Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Using glOrtho ()

  1. #1
    Intern Contributor
    Join Date
    May 2002
    Location
    Irvine, CA, USA
    Posts
    51

    Using glOrtho ()

    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?

  2. #2
    Intern Contributor
    Join Date
    May 2002
    Location
    Irvine, CA, USA
    Posts
    51

    Re: Using glOrtho ()

    Ignore this thread, I've gone stupid.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •