#### Archived

This topic is now archived and is closed to further replies.

# When to use display lists

This topic is 5303 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

OK, I thought display lists speed up things, but I''m drawing a series of boxes(a window border for fullscreen) and decided to put it in a display list. I know the speed difference isn''t really anything, it takes 16 ticks in a display list compared to 12 when simply drawn each time, but I was wondering when would i use a display list? btw, the ticks are from using the performance timer so i guess they''re accurate.

##### Share on other sites
I''ve had this problem too; as it stands part of my code constructs a spinning wireframe sphere, drawing anywhere from 400 to 3200 polygons depending on the complexity setting selected. When the sphere is drawn directly, the motion is smooth and clear. However, when I put it into a display list, the motion is very jerky and the lines are also themselves less clear and kind of "fuzzy". So same question?

--
Mercy

##### Share on other sites
quote:
Original post by Aeotaph
I''ve had this problem too; as it stands part of my code constructs a spinning wireframe sphere, drawing anywhere from 400 to 3200 polygons depending on the complexity setting selected. When the sphere is drawn directly, the motion is smooth and clear. However, when I put it into a display list, the motion is very jerky and the lines are also themselves less clear and kind of "fuzzy". So same question?

--
Mercy

You have line antialiasing enabled in your display list, but not your other code?

Death of one is a tragedy, death of a million is just a statistic.

##### Share on other sites
As far as i know there are two advantages (my only source being the red book).

The first is that you dont have to resend all the drawing function calls that you would normally use to redraw an object. Its just one function and the thing is done.

The second, athough im not completely sure of this one but, when you generate a display list, OGL takes the time to select device compatible or accelerated parameters so that what your drawing runs as fast as it possibly can on hardware.

##### Share on other sites
Obviously u are doing something wrong.

Some possible errors

1)You should only Compile the display list at load time or once in ur application using GL_COMPILE

WHen u need to use it, you should use glCallList.

2)It would help if you showed some code.

3)For objects with very low poly counts like 12 polygon cubes, you should render directly as there is some overhead in calling display lists.

##### Share on other sites
I am sure i'm doing it right, but am useing less then 12 quads, only creating 4 but i'm changing the color a lot, here's the part where i draw:

#define FIRST_COLOR glColor3d(0.8, 0.8, 0.96)#define SECOND_COLOR glColor3d(0.4, 0.4, 0.5)void DrawWindow(){	int borderWidth = 5;	int titleHeight = 25;	int screenHeight = 600;	int screenWidth = 800;	glBegin(GL_QUADS);	FIRST_COLOR; //Title bar	glVertex2i(0, titleHeight);	glVertex2i(screenWidth, titleHeight);	SECOND_COLOR;	glVertex2i(screenWidth, 0);	glVertex2i(0, 0);	glColor3f(1, 1, 1); //Show place of the icon	glVertex2i(720, 2);	glVertex2i(720, 22);	glVertex2i(740, 22);	glVertex2i(740, 2);	FIRST_COLOR; //Left border	glVertex2i(0, titleHeight);	glVertex2i(0, screenHeight);	SECOND_COLOR;	glVertex2i(borderWidth, screenHeight - borderWidth);	glVertex2i(borderWidth, titleHeight);	FIRST_COLOR; //Bottom border	glVertex2i(0, screenHeight);	glVertex2i(screenWidth, screenHeight);	SECOND_COLOR;	glVertex2i(screenWidth - borderWidth, screenHeight - borderWidth);	glVertex2i(borderWidth, screenHeight - borderWidth);	FIRST_COLOR; //Right border	glVertex2i(screenWidth, screenHeight);	glVertex2i(screenWidth, titleHeight);	SECOND_COLOR;	glVertex2i(screenWidth - borderWidth, titleHeight);	glVertex2i(screenWidth - borderWidth, screenHeight - borderWidth);	glEnd();}

btw, the screens set up in ortho mode

[edited by - desertcube on August 10, 2003 6:07:07 AM]

##### Share on other sites
There is nothing wrong with your code, as the guy said above, calling a display list for really simple geometry brings with it extra overheads. for example if i wanted to draw a STATIC stack of 100 cubes, instead of making a display list for a single cube and rendering loads, i would make a display list containing all 100 cubes.

as for your sphere, make sure you are only compiling the list once, not every frame, ive seen a number of people do that.

show yor code, we might see problems you dont.

"Very funny, Scotty. Now beam down my clothes."

##### Share on other sites
no, i think you mis-understood me. I''m not having problems with my code, i just thought it was odd that it was slower.

##### Share on other sites
I have no problem with showing you the code, but I''ll warn you, it''s in Delphi, and not very neat Delphi ^_^;
As far as the comment about line anti-aliasing goes, that would make a lot of sense actually, but I have no idea how to enable or disable anti-aliasing? Still a n00b I fear...

This first bit is done as part of program initialisation, in the background while displaying the splash screen. I''ve omitted the math that actually fills st and sq with the vertices of the sphere''s constituent triangles and quads.

sphere := glGenLists(1);
glNewList(sphere,GL_COMPILE);
glPolygonMode( GL_BACK, GL_line ); // Make the sphere a wireframe
glPolygonMode( GL_FRONT, GL_line );
glColor3f(0.0,1.0,0.0); // All lime green
glBegin(GL_TRIANGLES);
for I := 1 to (2*b) do
begin
glVertex3f(st[I,1,1] , st[I,1,2] , st[I,1,3]);
glVertex3f(st[I,2,1] , st[I,2,2] , st[I,2,3]);
glVertex3f(st[I,3,1] , st[I,3,2] , st[I,3,3]);
end;
glEnd();
for I := 1 to (ni-1) do
begin
for J := 1 to b do
begin
glVertex3f(sq[I,J,1,1] , sq[I,J,1,2] , sq[I,J,1,3]);
glVertex3f(sq[I,J,2,1] , sq[I,J,2,2] , sq[I,J,2,3]);
glVertex3f(sq[I,J,3,1] , sq[I,J,3,2] , sq[I,J,3,3]);
glVertex3f(sq[I,J,4,1] , sq[I,J,4,2] , sq[I,J,4,3]);
end;
end;
glEnd;
glEndList;

[Subsequently during DrawGLScene:]

glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glTranslatef(0.0,0.0,-37.5);
glCallList(sphere);

Thanks for the help...

--
Mercy

##### Share on other sites
To use anti-aliasing use the code:

glEnable(GL_LINE_SMOOTH); //turns anti-aliasing on
glDisable(GL_LINE_SMOOTH); //turns anti-aliasing off

I can''t see any reason why your display list would decrease perfomance with your code. I''m not so familar with delphi, but try compiling the code to a release/optimized mode instead of debug, that will speed up performance in general and possibly your display lists

##### Share on other sites
What video card do you have? I don''t think all video cards take advantage of display lists, which I suppose could slow it down.

##### Share on other sites
I have a radeon 9500 with catalyst3.6. Does it vary with different drivers as I ahve noticed switching screens using the NeHe bascode has become very slow with the new release.

##### Share on other sites
quote:
Original post by desertcube

You should be using DirectX 9.0 for your rendering with your card, you would get a lot better performance out of it than OpenGL.

But then again if you are going to release the software out to the rest of the world... (mutters off to himself)

Extracting Patch....
Initializing Windows XP Update Path 2543663B....
Core Dumped, Now Installing Linux.....

----
Mike
Team AI: Http://members.iinet.net.au/~slyons/teamai

##### Share on other sites
I have directX 9.0b installed, but I find some games prepher OpenGL. The main game I play is Counter-Strike(based on HalfLife) and I find I get higher fps then in DirectX, maybe half life was optimized for OpenGL?

##### Share on other sites
quote:
Original post by desertcube
I have directX 9.0b installed, but I find some games prepher OpenGL. The main game I play is Counter-Strike(based on HalfLife) and I find I get higher fps then in DirectX, maybe half life was optimized for OpenGL?

HalfLife uses DirectX 6 or 7 I think... OpenGL compared to DX < 8.1 is a lot faster... from there on DX was about equal until now. I actually find DX9 rendering run faster than OpenGL as DX9 is really well optimized and programmed now. And I am even using a NVidia card and getting those results.

Extracting Patch....
Initializing Windows XP Update Path 2543663B....
Core Dumped, Now Installing Linux.....

----
Mike
Team AI: Http://members.iinet.net.au/~slyons/teamai