Archived

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

EGD Eric

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

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