Writing 6000 cubes on screen...

Hi ppl. I was programming effect for my demo (flying trough field of cubes which was used first in 3d mark 99) and it was veeeryy slow (of course, i redrawed all cubes every frame). Pls, could u help me. Explain me philosophy, how to program this effect optimally. Thanks.

Don’t use immediate mode rendering (glVertex/glColor and those commands). Use display lists and/or vertex arrays. Per object frustum culling might boost your performance a bit.

Originally posted by Bob:
Don’t use immediate mode rendering (glVertex/glColor and those commands). Use display lists and/or vertex arrays. Per object frustum culling might boost your performance a bit.

Thx. Im using displists. ill check that frustrum culling :slight_smile:

hi, if you are using displaylist render all cubes into one list and not every cube in a single list…

but if you want to use frustum culling you must render your scene into vertex arrays…

you have to try which way is the fast

good luck mate

Originally posted by MofuX:
[b]hi, if you are using displaylist render all cubes into one list and not every cube in a single list…

but if you want to use frustum culling you must render your scene into vertex arrays…

you have to try which way is the fast

good luck mate[/b]

No. i have in displist 1 cube and im rendering entire field every frame and with glTranslatef im moving trough field.

Pls. could anyone gimme link, where can i find, what is frustrum culling (coz i didn`t found anything relevant).

Thanks

MofuX, you can do frustum culling with display lists. Test each cube against the frustum, and call glCallList if it’s visible. You don’t have to use veryex arrays just to do frustum culling.

How many cubes you store in one display list depends on how much precision you want in your frustum culling. If you have one cube per list, only semi- or fully visible cubes will pass the test. If you have 27 cubes (3x3x3) per list, you will test this group of boxes, and draw all of them if parts of the group is visible, resulting in cubes outside the frumstum to be drawn. In short, the more cubes you have in the list, the more “invisible” cubes you draw, but the less function calls is needed.

I suggest you put a group of about (4x4x4) cubes in one display list, test the whole group against the frustum, and draw the entire group if needed.

Search Google for frustum culling. I did, and the very first link contains more or less everything you ever need to know about frustum culling.

Be sure and render front to back