View Full Version : Displaylists and colors
04-09-2000, 08:48 AM
I was just trying out some glList stuff, and noticed it was really faster then just drawing the stuff myself.
But I just have a question about coloring the object in the list.
I build the list with glColor3f() and glVertex3f() calls and when I call glCallList() I get all the polygons I draw to get all the same colors. Logically, ofcourse.
So I tried to give the List all kinds of grey
shades, and set a glColor3f() before I call the list, with only the blue color 1, and the rest zero. But I still get a grey shaded polygon. Is there anyway to use one list, but I assign the color at a later stage?
[This message has been edited by Sjonny (edited 04-09-2000).]
04-09-2000, 09:18 AM
All glColor() function calls, are stored in the display list, and then called again when the list is being 'played'.
Make sure that you don't call glColor() while you are building the list, and then you can draw the objects in the list any color you like, by calling glColor() before you play back the display list.
The main problem with this though, is that the whole of the object must be just one colour at a time.
Hope this is what you were after. http://www.opengl.org/discussion_boards/ubb/smile.gif
display lists are just wrappers (roughly speaking) for gl commands.
if you can render colored primitives with a list, you can also do it with straight opengl.
but you surely know this... http://www.opengl.org/discussion_boards/ubb/smile.gif
the fact your object is still gray makes me think about lighting: is it turned on?
if it so, glColor() calls are discarded, unless you have enabled GL_COLOR_MATERIAL.
04-09-2000, 12:24 PM
Well, when I leave the glColor() calls out, I get flat colored polygons, and I lose the perspective in the scene too.
I never turned on the lighting, so that's not it. What I actually want is every glVertex() I put in the list should have an glColor so OpenGL blends the colors from vertex to vertex. But I guess that can't be done in a list, since the OpenGL driver remembers all data you put in the list, and doesn't retrieve the updated data in my arrays.
So glColor3f(red, green, blue); in the list stays the same, even after I change the rd green and blue values later on...
I haven't tried this, but is it still faster if I use GL_COMPILE_AND_EXECUTE in stead calling glVertex without a list?
no! don't use C&X display lists! http://www.opengl.org/discussion_boards/ubb/smile.gif
i made tests on g200, tnt and nv10 and compile and execute is very very slow.
i can't understand why your list don't render as expected...
i don't think it's the case, but remember that a complete vertex, ie a vertex wich have a position, a color, a texture coordinate, a normal and so on, is created only when you call a glVertex() class function.
i made use of display lists various times, and they render correctly everytime.
to be precise: opengl don't exactly remembers the values you pass into a glBeginList/glEndList.
it instead builds a database wich contains your commands in a way the chip you have can understand.
in short, it compiles your commands: something like the old compiled bitmaps, where a particular memory zone does not contain pixels, but CPU instructions that directly set the pixel in video ram.
this is the reason why a display list can't be modified.
all this, in theory: it all depends on the implementation.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.