Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Scrowubit

glReadPixels giving an RGB offset

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

hey, im having this strange problem with glReadPixels, im using it to tell wether ive clicked on something or not... if i draw a box with rgb values of 0.02f, 0.02f,0.02f and click on it & get it to display the RGB values of whats under the mouse it gives me an offset of -0.000392f it appears as "COLORS UNDER MOUSE: R:0.019608 G:0.019608 B:0.019608" im running my prog in 32 bit color depth & i have no clue what this problem could be...any idea''s anyone? this one has been bothering me for a week.

Share this post


Link to post
Share on other sites
Advertisement
That''s absolutely normal.

As you run in 32bits color depth, that means you have 8bits for Red, 8bits for Green, 8bits for Blue, and 8bits for Alpha (and NOT 32bits for each).

Assuming that a 8bit buffer can define INTEGER values between 0 and 255, there you go:
your value is 0.02, which is coded as 0.02*255 = 5.1, but as the value is stored as an integer, it is the number 5 in each 8bit buffer.
When you decode the value, it is 5/255 = 0.01960784313725490196078431372549...

got it ?

Share this post


Link to post
Share on other sites
Thanks alot man ^_^
im gonna try implement that now, i wont be sorry to have my buggy ass mouse interface system bug free :D

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!