Jump to content
  • Advertisement
Sign in to follow this  

Texture memory alignment question

This topic is 2111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is a follow-up of my previous thread.


Yesterday, i was trying my project on a resolution of 1366x768 and found the following bug. I didn't take long for me to realize what was wrong.

Im extracting the image from win32 DIBs bitmaps and they are padded to be aligned to 4 bytes, and 1366 is not aligned, so the extra 2 bytes was getting in the way.

So, i rewrote the algorithm to take padding into account and fixed the bug. However, im wondering if that was not a mistake.


If i continue on this path, and go for lower than 8 bpp, the algorithm is gonna get very messy. Ex 1366 / 8 = 170.75. That mean i would have to shift bits all around and such.


Then, it hit me, what if i leaved the padding as it is, and use


glPixelStorei(GL_UNPACK_ALIGNMENT, 4);


instead of


glPixelStorei(GL_UNPACK_ALIGNMENT, 1);


would that solve the issue?

Edited by Vortez

Share this post

Link to post
Share on other sites

Ok thx, ill try it out.


And ill make sure to rate you up later when i have more points to spend :) .

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!