2D Drawing in OpenGL

Posts: 133
Joined: 2008.05
Post: #1
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?
Quote this message in a reply
Posts: 156
Joined: 2002.11
Post: #3
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. :)
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  opengl text/font drawing from CGContext fretmunky 11 16,705 Dec 7, 2008 11:29 AM
Last Post: fretmunky
  OpenGL ES - Drawing a simple cube help. MattCairns 7 15,523 Oct 10, 2008 05:26 PM
Last Post: Frogblast
  Drawing bitmaps in OpenGL MacGoober 21 29,198 Sep 22, 2007 05:50 PM
Last Post: MikeC
  Opinions Of My Personal OpenGL Math/Quick Drawing Functions Nick 8 5,167 Aug 22, 2004 09:23 AM
Last Post: Skorche
  openGL 2d drawing problems, objects appear to overlap matthew 12 8,129 Oct 5, 2003 07:53 PM
Last Post: matthew