Jump to content
  • Advertisement

Archived

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

Flibble

Mouse in openGL?

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

Does anyone know how I can use the mouse to select objects in openGL written in Win32 (not GLUT) - (using NeHe''s tutorials)? Thanks

Share this post


Link to post
Share on other sites
Advertisement
u could use the selection buffer. examples in the red book and the glut distribution. + no glut aint necessary

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
I have tried that, and I can''t make it work - I always get 1 hit - even though I don''t click - I think it is because the mouse is from Windows and works on different co-ordinates to the openGL window - any ideas?

Share this post


Link to post
Share on other sites
with windows (0,0) is at the top left of the screen, in gl thats the bottom left so any so u have to alter the ycoord that u pass to the selection function eg the user has clicked 10 pixels under the title bar at the top u use (x, windowheight-y)

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
But, how do I convert from windows co-ordinates eg.

Length
(0 - 823) - Windows screen co-ordinates
to
(-22 - +22) - openGL drawing co-ordinates?

Share this post


Link to post
Share on other sites
not necessary
have a look in the red book or glut for example code using gluPickMatrix.
gluPickMatrix( cursorx,winheight-cursory, 1, 1, viewport)

if u wanna find out whereabouts in your world the mouse is (use gluUnProject(..)

also check the FAQ http://www.frii.com/~martz/oglfaq/

http://members.xoom.com/myBollux

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!