glTexSubImage2D crashes

Hello when I resize the Windowsize I also need to resize a
texture and fill it with content. So I resize the Texture
with glTexImage2D and then upload the changed data with
glTexSubImage. But when I resize the Window just a little bit then the application crashes at glTexSubImage2D. But I dont
know why. But when I resize the window with the maximize button
in the windowbar there are no crashes. I can do it as often as
I want. But resizing the window picking the window border and
change the size cause in a crash.

any ideas ?


Edit: it crashes only if I change the window width.

it was my mistake… :smiley:


Hi lobbel,

i’v got the same problem. What was your mistake and how did you solve it ?


Ok, I have solved the problem by changing the format from GL_RGB to GL_RGBA. Seems to be a bug in nvidia driver.


Read “7. Watch Your Pixel Store Alignment” here :

GL_RGB is not a multiple of 4 bytes (the default). And if you don’t take special care, you will get access to invalid memory -> crash.

Just use this and it should work with GL_RGB too :
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);