Sign in to follow this  
Pirosan

OpenGL 2d Opengl in a 3d world

Recommended Posts

Hello, I am looking for a good resource for 2d rendering in opengl. In my application i have set up the camera and everything, so i dont know how to just draw 2d shapes. I am looking for quick and easy access to the screen so i can draw HUD devices, cursors, indicators etc... for my game. Thanks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Set up an orthogonal projection matrix and draw your 2D shapes (Quads, Triangles) as normal (preferably with near-zero z component). It's pretty simple, really.

Share this post


Link to post
Share on other sites
I'm using NeHe Lesson 32 as the basecode for my 2D in a 3D world engine.

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=32

Make sure to take out the "GlLoadName(x)..." lines of code in the drawing section if you aren't going to do object picking. If you don't, x can't be higher than 64, and your game can crash if it is. The only thing GlLoadName is used for is to assign a name to the texture so you can "pick" it with the mouse, which I doubt you will be doing unless you're using a menu.

The base code fits well for 2D on 3D. Its got no advanced features so it should run on ancient computers with OpenGL, and its pretty optimized. Even after I added my physics/collision detection and started blasting fireballs at 100 or so objects, it was running at 1000-2000 fps. Lets face it, you want your 2D game to run well on old computers, because its expected.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this