I want to plot a rectangle by mouse click in opengl. But I failed to do it, it's very comfued, by the way, the rectangle just exists in a flash, then disappear.

void OnMouse(int button, int state, int x, int y)
{	
      glRectf(a,b,0,-10);
}
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
           ......................
	glutMouseFunc(OnMouse);
	glutMainLoop();
	return 0;
}

How can I solve it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.