Archived

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

desertcube

When to use display lists

Recommended Posts

desertcube    514
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 this post


Link to post
Share on other sites
Aeotaph    122
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 this post


Link to post
Share on other sites
python_regious    929
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 this post


Link to post
Share on other sites
llvllatrix    340
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 this post


Link to post
Share on other sites
GamerSg    378
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 this post


Link to post
Share on other sites
desertcube    514
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();
}


thanks for the reply

btw, the screens set up in ortho mode

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

Share this post


Link to post
Share on other sites
aleks_1661    188
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 this post


Link to post
Share on other sites
Aeotaph    122
I have no problem with showing you the code, but I''ll warn you, it''s in Delphi, and not very neat Delphi ^_^;
(Sorry about the slow reply, I didn''t realise I had to enable watching specifically once I''d posted to a thread...)
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();
glBegin(GL_QUADS);
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);
glLoadIdentity();
glTranslatef(0.0,0.0,-37.5);
glCallList(sphere);

Thanks for the help...

--
Mercy

Share this post


Link to post
Share on other sites
Mike737    122
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 this post


Link to post
Share on other sites
clum    217
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 this post


Link to post
Share on other sites
desertcube    514
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 this post


Link to post
Share on other sites
Mike737    122
quote:
Original post by desertcube
I have a radeon 9500....


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 this post


Link to post
Share on other sites
desertcube    514
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 this post


Link to post
Share on other sites
Mike737    122
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

Share this post


Link to post
Share on other sites