When I load a texture in OpenGL and this has one (GL_ALPHA
) or three components per pixel (GL_RGB
), the texture appears tilted. What makes this happen?
As additional detail, the relation width/height seems to affect. For example, an image of 1366x768(683/384) appears tilted while an image of 1920x1080(16/9) is mapped correctly.
This is probably a padding/alignment issue.
GL, by default, expects rows of pixels to be padded to a multiple of 4 bytes. A 1366 wide texture with 1 byte or 3 byte wide pixels, will not be naturally 4 byte aligned.
Possible fixes for this are:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With