Jump to content

  • Log In with Google      Sign In   
  • Create Account

Display list performance


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 wellcosh   Members   -  Reputation: 137

Like
0Likes
Like

Posted 13 June 2011 - 03:43 AM

Hi,

I am creating a simple 3D game, but I found a problem:

When I place 30 trees of ~1000 triangles (1 tree = 2 display lists (branches + trunk)), FPS are already below 50 - which is pretty bad :(

So, my question is:

Are display lists just a bad technique, or I am doing something wrong? Should I use VBOs instead?

Thanks for answers.



Sponsor:

#2 Danny02   Members   -  Reputation: 275

Like
1Likes
Like

Posted 13 June 2011 - 05:59 AM

1. nowadays u should use VBO, because display lists are deprecated
2. your problem in this case is that u have so many draw calls and probably drawing always the trunk and branches of each tree instead of first only the trunks and then the branches,
try to render all trees in 1 display list

#3 Aks9   Members   -  Reputation: 913

Like
1Likes
Like

Posted 13 June 2011 - 08:27 AM

60 display lists is not a great number of calls to have any problem in drawing. I handled several thousands of calls per frame.

You are probably doing something wrong. Can you post your drawing code? Are you using only glCallList() for drawing?

If you are creating your lists in a draw call, that's the reason for a significant performance drop.



#4 wellcosh   Members   -  Reputation: 137

Like
0Likes
Like

Posted 13 June 2011 - 11:28 AM

I'm using Lib3ds to load 3ds models.

Here is how it creates display list for mesh.

glNewList(mesh->user.d, GL_COMPILE);
          Lib3dsVector *normalL=(Lib3dsVector *)malloc(3*sizeof(Lib3dsVector)*mesh->faces);
          Lib3dsMaterial *oldmat = (Lib3dsMaterial *)-1;
         Lib3dsMatrix M;
         lib3ds_matrix_copy(M, mesh->matrix);
         lib3ds_matrix_inv(M);
         glMultMatrixf(&M[0][0]);

	  	lib3ds_mesh_calculate_normals(mesh, normalL);

	  	glBegin(GL_TRIANGLES);
	  	for (int j=0; j<mesh->faces; ++j) 
	  	{
		  	Lib3dsFace *f=&mesh->faceL[j];
		  	
		  	Lib3dsMaterial *mat=0;
		  	int tex_mode = 0;
		  	if (f->material[0])  mat=lib3ds_file_material_by_name(file, f->material);

		  	if( mat != oldmat ) 
		  	{
			  	if (mat) 
			  	{
				  	if (mat->two_sided) glDisable(GL_CULL_FACE); else glEnable(GL_CULL_FACE);
				  	if (mat->use_wire ) glEnable(GL_ALPHA_TEST); else glDisable(GL_ALPHA_TEST);
			  	}
			  	oldmat = mat;
		  	}

		  	int i;
		  	if (f->user.i>0) 
 	  	{
glActiveTextureARB(GL_TEXTURE0_ARB);
			  	glEnable(GL_TEXTURE_2D);
			  	glBindTexture(GL_TEXTURE_2D,f->user.i);
		  	}

		  	glNormal3fv(f->normal);
		  	for (i=0; i<3; ++i) 
		  	{
			  	glNormal3fv(normalL[3*j+i]);
			  	float scale=1;
			  	if (mesh->texels>0)
{
 			  	glMultiTexCoord2fARB(GL_TEXTURE0_ARB,mesh->texelL[f->points[i]][0]*scale,  mesh->texelL[f->points[i]][1]*scale); 
			  	}
			  	glVertex3fv(mesh->pointL[f->points[i]].pos);
		  	}


	  	}
	  	glEnd();
	  	free(normalL);
	  	glEndList();


#5 Aks9   Members   -  Reputation: 913

Like
1Likes
Like

Posted 13 June 2011 - 12:14 PM

1. move all loading code out of the display list setting (it shouldn't make trouble, but I don't know what is called inside all those functions)

2. also move out texture related functions except texture coordinate setting. (why are you using glActiveTextureARB() if only GL_TEXTURE0 is used? Also glEnable(GL_TEXTURE_2D) is superfluous here.)

Try to enclose only loop and glNormal/glTexCoord/glVertex function calls inside glNewList/glEndList. What version of OpenGL are you using? Why there is aways ARB suffix? All those functions are in core since GL 1.3 or so.



#6 wellcosh   Members   -  Reputation: 137

Like
0Likes
Like

Posted 13 June 2011 - 12:58 PM

1. move all loading code out of the display list setting (it shouldn't make trouble, but I don't know what is called inside all those functions)

2. also move out texture related functions except texture coordinate setting. (why are you using glActiveTextureARB() if only GL_TEXTURE0 is used? Also glEnable(GL_TEXTURE_2D) is superfluous here.)

Try to enclose only loop and glNormal/glTexCoord/glVertex function calls inside glNewList/glEndList. What version of OpenGL are you using? Why there is aways ARB suffix? All those functions are in core since GL 1.3 or so.


OMG!! I moved glBindTexture outside list and FPS increased from 50 to 500 :D :D


Thank you for advice. Too bad I can't give you more than one +rep.

#7 Aks9   Members   -  Reputation: 913

Like
0Likes
Like

Posted 13 June 2011 - 01:09 PM

I'm glad I could help. The reputation is not important. :cool:




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS