Jump to content
  • Advertisement
Sign in to follow this  
Pirosan

OpenGL 2d Opengl in a 3d world

This topic is 4736 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

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
Advertisement
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
Sign in to follow this  

  • 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!