PDA

View Full Version : Create texture w/o copying pixel data to it?



Foxbat
01-13-2006, 10:23 AM
Can you allocate a texture without copying 'pixels' data to it? i.e. call glTexImage* with a NULL value for the 'pixels' parameter?

The 'Why?' is to handle tiled image data without having to create an intermediate buffer in main memory. Pbuffers would do the trick too but wondering if it can be done with just textures.

ebray99
01-13-2006, 10:34 AM
yep, you can do that. You might encounter some bugs in the driver, but thats perfectly legit (might not be in old versions of OpenGL?). If you encounter problems, you can always initialize your texture to garbage and simply fill it in as needed.

sqrt[-1]
01-13-2006, 02:56 PM
Supplying NULL for pixels is core OpenGL 1.1

dmy
01-14-2006, 06:44 AM
also, you could get pixels from the the framebuffer with glCopyTexImage2D: no need for a starting sysram buffer then.

macarter
01-14-2006, 04:46 PM
Originally posted by Foxbat:
Can you allocate a texture without copying 'pixels' data to it? i.e. call glTexImage* with a NULL value for the 'pixels' parameter?

The 'Why?' is to handle tiled image data without having to create an intermediate buffer in main memory. Pbuffers would do the trick too but wondering if it can be done with just textures.I have done this with glTexImage2D for the same reason you suggested. I was suprised when it failed for glCompressTexImage2D. The specification for glCompressTexImage2D does not explicitly allow a NULL pointer.

vince
01-18-2006, 08:23 AM
Originally posted by Foxbat:
Can you allocate a texture without copying 'pixels' data to it? i.e. call glTexImage* with a NULL value for the 'pixels' parameter?
Yes you can, but I tried about 2 years ago and the nVidia driver was crashing, while it was working fine with ATI. I didn't rechecked since if they fixed it.