iDevGames Forums
2D Drawing in OpenGL - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: 2D Drawing in OpenGL (/thread-6641.html)

2D Drawing in OpenGL - longjumper - Nov 20, 2003 10:43 PM

I want to draw something that isn't 3D at all. I guess I'd like to draw something without any projection, kind of like "in the front" of the screen. So when I draw something with the coordinates -.5,.5 as left corner and 0,0 and the bottom right corner, I'd like it to cover exactly 1/4th the screen, the second quadrant. I also need to do this after I draw some projected stuff.

I'm guessing it would have to do something with setting up another camera orthographically, then pushing the matrix calling the camera render function, and drawing?

2D Drawing in OpenGL - FCCovett - Nov 20, 2003 11:03 PM

Check this out (in Carbon/C):

2D Drawing in OpenGL - johnMG - Nov 21, 2003 06:04 PM

Using glut, I wanted the dimensions of my drawing area to match up with the actual pixels, so I did this:
void my_reshape_func( int w, int h )
    glViewport( 0, 0, w, h );
    glMatrixMode( GL_PROJECTION );
    glOrtho( 0.0, static_cast<double>( w ),
             0.0, static_cast<double>( h ),
             -1.0, 1.0 );

    glMatrixMode( GL_MODELVIEW );

You'll need to pass something different than w & h to glOrtho() if you don't want (0.0, 0.0) to be the bottom left corner. Enjoy. :)