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?