Page 1 of 1

glTexImage2D Trick

Posted: Sun Oct 17, 2010 8:13 pm
by mh
Say you're creating a texture object but you don't have the data for it yet. You might think that you need to allocate a dummy buffer of the right size, but you actually don't. Just give glTexImage2D a NULL pointer and it will happily create the texture for you.

It's all there in the documentation (http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml).

Posted: Sun Oct 17, 2010 9:36 pm
by r00k
In GL version 1.1 or greater, data may be a null pointer.
In this case, texture memory is allocated to accommodate a texture of width width and height height. You can then download subtextures to initialize this texture memory.
The image is undefined if the user tries to apply an uninitialized
portion of the texture image to a primitive.
When they say 'download' are they referring to selecting a texture already in an array?

Posted: Mon Oct 18, 2010 12:12 am
by Spike
they mean uploading a section of a larger texture.