Performance

Started by
5 comments, last by AdamGL 18 years, 5 months ago
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)?
bi-FreeSoftware
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.
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).
bi-FreeSoftware
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.
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.
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
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.
f@dzhttp://festini.device-zero.de
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?
bi-FreeSoftware

This topic is closed to new replies.

Advertisement