I want to draw random size squares in the position where the mouse clicks. But my code changes the size of the rectangle already painted. I want to ask how I can change my code for not Change the size of the rectangle drew before. here is my code little.
GLfloat myVertices[10][2];
GLint count = 0;
std::default_random_engine(dre);
std::uniform_int_distribution<> uid(10, 100);
void Mouse(int button, int state, GLint x, GLint y)
{
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
myVertices[count][0] = x;
myVertices[count][1] = (600 - y);
count++;
}
}
GLvoid drawScene()
{
GLint index;
if (count > 0)
{
for (index = 0; index < count; index++)
{
glRectf(myVertices[index][0], myVertices[index][1], myVertices[index][0] + uid(dre), myVertices[index][1] + uid(dre));
}
}
glFlush();
}