NPOT support in OpenGL for R8G8B8 texture

后端 未结 1 494

I have created a sample application using glew and glut which reads a dds file and displays it. I manually read the dds file (NPOT(886 x 317) file in R8G8B8) and creates the dat

相关标签:
1条回答
  • 2021-01-24 10:33

    This looks like an alignment issue. Add this before the glTexImage2D() call:

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    

    This value specifies the row alignment of your data in bytes. The default value is 4.

    With your texture width of 886 and 3 bytes per pixel for GL_RGB, each row is 886 * 3 = 2658 bytes, which is not a multiple of 4.

    With the UNPACK_ALIGNMENT value at the default, the size would be rounded up to the next multiple of 4, which is 2660. So 2660 bytes will be read for each row, which explains the increasing shift for each row. The first row would be correct, the second one 2 bytes off, the 2nd row 4 bytes off, the 3rd row 6 bytes off, etc.

    0 讨论(0)
提交回复
热议问题