Jump to content
  • Advertisement
Sign in to follow this  
AdamGL

OpenGL Performance

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

Hi, I'm making a sidescroller and was wondering whether performance is decreased if I draw the whole map(then OpenGL figures out what to show). In a previous game I drew only the tiles that were seen, but If OpenGL handles this for me, will the program slow down? And another question... what functions would not work on an old 4mb video card(friends card, want the game to run on his computer)?

Share this post


Link to post
Share on other sites
Advertisement
It will always be faster for you to cull what will not be seen yourself. How much of a performance hit depends on how much you are telling OpenGL to draw that ends up not getting drawn.

You'll have to be more specific about the video card. Just saying it has 4MB isn't too informative. But my guess is, not much will work on it. At least, it won't work well.

Share this post


Link to post
Share on other sites
Well, I'm wanting to draw a long quad that goes off the screen. Now lets say I have lots of those. Do I let OpenGL handle it, and if not, how would I? And for the video card, I just want to draw quads and texture them(2-D style).

Share this post


Link to post
Share on other sites
If you're just drawing a single quad, let OpenGL handle it. How big of a quad are you planning on using?

Texturing 2D quads should be fine, as long as you use power of 2 textures.

Share this post


Link to post
Share on other sites
It's trivial to cull them yourselves. Assuming you use a for loop to send the tiles to OGL, you just set the start value and the end value for the starting pixel and the ending pixel (that is visible in the screen).
You probably won't notice a huge performance difference.. or even any at all. You would find differences when drawing much more geometry in the same tile-based way. Either way, it probably couldn't hurt to do it yourself.

Share this post


Link to post
Share on other sites
Quote:
Original post by AdamGL
Well, I'm wanting to draw a long quad that goes off the screen. Now lets say I have lots of those.


Then it depends on a) what you consider "lots" and b) how you would cull them. Because starting to cull single primitives is a waste of time and you will spend a lot more time culling than it would have taken to just draw them. Always find a way to cull a large chunk of primitives in and efficient way. For a grid of quads that could be figuring out which part of the grid to draw.

ie:
figure out start and end;
for (start to end) draw quad;

is good

for (all quads)
figure if visible
draw if visible

is horrible.

If your goal is to draw a huge grid or terrain, then two ways come to mind. In both ways you would group a good number of quads to a chunk.

a) Use something like a quadtree for culling, if your tree is growing deep and/or isn't implemented in an at least somewhat efficient way you might waste more time on the whole tree-traversing overhead than you save.

b) Crudely "Project" the frustum on the grid/terrain (quick, dirty, just to get a rectangular subgrid). If you feel like it you can then still cull the chunks, but should profile if it's even making a difference. Meaning: get the world coordinates of your frustum, take the minimum and maximum x,z coords and process (or just draw) only chunks in between.

Share this post


Link to post
Share on other sites
I like the suggestion of drawing from start pixel to end. The only problem is if I texture it, will the texture be spread out if I draw the quad longer? If I repeat texture the quad, will it have any visual difference between a smaller quad and a larger one?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!