Advertisement

Wierd problem reading pixels with glReadPixels

Started by January 27, 2002 02:18 PM
0 comments, last by Scrowubit 23 years, 1 month ago
Hey, ive just started to set up a mouse click interface system in my game & im currently using the glReadPixels method to detect what a user has clicked on, ive run into a really weird problem though... if i have 2 quads, one rendering Full red for the call to glReadPixels and one rendering Full green...i draw the first quad (roughly in the center of the screen )...ok...click on it...wehey it works.... i insert the code for drawing the second quad ( 2 units below the fist quad ) try click on it....hmmm....nothings happening... if i click roughly 2 units above the first quad THEN it responds as if ive clicked on the second quad... its as if its flipping the Y axis, i think ive read somewhere that you must first flip the Y axis...but that mightve been for picking with the selection buffer. Any idea''s? i can post code if needed but hopefully its just a stupid newbie mistake & someone will spot it right away.
****************************Yesterday we Obeyed kings & bent our necks before emperors,but today we kneel only to the truth.****************************
whao its ok now Terminate helped me on the IRC channel

the prob was i was using GetCursorPos(&mpos) to get the cursors x & y co-ords, but GetCursorPos(&mpos) considers 0,0 as top left

and glReadPixels considers 0,0 as bottom left hence the Y flipping

GetCursorPos(&mpos);
mpos.y= -mpos.y+Window_Hieght;

seemed to fix it.

Edited by - Scrowubit on January 27, 2002 3:59:51 PM
****************************Yesterday we Obeyed kings & bent our necks before emperors,but today we kneel only to the truth.****************************

This topic is closed to new replies.

Advertisement