Doing 2D things with OpenGL

Started by
2 comments, last by Mulligan 22 years, 1 month ago
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.
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

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.
神はサイコロを振らない!
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

This topic is closed to new replies.

Advertisement