azverkan@hotmail.com

OpenGL bug in glCopyTexImage2D

Discussion created by azverkan@hotmail.com on Feb 26, 2009
Latest reply on Mar 11, 2009 by avk
Quantizing depth texture information

Right now if you create a GL_DEPTH_COMPONENT24 texture and use glCopyTexImage2D with GL_DEPTH_COMPONENT to fill that texture from a 24bit depth buffer, only the top 16bits of the 24bit texture get copied.

Right now you have to you have to explicitly say GL_DEPTH_COMPONENT24 to copy all 24bits into the destination texture.  This seems like incorrect behavior (and differs from what the NVidia OpenGL implementation does).

Example:

 

glBindTexture(GL_TEXTURE_2D, 1);

glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, w, h, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);

glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, w, h, 0);

 

Workaround:

 

glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 0, 0, w, h, 0);

 

Outcomes