void drawMolecule() {
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glOrtho (0, 400, 400, 0, 0, 1);
glMatrixMode (GL_MODELVIEW);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
for (int i = 0; i < 100; i++)
{
getColor(grid);
getTransform(grid);
glBegin(GL_QUADS);
glVertex2i(0, 0);
glVertex2i(20, 0);
glVertex2i(20, 20);
glVertex2i(0, 20);
glEnd();
}
glutSwapBuffers();
}
But, when I do so, everything gets shifted down when I call glutPostRedisplay in another function... How can I stop it from shifting down? I am calling the translations in the getTransform function which is defined as follows:
void getTransform(point x) {
glTranslatef(21, 0, 0.0);
if (counter % 10 == 0 && counter >= 10) {
glTranslatef(0, 21, 0);
glTranslatef(-210, 0, 0);
}
counter++;
}
Any help would be appreciated.