Help with gluOrtho2d call please.

I have a simple program that starts up and draws a 640x480 window and displays a few points.

I set up my window with :
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(SCREEN_HEIGHT /640/, SCREEN_WIDTH /480/);
glutCreateWindow(“My window”);

To initially draw the first picture I call this:

Here is DrawIt:
void DrawIt() {
gluOrtho2D(0.0 , SCREEN_WIDTH , 0.0 , SCREEN_HEIGHT);
glClear(GL_COLOR_BUFFER_BIT); //clear the screen
glBegin (GL_POINTS);
glVertex2i(100, 50);
glVertex2i(100, 130);
glVertex2i(150 , 130);
glFlush(); //send all output to display

Now the problem, I want the user to be able to hit any key, and I want to draw a different picture. Only the world coordinates could be from 0.1 to 0.9, instead of from 0->640 and 0->480. How do I set up the new mapping. Another call to gluOrtho2d(0.0 , 1 , 0.0 ,1); doesnt seem to work.

You aren’t clearing the matrix before calling gluOrtho2D. So the old matrix from the last frame is still there, and your new gluOrtho2D matrix is being multiplied with it. Which results in something very different from what you actually wanted.

Add a call to glLoadIdentity before the gluOrtho2D call.

Thanks, that worked!