PDA

View Full Version : Glut Mouse Func



Joshhua5
01-07-2011, 12:58 AM
Hello, I'm trying to use the glut mouse function but how it's used is kinda confusing in the refrence...

My function name is startMouseClick
state GLUT_DOWN
Button GLUT_LEFT_BUTTON

How do i put that into the glutMouseFunc()

mobeen
01-07-2011, 01:09 AM
Hello, I'm trying to use the glut mouse function but how it's used is kinda confusing in the refrence...

My function name is startMouseClick
state GLUT_DOWN
Button GLUT_LEFT_BUTTON

How do i put that into the glutMouseFunc()
Hi, its a fairly simple thing.
create the mouse func. like this


void OnMouseClick(int button, int state, int x, int y)
{
if (button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN)
{
//store the x,y value where the click happened
puts("Middle button clicked");
}
}
and then attach it to the glutMouseFunc(OnMouseClick);

Joshhua5
01-07-2011, 01:12 AM
Okay so all the GlutMousefunc is doing is running a function and in the function you do all the States

mobeen
01-07-2011, 01:17 AM
glutMouseFunc is attaching the func. u give it as a callback. Whenever any mouse event takes place (like mouse click), this function will be called automatically by glut.

Joshhua5
01-07-2011, 01:44 AM
KK Thx