Jump to content
  • Advertisement

Archived

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

Mulligan

OpenGL Doing 2D things with OpenGL

This topic is 6056 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 render 2D images with opengl? Now I''m not talking about particle like sprites, but something more along the lines of DirectDraw. Lets say that I have a 800x600 image and I''m in 800x600 display mode. Is there a awy to make it fi the screen perfectly? I hope that makes sence.

Share this post


Link to post
Share on other sites
Advertisement
To draw images onto the screen you can use two different approaches:

1. blit the image with glDrawPixels

2. draw a quad that is textured with the image data (remember to calculate the right texture size (powers of 2 ) and the texcoords).

FunkyMonk

Share this post


Link to post
Share on other sites

Ahh... But there''s a third (easy and fast) way:

3. Use glViewport() and glOrtho() to set up the orthographic
projection. Then use glVertex().

  
glViewport(0, 0, Width, Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, Width, Height, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Do your drawing



(0, 0) is top-left and (Width, Height) is bottom-right.
Pixel-coordinates. Simple.


Premature optimizations can only slow down your project even more.

Share this post


Link to post
Share on other sites
sorry if it''s stupid, but...

how do you make that tangentz ? the white screen ? is there any way to draw something here in order to explain better what you want ?

thanx a lot

Fratt

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!