PDA

View Full Version : Mouse Clicks



Erin C.
10-26-2008, 09:27 PM
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.

trinitrotoluene
10-27-2008, 06:52 AM
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;
}
}

Officedog
10-28-2008, 06:32 AM
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 &amp;&amp; x<300 &amp;&amp; y>100 &amp;&amp; y< 300)
{
glColor3d(1,0,0);
glutPostRedisplay();
}
........ etc etc