Jump to content
  • Advertisement
Sign in to follow this  
coordz

OpenGL silly question - 0.5 as a byte? 127 or 128?

This topic is 4155 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

Sorry for this dumb question but... I want to load a (floating point) texture with 0.5 quickly so I load it using bytes to cut down on my memory bandwidth usage. As far as OpenGl and GLSL are concerned what is 0.5 as a byte? 127 or 128?

Share this post


Link to post
Share on other sites
Advertisement
0.5 is 127 in case you count byte as 0-255, and 128 in case byte is 1-256. Gl uses first scheme, but you need to take into account buffer depth, in 16 bit mode you get only 5 bits per pixel, so both values will be rounded roughly to 0.5, and why don't use floating color values instead of bytes ? As far as i know they faster, and easier to understand

Share this post


Link to post
Share on other sites
Asuming you load a single channel texture which represents each pixel with one byte, it shouldn't matter whether you use 127 or 128 since: 0(byte) = 0.0f(float), 255(byte) = 1.0f (float) -> 127 = 0.498, 128 = 0.501.

Share this post


Link to post
Share on other sites
Further thinking about this has made me realize it was a really stupid question..... 0.5 lies exactly at 127.5 so either 127 or 128 are equally good.

Thanks for humouring me :-D

Share this post


Link to post
Share on other sites
Quote:
Original post by coordz
Further thinking about this has made me realize it was a really stupid question..... 0.5 lies exactly at 127.5 so either 127 or 128 are equally good.

Thanks for humouring me :-D


It depends on whether you follow the Path of Light, or the Path of Darkness. ;)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!