views:

76

answers:

2
+1  A: 
glMatrixMode( GL_PROJECTION );

The above line is the one causing problems. Change it to "glMatrixMode(GL_MODELVIEW);" since you are not really using the projection matrix for anything.

The projection matrix is used to set the projection parameters like perspective/orthographic mode, FOV etc. This needs to be done usually at time of creation of window and whenever the window/viewport size changes. The the modelview matrix is used for translations, rotations and scaling.

Due to the way OpenGL works, its very important to keep track of the "state". The general workflow is to set the projection mode, change the parameters as desired and change back to modelview mode immediately, like:

glMatrixMode(GL_PROJECTION);
//...
//do various projection stuff
//...
glMatrixMode(GL_MODELVIEW);

This applies to many things in OpenGL, not just matrix state but other things like lights, blending etc etc too. Its very common to have a "default" state to return to after doing a set of operations before doing another set of operations and again switching back to default state.

Vaayu
Thank you for your suggestion, Vaayu. I tried changing the line that you suggest, but for me the problem still persists. The colors are not being displayed correctly, and when I try passing negative arguments to the `glPixelZoom` function, nothing but a white background is displayed. Perhaps this is a platform-specific problem? I am working with Mac OS X 10.6.4 using gcc 4.2.1.
Nicholas Kinar
Perhaps there is another way to do what I want (display a pixmap as demonstrated in the code above), and this way does not involve the `glDrawPixels` function?
Nicholas Kinar
+2  A: 
Nicholas Kinar