Massive Slowdown Using Display Lists...(begging for help)
ok, i''m working on a game, it''s my first using c++ and openGL, i used to use dx8 and vb but they were really to slow for games...
but now i have found a massive speed problem, i know somthing is massively wrong with the code i''ve written.
here is the drawing code...if i remove the calllist part the frame rate zooms to 200... with drawing only one actor the rate drops to 30, and all 8 drops to 3...
void DrawActors() //used to place 8 actor objects in level(for speed testing)
{
int i;
for (i = 1; i <= 8; i++) //loop though 8
{
if (i != Local_PlayerNum) //don''t display player
{
glPushMatrix();
glTranslated(cos(i*0.7853f),0,sin(i*0.7853f)); //arange them in a circle
glRotated(i*-45,0,1,0);
glCallList(draw_player);
glPopMatrix();
}
}
}
the thing is that there isn''t really anything to the display list
here is my custom format data for the stand in actors
(note, i tryed a single triangle with 3points and got the same speed hit)
sqr start //starts squarepoly list
col .1 .1 .1 1 //sets color dark grey
pnt .25 0 .25 0 0 //1
pnt .25 0 -.25 0 0
pnt -.25 0 -.25 0 0
pnt -.25 0 .25 0 0
pnt .25 1 .25 0 0 //2
pnt .25 1 -.25 0 0
pnt -.25 1 -.25 0 0
pnt -.25 1 .25 0 0
pnt .25 1 .25 0 0 //3
pnt .25 1 -.25 0 0
pnt .25 0 -.25 0 0
pnt .25 0 .25 0 0
pnt -.25 1 .25 0 0 //4
pnt -.25 1 -.25 0 0
pnt -.25 0 -.25 0 0
pnt -.25 0 .25 0 0
pnt .25 1 .25 0 0 //5
pnt -.25 1 .25 0 0
pnt -.25 0 .25 0 0
pnt .25 0 .25 0 0
pnt .25 1 -.25 0 0 //6
pnt -.25 1 -.25 0 0
pnt -.25 0 -.25 0 0
pnt .25 0 -.25 0 0
sqr end
finaly here is my code to load the displaylist actor from the file
GLuint DisplayListLoad2(char *load_file)
{
FILE *filein;
GLuint object;
char oneline[255];
float x;
float y;
float z;
float u;
float v;
float r;
float g;
float b;
float a;
filein = fopen(load_file, "rt");
object=glGenLists(1);
glNewList(object,GL_COMPILE);
for (int i = 1; i <= 3000; i++)
{
fgets(oneline, 255, filein);
if ((oneline[0] == ''p'') & (oneline[1] == ''n'') & (oneline[2] == ''t''))
{
sscanf(oneline, "pnt %f %f %f %f %f", &x, &y, &z, &u, &v);
//glTexCoord2f(u, v);
glTexCoord2f(x/2, z/2);
glVertex3f( x, y, z);
}
if ((oneline[0] == ''c'') & (oneline[1] == ''o'') & (oneline[2] == ''l''))
{
sscanf(oneline, "col %f %f %f %f", &r, &g, &b, &a);
if ((r == 1) && (b == 1) && (g == 1))
{
//glEnable(GL_TEXTURE_2D);
glColor4f(1,1,1,a);
}
else
{
//glDisable(GL_TEXTURE_2D);
glColor4f(r,g,b,a);
}
}
if ((oneline[0] == ''s'') & (oneline[1] == ''q'') & (oneline[2] == ''r''))
{
if ((oneline[4] == ''s'') & (oneline[5] == ''t'') & (oneline[6] == ''a''))
{
glBegin(GL_QUADS);
}
if ((oneline[4] == ''e'') & (oneline[5] == ''n'') & (oneline[6] == ''d''))
{
glEnd();
}
}
if ((oneline[0] == ''t'') & (oneline[1] == ''r'') & (oneline[2] == ''i''))
{
if ((oneline[4] == ''s'') & (oneline[5] == ''t'') & (oneline[6] == ''a''))
{
glBegin(GL_TRIANGLES);
}
if ((oneline[4] == ''e'') & (oneline[5] == ''n'') & (oneline[6] == ''d''))
{
glEnd();
}
}
}
glEndList();
fclose(filein);
return object;
}
does anyone see anything that stands out as somthing i''m doing horribly wrong, at 98% speed hit just doesn''t seem to fit what i''m doing...
The code seems right. Are you sure you are getting an hardware-accelerated pixel format ? What happens if you use immediate mode instead of display lists ?
Y.
Y.
i just relised that i would be possible that i was reading from the file every single frame, eight times...please tell me this wasnt happening...
i just thought about the nature of display lists and relised that i don''t know if they capture every command or just ones sent to OGL...i created an object manualy within my program and the speed hit disapared...but i''m not really sure of anything thats going on so could someone tell me whats really happening...
i just thought about the nature of display lists and relised that i don''t know if they capture every command or just ones sent to OGL...i created an object manualy within my program and the speed hit disapared...but i''m not really sure of anything thats going on so could someone tell me whats really happening...
quote:
Original post by duckbob
i just relised that i would be possible that i was reading from the file every single frame, eight times...please tell me this wasnt happening...
I don''t think that''s what is happening. Here''s something I copied from the GL 1.3 specification...
After calling NewList all subsequent GL commands are placed in the display list (in the order the commands are issued) until a call to void EndList( void ); occurs, after which the GL returns to its normal command execution state. (193)
It seems that ONLY GL commands are placed into the list, not regular commands. However, it might be best to take your reading code outside of the glNew/EndList() calls and do as few commands as possible in there...
~ Dragonus

August 16, 2001 10:32 AM
I couldn''t really see from you code but you problem could be that you call glTexImage2D(...) inside your display list. Eventhough display lists should remember this command in an effective way it doesn''t (at least on mesa3d and nvidias linuxdriver - which is where I experienced this problem)
If this is the course of your problem then try using texture objects instead (glGenTextures(...) and glBindTexture(...))
Hope this helps
Carsten Kjaer
If this is the course of your problem then try using texture objects instead (glGenTextures(...) and glBindTexture(...))
Hope this helps
Carsten Kjaer
i didn''t call glTexImage2D...
i am using texture objects...but the textures are set up outside the display lists and most of the objects i''m drawing don''t even use textures, i disable them while the objects draw...
i am using texture objects...but the textures are set up outside the display lists and most of the objects i''m drawing don''t even use textures, i disable them while the objects draw...
August 16, 2001 06:48 PM
Why arent you using Vertex Arrays?
If you dont know what they are, get the Redbook and read about em. Also some of you people need to read the friggen opengl spec. go download it.
If you dont know what they are, get the Redbook and read about em. Also some of you people need to read the friggen opengl spec. go download it.
Maybe getting this document and reading it would help?!
http://partners.nvidia.com/Marketing/Developer/DevRel.nsf/045cfdb95e306a4d882568170059fa93/90eef4a5cef8d6c588256a180066d598/$FILE/GDC01_Performance.pdf
-OR this way-
1. http://partners.nvidia.com/Marketing/Developer/DevRel.nsf
2. GO TO "Presentations"
3. Select "GDC 2001 -- OpenGL Performance"
4. Get the .PDF
http://partners.nvidia.com/Marketing/Developer/DevRel.nsf/045cfdb95e306a4d882568170059fa93/90eef4a5cef8d6c588256a180066d598/$FILE/GDC01_Performance.pdf
-OR this way-
1. http://partners.nvidia.com/Marketing/Developer/DevRel.nsf
2. GO TO "Presentations"
3. Select "GDC 2001 -- OpenGL Performance"
4. Get the .PDF
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement