Etienne Belanger(deleted)
|
Re: glTexImage2D with NULL pointer to texture memory
|
Etienne Belanger(deleted)
03/26/2009 9:28 AM
post25320
|
Re: glTexImage2D with NULL pointer to texture memory
What you are trying to do, i.e. call glTexImage2D with no data to allocate memory for a texture, and then use
glTexSubImage2D to upload data should be supported in OpenGL ES 1.0.
You can write a test app that does:
...
glBindTexImage2D(GL_TEXTURE_2D, tex1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_w, texture_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data->pixels);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
glDrawArrays(...);
and compare with:
...
glBindTexImage2D(GL_TEXTURE_2D, tex1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_w, texture_h, 0, GL_RGBA, GL_UNSIGNED_BUTE, NULL)
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture_w, texture_h, GL_RGBA, GL_UNSIGNED_BYTE, data->pixels);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
glDrawArrays(...);
Both should give the same results.
Note that the texture data may not be updated immediately after the call to glTexImage2D or glTexSubImage2D returns. A
copy of the texture data may be held in system memory until the texture is actually needed.
|
|
|