captncraig
captncraig

Reputation: 23078

Display image in opengl

I am fairly new to openGL. I have a 3d game that I have running, and it seems to go fairly well. What I would like to do is display an image straight onto the screen, and I am not sure the easiest way to do that. My only idea is to draw a rectangle right in front of the screen and use the image as the texture. It seems like there should be an easier way.

This is for menu screens, and things, so if there is a better way to do that as well, please let me know.

Upvotes: 2

Views: 1870

Answers (2)

Drew Hall
Drew Hall

Reputation: 29045

You've got the basic idea. The other obvious alternative is to use glDrawPixels() but I think you'll find the texture method has much better performance. If you're feeling frisky, you might also take a look at Pixel Buffer Objects.

Good luck!

Upvotes: 0

mrkj
mrkj

Reputation: 3101

I would recommend setting up OpenGL for 2D rendering via gluOrtho2d(); then, load the image into a texture and, as you said, draw it to the screen by creating a polygon and binding the texture to it. A good example can be found here.

Upvotes: 5

Related Questions