speed up of display

Hey, I need help to speed up my display. I am working with displaying thousands of cubes that are filling up a larger cube. I need to keep track of each individual one, but I need a way to display them faster. Right now it takes about a quarter second to display them all. I am displaying the cubes through GL_Quads and making all the sides. I need to place each one at a specific quardinate. Is there a better way to make the cubes to make them faster? They also need to be just one solid color. Thank you much for your help. Also is there a way that I can display how long it took to do?

hi.
display list could help you.
store one centered cube in a display list and then, for each cube, push modelview matrix, translate to the right location, render display list and pop modelview matrix.
this avoid many calls to glBegin, glVertex and so, speed up application.

You should use display lists. NeHe tutorial #12 might give you some ideas : http://nehe.gamedev.net/lesson.asp?index=03

Bonus : tutorials #13 and following deal with displaying text

EDIT : added missing word

[This message has been edited by kehziah (edited 06-27-2003).]

thank you very much for your help. I did that, and can’t really tell too much of a difference. It does probably help with the speed but I can’t much tell. Is there any way that I can display the time it took to render? Thanks again

Originally posted by dlswimmer:
Is there any way that I can display the time it took to render?

Take a look at http://www.fraps.com

How about posting some code so we can see how you are drawing these cubes.

Originally posted by dlswimmer:
Hey, I need help to speed up my display. I am working with displaying thousands of cubes that are filling up a larger cube. I need to keep track of each individual one, but I need a way to display them faster. Right now it takes about a quarter second to display them all. I am displaying the cubes through GL_Quads and making all the sides. I need to place each one at a specific quardinate. Is there a better way to make the cubes to make them faster? They also need to be just one solid color. Thank you much for your help. Also is there a way that I can display how long it took to do?

that program is mainly for games, it didn’t really help with finding the time it took my program to render. Thank you anyway.

I took the advice of the earlier posters and made a list with my box, I now have the display just accessing the box every time I need one displayed. I create a bigger box using lines, then I create the many smaller boxes that fill the bigger box. Here is the code:
void CTestDlg::Render()
{

// Clear the screen.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

// I use this to move the screen over some so the triangle is in the middle of the
// screen. This is necessary in our MFC version.

glTranslatef(-6.0f,-2.0f,-20.0f);
glRotatef(30.0f,1.0f,0.0f,0.0f);
glRotatef(40.0f,0.0f,1.0f,0.0f);
glCallList(bigBox);
for (int k=0;k<96;k++)
{
for (int j=0;j<17;j++)
{
for (int i=0;i<16;i++)
{
if (x==0)
glColor3f(1.0f-i*.0625f,0.0f,i*.0625f);
else
glColor3f(i*.0625f,0.0f,1.0f-i*.0625f);
glCallList(box);
glTranslatef(0.0f,0.0625f,0.0f);
}
glTranslatef(0.0f,-1.0f,-0.25f);
}
glTranslatef(0.25f,0.0f,4.25f);
}
x=(x==0?1:0);
// Swap buffers.
SwapBuffers(hDC->GetSafeHdc());
}

What’s in the display list with id box?

I haven’T yet understood the intention behind this. It looks pretty silly to draw the same 3D space filled with cubes over and over again if the final image will only show the outside of the cubes.

The color is only dependent on i, move the i loop to the outside to do less color calls.
The continuous translate costs performance.

My 2c:
It’s faster if you generate the whole volume in a 3D grid, mark the filled cubes (all?), generate the quads which have only one neighbour, color them according to their grid position and draw the remaining quads in one single drawarrays call.

Oh, and enable backface culling.

[This message has been edited by Relic (edited 06-27-2003).]

ok, well here is the thing, right now, I am totally displaying every cube to get the feel for how long it could take. When I actually get to it, every cube will not be displayed. A data file will be read, with information. Depending on what the information is for that certain coordinate, depends on wether it will be displayed and what color. When the image is finnished, it will be kind of swiss cheesed. I am just completely filling it in right now to get a feel for display speed.

oh, and here is the info from the list boxes:
box = glGenLists(2);
glNewList(box,GL_COMPILE);
glBegin(GL_QUADS);
glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 0.0625f, 0.0f);
glVertex3f(0.0f, 0.0625f, -0.25f); glVertex3f(0.0f, 0.0f, -0.25f);

  glVertex3f(0.25f, 0.0f, 0.0f);		glVertex3f(0.25f, 0.0625f, 0.0f);
  glVertex3f(0.25f, 0.0625f, -0.25f);glVertex3f(0.25f, 0.0f, -0.25f);

  glVertex3f(0.0f, 0.0f, 0.0f);		glVertex3f(0.25f, 0.0f, 0.0f);
  glVertex3f(0.25f, 0.0625f, 0.0f);	glVertex3f(0.0f, 0.0625f, 0.0f);

  glVertex3f(0.0f, 0.0f, -0.25f);	glVertex3f(0.25f, 0.0f, -0.25f);
  glVertex3f(0.25f, 0.0625f, -0.25f);glVertex3f(0.0f, 0.0625f, -0.25f);

  glVertex3f(0.0f, 0.0625f, 0.0f);	glVertex3f(0.25f, 0.0625f, 0.0f);
  glVertex3f(0.25f, 0.0625f, -0.25f);glVertex3f(0.0f, 0.0625f, -0.25f);
  
  glVertex3f(0.0f, 0.0f, 0.0f);		glVertex3f(0.25f, 0.0f, 0.0f);
  glVertex3f(0.25f, 0.0f, -0.25f);	glVertex3f(0.0f, 0.0f, -0.25f);
glEnd();
glEndList();
bigBox = box +1;
glNewList(bigBox,GL_COMPILE);

glBegin(GL_LINES);
glColor3f(.788f,.498f,.353f);
glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f); glVertex3f(0.0f, 1.0f, -4.25f);
glVertex3f(0.0f, 1.0f, -4.25f); glVertex3f(0.0f, 0.0f, -4.25f);
glVertex3f(0.0f, 0.0f, -4.25f); glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(24.0f, 0.0f, 0.0f); glVertex3f(24.0f, 1.0f, 0.0f);
glVertex3f(24.0f, 1.0f, 0.0f); glVertex3f(24.0f, 1.0f, -4.25f);
glColor3f(.852f,.645f,.523f);
glVertex3f(24.0f, 1.0f, -4.25f); glVertex3f(24.0f, 0.0f, -4.25f);
glVertex3f(24.0f, 0.0f, -4.25f); glVertex3f(24.0f, 0.0f, 0.0f);
glColor3f(.788f,.498f,.353f);
glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(24.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f); glVertex3f(24.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 1.0f, -4.25f); glVertex3f(24.0f, 1.0f, -4.25f);
glColor3f(.852f,.645f,.523f);
glVertex3f(0.0f, 0.0f, -4.25f); glVertex3f(24.0f, 0.0f, -4.25f);
glEnd();
glEndList();