DIsplay Lists Question

It has been a while since I have worked with display lists so sorry if this is a simple question.

I have a 2-dimensional plot that is drawn in OpenGL. I have about 5000-10000 different data points that are on the plot. At each point I need to draw a symbol based on a user preference. One plot could have 5000-10000, 8 pixels by 8 pixels squares on the plot to represent the data points. My question is: would it be better to store this 8x8 rectangle inside a display list and call the display list 5000-10000 times or recall glRectd 5000-10000 times.

If it is better to use the display lists (which I think it is), what do I need to do to draw these boxes in their correct places? Do I need to do a translate before calling the display list each time?

Hopefully this seems like an easy question, I can not just wrap my mind around it today. Maybe a healthy dose of caffeine will help me out :smiley: but I am at a loss. Thanks for your help!

NAh, no displaylists needed here, use something like this.

  1. Make one or more 8x8 textures (for the data points)
  2. store the positions as single vertics in a VBO.
  3. use the pointsprite extension and set the point size to 8
  4. render the VBO as points with the texture above bound.

Are there any good examples of this for a Linux/Solaris environment and not a Windows environment? I love NeHe but it is all Windows based and unfortunately I have little knowledge on doing textures and VBOs. Thanks!

If you jump ahead to lesson 24 you will learn TGA loading which is platform independent unlike lesson06.

But if we are just talking about an 8x8 texture we need not worry about loading files, just make an array of 192 bytes and load form that array.
You don’t have to use VBO, you can use regular old glVertex3f, but with a VBO things will render a lot faster (VBO is NeHe lesson45 BTW).

(Hopefully the first of the new lessons will be out in a month or two and those are platform independent)

Yes, check out SDL at libsdl.org

Also if you do want to use a display it is pretty easy:

GLuint displayListID = glGenLists(1); //request a ID for a new list
glNewList(displayListID, GL_COMPILE); //start the list

glBegin(GL_QUADS); //add info for vertex and texture coords
	glTexCoord2f( 0.0f, 1.0f ); 
	glVertex3f( -0.5f,  -0.5f, 0.0f);
	glTexCoord2f( 1.0f, 1.0f ); 
	glVertex3f(  0.5f,  -0.5f, 0.0f);
	glTexCoord2f( 1.0f, 0.0f );
	glVertex3f( 0.5f, 0.5f, 0.0f);
	glTexCoord2f( 0.0f, 0.0f );
	glVertex3f( -0.5f, 0.5f, 0.0f);
glEnd();

glEndList();

Then to draw the list simply translate, scale etc, then call glCallList(displayListID);

Zeoverlord, how did you come up with an array of size 192 bytes?

Also, how can I use a texture if I don’t have an image to texture map with? I have worked with texture mapping a little bit, but it was always loading an image on top of my drawing. For this, I need to be able to change the color of boxes for each group to distinguish between the two and do not understand how a texture will help, especially since I have no texture to put onto it. I will look at those examples in NeHe but thanks again for your help!

192 = 8 x 8 x 3

for RGB 8x8 texture.

Well textures will help you make it look better, it can help you distinguish between the two in other ways, but if you realy only need a single solid color quad then just ignore texturing and pointsprites, just do something like this.

float points[numPoints][3]; // store the point's here, or use whatever storage system you have

glPointSize(8);
glBegin(GL_POINTS);
int i=0;
while(i<numPoints)
{
glColor3f(1,1,1); // or whatever color you want
glVertex3fv(points[i]);
i++;
}
glEnd();

As you can see, for every problem there is about 50 solutions for it.
Either you go really fast and/or great looking or you do it the simple way, it’s up to you.