Mouse Clicks

Hi there,
I’m new to OpenGL, but I’m hoping someone can point me in the right direction.

I want to check if GLUT_LEFT_BUTTON and if click is within the region of my square. The only problem is I’m not sure the syntax for checking if its in the bounds of that square.

Thanks for the help.

The syntax is something like this:


void mouse(int button, int state, int x, int y) 
{
  switch (button) 
  {
    case GLUT_LEFT_BUTTON:
      if (state == GLUT_DOWN)
      {
       //do work here
      }    
      break;
    ....
    default:
    break;
  }
}

This is something I tried for the glutMouseFunc function- I’m not claiming it’s ‘good code’ but it worked

void mouse(int button, int state, int x, int y)
{
    if(button == GLUT_LEFT && state == GLUT_DOWN)
    {
        if (x>100 && x<300 && y>100 && y< 300)
        {
            glColor3d(1,0,0);
            glutPostRedisplay();
        }
     ........ etc etc