PDA

View Full Version : glTexSubImage2D Screws up Texture



mayursb
05-26-2005, 12:36 PM
Hi,

I am creating a texture using :

::glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB16,
TxWidth,
TxHeight,
0,
GL_BGRA_EXT,
GL_UNSIGNED_BYTE,
pBuffer);

"pBuffer" points to a 32 bit buffer which is connected to a DIB.

When I update a section of this texture using :

::glTexSubImage2D(GL_TEXTURE_2D,
0,
x,
z,
w,
h,
GL_BGRA_EXT,
GL_UNSIGNED_BYTE,
pSectionBuffer
);I am getting a obscured output on the screen !

Is there anything wrong with my usage of 'glTexSubImage2D' ?

Thanks in advance.

dorbie
05-28-2005, 07:06 PM
You seem to use z in there instead of y.

The subimage image you're loading itself needs to be contiguous in memory OR you have to set pixel store to stride through the portion of the image not used.

use glPixelStorei with GL_UNPACK_ROW_LENGTH

Don't forget to set it back :-)