Advertisement

List problems

Started by July 01, 2004 08:34 PM
5 comments, last by kburkhart84 20 years, 5 months ago
I am having two problems with using gl display lists with my quad class. 1 - Duplicate display list name Initially, I put the glGenLists function call in my constructor like so:
m_dList = glGenLists(1);
This seemed to work fine until I tried to add a second quad. For some reason, glGenLists is returning the same list name for the second quad as it is for the first (97, because I generate a bitmap font before making the quads, which uses 96 lists). I also tried passing it to the quad constructor through my quad manager, as well as passing glGenLists(1) directly to the constructor through the newQuad function in the manager:
Quad* monkey = test.newQuad(	glGenLists(1), Size2D(0.6f, 0.6f), Float3(-1.0f, 0.0f, -5.0f), 
									GLI.createTexture("3HM1.png"));
with the same results. Currently, I finally managed to get different lists for each quad by creating external UINTs, initializing them to glGenLists(1), and then passing them to the newQuad function like so:
	UINT a = glGenLists(1);
	UINT b = glGenLists(1);
	Quad* monkey = test.newQuad(	a, Size2D(0.6f, 0.6f), Float3(-1.0f, 0.0f, -5.0f), 
									GLI.createTexture("3HM1.png"));
	Quad* ship = test.newQuad(	b, Size2D(0.3f, 0.3f), Float3(1.0f, 0.0f, -5.0f), 
								GLI.createTexture("Emerald.png"));
All this external code seems unnecessary, as it would be much nicer to have the quad simply generate its own list name internally. It also seems like it should work, as glGenLists is supposed to generate a new list. Is there anything that causes glGenLists to return an already generated list? Is there any way to fix this problem? 2 - Double compile The other problem I am having is that after creating the quad above, they do not render until I re-compile the list using the quads setSize function:
ship->setSize(Size2D(F, F));
monkey->setSize(Size2D(2*F, 2*F));
even though the exact same thing is done in the quad constructor, which calls the same function and passes it the quads size. Stepping through the code with the debugger indicates that the function is getting the exact same values each time, but for some reason it isn't working. When I don't externally re-size the quad, I get a blank screen. When I do, I it displays the quads properly, even though I am resizing the quads to their initial size. Any ideas?
Why don't you check out Nehe's tutorial that involves display lists, I think it will solve some of your difficulties. HERE it is.
Advertisement
Why don't you check out Nehe's tutorial that involves display lists, I think it will solve some of your difficulties. HERE it is.
Whatsoever you do, do it heartily as to the Lord, and not unto men.
I have already read that lesson (I am not sure why you associate lesson 21 with display lists, it is more geared towards setting an orthogonal viewport, doing lines, etc. The only list code I could find on a quick glance appeared to be font lists, which is covered in lessons 13-15. Furthermore, lesson 12 is actually the list lesson. ;)) as well as the font lessons and the list lesson (12), and have based my code on them. However, in all of these lessons, Nehe only generates a bunch of lists once, while I need to generate lists on the fly as each element is created.
I`d recommend generating list IDs when you build the list, not just generate a bunch of ID-s and afterwards build them... I don`t know exactly but OpenGL could just ignore empty lists, I mean it would totally make sense for me :)

Relative Games - My apps

Right, which is why I'm trying to do precisely that.
If I was unclear, I am sorry. However, what I am trying to do is build a quad class, that whenever it is constructed, creates a new list using glGenLists(1), and then immediately compiles the list. :)
Advertisement
You are going to build a class just for quads. If you make a displaylist for each quad, I don't think you will get much difference speed wise. Display Lists are for complete objects that have lots of polygons.


This topic is closed to new replies.

Advertisement