Jump to content

  • Log In with Google      Sign In   
  • Create Account


Texture memory alignment question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Vortez   Crossbones+   -  Reputation: 2697

Like
1Likes
Like

Posted 04 January 2014 - 04:48 PM

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, 04 January 2014 - 04:49 PM.


Sponsor:

#2 richardurich   Members   -  Reputation: 1187

Like
1Likes
Like

Posted 04 January 2014 - 05:49 PM

Yes. GL_UNPACK_ALIGNMENT from the spec: "Specifies the alignment requirements for the start of each pixel row in memory. The allowable values are 1 (byte-alignment), 2 (rows aligned to even-numbered bytes), 4 (word-alignment), and 8 (rows start on double-word boundaries)." (http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)



#3 Vortez   Crossbones+   -  Reputation: 2697

Like
0Likes
Like

Posted 04 January 2014 - 06:06 PM

Ok thx, ill try it out.

 

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



#4 Vortez   Crossbones+   -  Reputation: 2697

Like
0Likes
Like

Posted 04 January 2014 - 08:17 PM

That seem to do the trick!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS