Jump to content
  • Advertisement
Sign in to follow this  
svnstrk

GLUT detect idle mouse position in OSX

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

[font=arial, helvetica, sans-serif][size=2]
hi,


Im trying to build an opengl application using glut in OSX.


Glut supports mouse feedback when the button is pressed or the mouse is moved. But no function when the mouse is idle. So in my scene the camera moves, hence the position of the mouse based on world coordinate is moved. i need that position even when the mouse is on idle state (not moved nor pressed). Any idea how to do it or where to start?



Thanks in advance[/font]

Share this post


Link to post
Share on other sites
Advertisement

int g_mousePosX=0;
int g_mousePosY=0;

void motion(int x, int y)
{
g_mousePosX = x;
g_mousePosY = y;
}

void passiveMotion(int x, int y)
{
g_mousePosX = x;
g_mousePosY = y;
}

void main()
{
glutInit();
// create window etc
glutPassiveMotionFunc(passiveMotion); //< when buttons are not held
glutMotionFunc(motion); //< when buttons are held
}


Although reading your question again it seems that you just want to offset the mouse cursor when the camera moves? glutWarpPointer might be what you are looking for. To be honest though, it sounds like you have some logic wrong in the way you are trying to solve whatever it is you're trying to solve. What is the actual problem you are trying to solve?

Share this post


Link to post
Share on other sites

Although reading your question again it seems that you just want to offset the mouse cursor when the camera moves? glutWarpPointer might be what you are looking for. To be honest though, it sounds like you have some logic wrong in the way you are trying to solve whatever it is you're trying to solve. What is the actual problem you are trying to solve?


hi Rob,

actually what I want is the other way around. I already glutMouseFunc, glutMotionFunc and glutPassiveMotionFunc but it does not work. This is what I actually want:

The camera view is isometric. I want to draw a line from the player position to the mouse pointer and it defined in the world space coordinate. So when the mouse points at x, y at screen space, I calculate the x, y at world space and draw a line from the player and the x, y at world space. I call this function when the mouse if moved, dragged, or pressed by using the 3 function above. When the pointer moves it works perfectly.

But when the camera moves (without moving the mouse), the other end of the line (the one at the mouse pointer) does not follow the mouse position because the function does not called. what I need is a function that can be triggered even when the mouse is idle. is there such function? or any1 has a better solution?

its quite hard to capture this but i'll try again later.

thanks in advance

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!