Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


OpenGL 2D graphics with OpenGL

This topic is 6313 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to do 2D graphics programming with OpenGL like it is with DirectDraw? Or is it more similar to the new Direct3D?

Share this post

Link to post
Share on other sites
OpenGL was innitially a 2D graphics library, with 3D being added later. It''s very possible (and quite easy) to do 2D graphics with it. Look up glVertex2f and glOrtho.

For switching to a 2D perspective for drawing, I use the following function. Not sayings it''s the best, but it does the job.

void GL_Set2D ()
glLoadIdentity ();
glOrtho (0, 100, 0, 100, -99999, 99999);
glLoadIdentity ();

That will set OpenGL to draw in 2D. When drawing to the screen, you pass the location of where you want it drawn as a percentage of the screen size, so that glVertex2f(50,50); would place a vertice on the centre of the screen, no matter what your screen resolution is at.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!