PDA

View Full Version : Using glOrtho ()



rgreene
09-11-2002, 06:49 PM
I'm having trouble getting stuff to show up when using an orthagonal projection. Here's some sample code:

glViewport (0, 0, 256, 256);
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
glOrtho (0, 256, 0, 256, 1, 1000);

glClearColor (0, 1, 0, 1);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode (GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity ();

glDisable (GL_CULL_FACE);
glBegin (GL_TRIANGLES);
glColor3f (1, 1, 0);
glVertex3f (-1, -1, 10);
glColor3f (0, 1, 0);
glVertex3f (1, -1, 10);
glColor3f (0, 0, 1);
glVertex3f (0, 1, 10);
glEnd ();

glPopMatrix ();

glFlush ();
_pixels = new int32u[256 * 256];
glReadBuffer (GL_BACK);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, _pixels);


Basically, I'm attempting to draw something into the backbuffer, then read it back out to store it as a texture. I'm having difficulty getting anything to come out other than the clear color. Is there any way to apply the projection matrix to a vertex to see what values actually sent to the rasterizer? In DX there was a method to do this, or I could step through a vertex shader to see which pixels are to be touched. In OpenGL, I don't know how to do this. What am I doing wrong here?

rgreene
09-11-2002, 07:09 PM
Ignore this thread, I've gone stupid.