glTexSubImage3D exception

vindos

Newcomer
Hello..
I have a 3d texture which i update using the code

unsigned char *p = new unsigned char[ x * y * z ];
memset( p, 0, x * y * z );
glGenTextures(1, &g_Texture3D );
glBindTexture(GL_TEXTURE_3D, g_Texture3D );
glTexImage3DEXT(GL_TEXTURE_3D, 0, GL_RGBA, x, y, z, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, p );

This code works well when X is even but glTexImage3DEXT crashes when x is odd.
Y and Z works doesnt seem to have such limitation.
Please help:?:
 
The problem is almost certainly that you haven't changed the pixel unpack alignment. It defaults to 4, which means that each row in the image needs to be 4 byte aligned. Try calling this before loading the texture:

glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
 
Back
Top