[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]
GLUT detect idle mouse position in OSX
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?
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement