Glut Mouse Func

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);

Okay so all the GlutMousefunc is doing is running a function and in the function you do all the States

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.

KK Thx