KingNestor
KingNestor

Reputation: 67950

How do I get the current mouse position in C++ / OpenGL?

I know that I can use a Mouse callback function for when a user clicks the mouse, but what if I want to know the current x/y position without the user clicking?

Will I have to use a different callback that gets called on any mouse movement and keep track of the x/y myself or is there a function I can call within GLUT/OpenGL to get it?

Upvotes: 3

Views: 20021

Answers (2)

epatel
epatel

Reputation: 46051

Register a glutPassiveMotionFunc callback function

See info about callbacks

Upvotes: 9

crashmstr
crashmstr

Reputation: 28563

You need to use the glutMotionFunc/glutPassiveMotionFunc callback to track mouse movement independent of mouse clicks.

7.6 glutMotionFunc, glutPassiveMotionFunc

Upvotes: 4

Related Questions