glCallList not working

Hello,

I’m working on an OpenGL program using C and I was wanting to implement a display list to make a collection of shapes, however it wasn’t displaying. I then changed this so that the display list called glutSolidCube(2) (and yes, glut.h is included) and this doesn’t work either. I was wondering if someone could hint to me what I am doing wrong?

This is my global variable

GLuint propellerDL = glGenLists(1);

This is in my init() method, which seems to work fine. It’s called only once at the start of the program.

glNewList(propellerDL, GL_COMPILE);
        //propeller();
	glPushMatrix();
	glutSolidCube(2);
	glPopMatrix();
glEndList();

This is the code in my display method, which runs every frame.

glPushMatrix();
	glRotatef(angle, 0, 0, 1);
	glCallList(propellerDL);
glPopMatrix();

This doesn’t seem to display anything, which is frustrating because both propeller(); and glutSolidCube(2); both work fine on their own, it’s just when trying to get them onto a display list that it’s failing somewhere.

If it’s relevant, I’m working on Windows 7, using Visual Studio 2008.

Thanks very much for any advice

Are you calling glFlush() or glFinish() at some point? Rendering commands don’t actually have to be executed until one of these is called.

I’m using glutSwapBuffers() at the end of display, which is set up correctly. It’s definitely drawing each frame as I can add animations such as a moving ground texture and such, however anything in the list doesn’t seem to do anything.

Check the value of propellerDL, check the value returned by glGetError(). Are you sure your init() function is called once you have valid OpenGL context on the calling thread?

Have you tried first to render these shapes without using display lists? If it does not work either, something might be wrong in your camera/projection setup.

everything works when the list code is commented out. If I call propeller() it renders a propeller which can rotate every frame, however when I put propeller() inside the list code it does nothing. I can also render other moving objects outside the list code, just not what’s in there

A problem I’ve run into -> Make sure you are not defining your lists BEFORE OpenGL is fully initialized. I find the safest way to go is to define my lists on the first pass through the draw function (only that one time of course). They usually will not show up if I define them before that. Good luck.

Thanks for the support guys, but unfortunately I’ve not got it figured out and the deadline is looming closer :slight_smile:

I think I’ve placed the list definition in a good place, right at the end of init() which is run before display()'s first call. I tried shifting it round, creating a separate method and calling it only once the first time display was run, but unfortunately it had no effect.

At the end of the day it’s not the end of the world if I don’t get it working as calling propeller() does exactly the same, however it’s just annoying me that it’s not working when, as far as I can see everything seems to be in the right place. Using it will give me bonus points but I might just leave it in and comment it out, saying that it didn’t work as I intended it to.

Any chance anyone has any other ideas?

Aha! Gotit!

Maybe it was caused by what you meant, but I misunderstood you the first time MaxH

If anyone is interested for future notice it didn’t seem to like the line

GLuint propellerDL = glGenLists(1);

however when I changed this to:

GLuint propellerDL;

and firing

propellerDK = glGenLists(1);

just before calling glNewList() it seems to like it a lot better.

Very strange error, but thank you to everyone who helped me try different things and helping me solve the problem.