Hi everybody ,,
How to let a rectangle to be dragged IF AND ONLY IF the mouse pointer is inside the rectangle ... !!!
Here is my rectangle and its parameters :
// Rectangle para.s
float x1=10.00f ,y1=-40.00f,x2=-60.00,y2=-50.00, D=0.0;
void drawbar (void)
{
glPushMatrix();
glTranslatef(dragx,dragy,0.0f);
glColor3f(1.0, 1.0, 1.0);
glRectf(x1,y1,x2,y2);
glPopMatrix();
}And here is my GlutMouse Function :
void myGlutMouse(int button, int button_state, int x, int y )
{
switch(button)
{
case GLUT_RIGHT_BUTTON:
if (button_state == GLUT_DOWN)
{ dragging = true; y = 600 - y; // Win(0,0)
// is left top
lastMouseX = x;
lastMouseY = y;}
else
dragging = false;
// default:
// break;
}
}Thanks in advance ...
