problem in implementing display list

Hi all, the following is my code abt initializing a display list (which is aimed to render a 1024x12024 terrain ) Would anyone be kind enough to tell me if there is anything wrong in the function? Since I can’t get any improvment after implementing the display list… Thx for your kindful help

void InitializeList(BYTE *pHeightMap)
{
g_terrainList = glGenLists(1);

int X = 0, Y = 0;						// Create some variables to walk the array with.
int x, y, z;							// Create some variables for readability
bool bSwitchSides = false;

if(!pHeightMap) return;					// ensure height data is valid

glNewList(g_terrainList, GL_COMPILE);

glBindTexture(GL_TEXTURE_2D, g_Texture[0]);

glBegin( GL_TRIANGLE_STRIP );			


for ( X = 0; X <= MAP_SIZE; X += STEP_SIZE )
{
	// Chechk if we need to render the opposite way for this column
	if(bSwitchSides)
	{	
		// Render a column of the terrain, for this current X.
		// We start at MAP_SIZE and render down to 0.
		for ( Y = MAP_SIZE; Y >= 0; Y -= STEP_SIZE )
		{
			// Get the (X, Y, Z) value for the bottom left vertex		
			x = X;							
			y = Height(pHeightMap, X, Y );	
			z = Y;							

			// Set the current texture coordinate and render the vertex
			SetTextureCoord( (float)x, (float)z );
			glVertex3i(x, y, z);		

			// Get the (X, Y, Z) value for the bottom right vertex		
			x = X + STEP_SIZE; 
			y = Height(pHeightMap, X + STEP_SIZE, Y ); 
			z = Y;

			// Set the current texture coordinate and render the vertex
			SetTextureCoord( (float)x, (float)z );
			glVertex3i(x, y, z);			
		}
	}
	else
	{	
		// Render a column of the terrain, for this current X.
		// We start at 0 and render down up to MAP_SIZE.
		for ( Y = 0; Y <= MAP_SIZE; Y += STEP_SIZE )
		{
			// Get the (X, Y, Z) value for the bottom right vertex		
			x = X + STEP_SIZE; 
			y = Height(pHeightMap, X + STEP_SIZE, Y ); 
			z = Y;

			// Set the current texture coordinate and render the vertex
			SetTextureCoord( (float)x, (float)z );
			glVertex3i(x, y, z);

			// Get the (X, Y, Z) value for the bottom left vertex		
			x = X;							
			y = Height(pHeightMap, X, Y );	
			z = Y;							

			// Set the current texture coordinate and render the vertex
			SetTextureCoord( (float)x, (float)z );
			glVertex3i(x, y, z);		
		}
	}

	// Switch the direction the column renders to allow the fluid tri strips
	bSwitchSides = !bSwitchSides;
}

// Stop rendering triangle strips
glEnd();
glEndList();

}

What is it you can’t improve? Performance? You should be aware than display lists are not guaranteed to improve performance. They can improve it if used properly, but there’s no guarantees.

And second, don’t expect good perfomance by drawing a 1024x1024 terrain without a good culling system. Make some rough desicions what’s visible, and just draw that. Here’s some reading, and here too.

Thx, I am going to read it. Yep, I can’t see much improvment in the performance (FPS) after implementating the display list or the vertex array…

Originally posted by wow:
Thx, I am going to read it. Yep, I can’t see much improvment in the performance (FPS) after implementating the display list or the vertex array…

It depends on your video card. I think the ones with display lists that work well are nvidia and Intel while ATI can slow down slightly and Matrox and 3Dlabs can sometimes render incorrectly. I assume XGI and S3 are in the later group.

Display lists would only help if you are vertex throughput limited.

Three things to try:

  • Do not use glVertex3i but glVertex3f.
    Most (all?) hardware uses floats internally and these are the more optimized paths in general.
  • Do no overoptimize triangle strip length too much. You put everything in one strip.
    It’s sometimes better to keep the number of vertices per primitive below some threshold, of which 2^16 is the famoust.
  • Instead of generating long strips along one axis, try to keep things in local patches, like a quadtree depth traversal would do. This helps implementations to reuse vertices or cull faster.