Forum

glTexImage2D Trick

Discuss programming topics that involve the OpenGL API.

Moderator: InsideQC Admins

glTexImage2D Trick

Postby mh » Sun Oct 17, 2010 8:13 pm

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).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby r00k » Sun Oct 17, 2010 9:36 pm

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?
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby Spike » Mon Oct 18, 2010 12:12 am

they mean uploading a section of a larger texture.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK


Return to OpenGL Programming

Who is online

Users browsing this forum: No registered users and 1 guest