PDA

View Full Version : problem with drawing four points around the mouse



frescovivir
11-22-2010, 11:33 AM
Greetings everyone

i stated to learn opengl

and i want to write a program to
draw four points whenever the mouse clicked on the screen these four points surround the clicked position "on the corner" , i also want to be able to click and drag the mouse so the points move with the mouse while i click

this is what i have done so far i make it draw one point but it not move when i drag the mouse and i failed to make four points

void drawPoints()
{
glClear(GL_COLOR_BUFFER_BIT);
glPointSize(6);
glBegin(GL_POINTS);
glVertex2i(50,50);
glEnd();
glFlush();
}
void mouseFunc(int button, int state,int x,int y)
{
if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
drawPoints(x,y);
cout<<endl<<"x = "<<x<<endl<<"y = "<<600-y;
}
else
return;
}
int main(int argc, char** argv)
{
glutInit(&amp;argc,argv);
glutInitDisplayMode(GLUT_SINGLE |GLUT_RGB);
glutInitWindowSize(800,600);
glutInitWindowPosition(100,100);
glutCreateWindow("Draw");
Init();
glutDisplayFunc(drawPoints);
glutMouseFunc(mouseFunc);
glutMainLoop();
return 0;
}

please help

thank you