2D Drawing in OpenGL
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?
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?
Check this out (in Carbon/C):
http://webpages.charter.net/fccovett/MyGameSource.dmg
http://www.idevgames.com/forum/showthrea...#post54475
http://webpages.charter.net/fccovett/MyGameSource.dmg
http://www.idevgames.com/forum/showthrea...#post54475
Using glut, I wanted the dimensions of my drawing area to match up with the actual pixels, so I did this:
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. :)
Code:
void my_reshape_func( int w, int h )
{
glViewport( 0, 0, w, h );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0.0, static_cast<double>( w ),
0.0, static_cast<double>( h ),
-1.0, 1.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glutPostRedisplay();
}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. :)
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| opengl text/font drawing from CGContext | fretmunky | 11 | 11,397 |
Dec 7, 2008 11:29 AM Last Post: fretmunky |
|
| OpenGL ES - Drawing a simple cube help. | MattCairns | 7 | 10,981 |
Oct 10, 2008 05:26 PM Last Post: Frogblast |
|
| Drawing bitmaps in OpenGL | MacGoober | 21 | 19,019 |
Sep 22, 2007 05:50 PM Last Post: MikeC |
|
| Opinions Of My Personal OpenGL Math/Quick Drawing Functions | Nick | 8 | 3,465 |
Aug 22, 2004 09:23 AM Last Post: Skorche |
|
| openGL 2d drawing problems, objects appear to overlap | matthew | 12 | 4,769 |
Oct 5, 2003 07:53 PM Last Post: matthew |
|

