PDA

View Full Version : Very basic question



Bob H
09-13-2005, 05:44 AM
I have only been using OpenGL for about 24 hours. I have a behavior which I don't understand. I was trying to draw a series of lines but got nothing to display so I switched to a simple filled rectangle.

This is my environment: Windows platform, 32 bit color, 32 bit depth, writing to a bitmap

With this code --

glColor3f(.5f, 0, 0);
glRectf(0, 25.0f, 25.0f, 0);

the lower left quadrant of the window fills with red.

The window is approx 800 wide by 500 high. I don't understand how (0, 25) x (25, 0) maps to the lower left quadrant.

RigidBody
09-13-2005, 06:14 AM
you have to setup the projection and transformation
matrices before drawing the rectangle. if you try


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-20., 20., -20., 20., 1., 100.);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(25., 25., 10., 10., 10., 0., 0., 0., 1.);

glColor3f(.5f, 0, 0);
glRectf(0, 25.0f, 25.0f, 0); you'll see the rectangle from a different perspective.

Bob H
09-13-2005, 08:37 AM
Much appreciated. At least I have a clue now what boiler plate I need to get this rolling.