Archived

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

2D w/ OpenGL - Beginner Questions

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

Ok, I''ve went through the first few NeHe Tutorials, and I know how to draw Triangles and Quads on the screen and color them. Now, to solidify my knowledge to this point, I want to make a 2D Breakout Clone w/ OpenGL. I have a few questions right off the bat, and I''m hoping a few of you can help me out. 1) Is there anything special I should set in OpenGL if I''m using it to draw 2D and not 3D? Anything to give me the best perspective or view? 2) For Collision detection, is there a way to convert to and from OpenGL Coords and Screen Coords? 3) Any other hints on how to do 2D in OpenGL? Anything I need to know? Any words of Wisdom? thanks if you can help me out.

Share this post


Link to post
Share on other sites
quote:
Original post by Radagar
1) Is there anything special I should set in OpenGL if I''m using it to draw 2D and not 3D? Anything to give me the best perspective or view?

glOrtho gives you an orthographic projection which is best for 2d graphics (ie, no perspective!)

quote:
2) For Collision detection, is there a way to convert to and from OpenGL Coords and Screen Coords?

It depends how you setup your view (via glOrtho or not). A really simple way to do things is to set up the screen with one gl unit to one pixel. Or you can use gluUnproject to get world coords from screen coords. Or you can do the math yourself manually.

But you don''t want to convert for collision detection. Do all your game logic / collision etc. in your own world coords, then only convert when drawing to screen. Separate your game logic and information from your actual graphical output.

Share this post


Link to post
Share on other sites
Hi, start with lesson2.pdf and go through all these lessons. One of the lessons has collision. It will walk you through making a 2d game in opengl and is a pretty decent tutorial for beginners. it has some other stuff in there as well. I hope this helps what you are looking for or maybe you can use the extra info anyway.
2d Open GL


[edited by - dischord333 on February 20, 2004 2:51:57 PM]

Share this post


Link to post
Share on other sites