Jump to content
  • Advertisement

Archived

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

EGD Eric

OpenGL Picking a "Screen Rect" out of an OpenGL screen

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

I''m making a 2D game in OpenGL. I want to have a world full of dust particles and background textures, etc.. But I have to only draw the screens that are within view of the player. I tried having list of "screen" objects, each with its own list of particles. That''s about 100,000 screens, each with about 200 particles. And I''m drawing them all! Are you surprised to hear that the game wouldn''t run? ALL the CPU was used. So know I''m thinking that I can save alot of processing by by only drawing the screen (and the adjacent ones) that the player is in. I could just index the array of screens something like this: screen[playerX][playerY] and draw that one But how do I figure that out which screen the player is in? The player''s screen size is measured in floats, and changes depending on how zoomed in or out the camera is.

Share this post


Link to post
Share on other sites
Advertisement
I''ve read that example thoroughly. Is there an easy way to figure out the width and height of the viewport from that? Yes, I know you can just do:

int viewPort[4]

glGetIntegerv(GL_VIEWPORT, viewPort)

But I need to figure out the width and height of a screen in unit values, not pixel values. I know I could just measure the screen dimensions manually, but then those values would be outdated if I made the camera any higher or lower.

To give you more information on my problem, the reason I want to be able to get coordinates like this is for scrolling purposes in a 2D asteroids clone that uses 3D models.

Share this post


Link to post
Share on other sites

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