Skip to content

Bitmaps that have a width with a multiple of 4 do not render correctly when used as a texture. #1238

Answered by Underdisc
Underdisc asked this question in Q&A
Discussion options

You must be logged in to vote

It turns out it was definitely an issue of 4 bytes vs 1. When the width of the rendering is a multiple of 4 everything is fine, because opengl expected every row of the image to take up some multiple of 4 bytes. I padded every row by giving it the number of bytes it was missing in my own modified buffer and the character rendered correctly.

The padding of rows is actually something you can specify within opengl and you can do that with glPixelStore. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glPixelStore.xhtml. I thought something like this would be handled by glTexImage2D because of the GL_UNSIGNED_BYTE param and now feel outplayed.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nothings
Comment options

Answer selected by Underdisc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants