Skip to main content
gamedev.net
🔒 Locked

Mouse Coordinates?

Started by Daaark Jan 6, 2003 at 5:23 PM 3 replies 900+ views
Original Post
Daaark
Daaark
How Do I find the mouse coordinates in an OpenGL window?
buffalothunder
buffalothunder
It isn''t clear what you''re refering to. Probably getting the X, Y coords of the mouse cursor? Like the previous poster said, use your API first (DirectInput, SDL etc), or if you''re not using one, try the Windows GetCursorPos function. (You pass a reference to a POINT struct of your own to the function. check the win32 api.) Other than that, use windows messages.

Otherwise, you could be refering to Selection & Picking, for which there is tons of info. Google it, check the Programmers Guide and the usual tutorial sites.
aleks_1661
aleks_1661
if your using the GLUT library then there are a few functions you can use,

glutMotionFunc - when you drag with the mouse
glutPassiveMotionFunc - when your moving mouse without any buttons depressed.

if you want to convert window coordinates into opengl world co-ordinates then search for info about glProject and glUnProject.

"Very funny, Scotty. Now beam down my clothes."
Twitter: [twitter]CaffinePwrdAl[/twitter] Website: (Closed for maintainance and god knows what else)
Daaark
Daaark
Oops, my fault. I wasn''t specific enough. I just wanted to know if the Windows functions still worked.
I''ve been reading the selection stuff in the online redbook the last two days. Isn''t rendering my whole scene again a slow way to do it?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.