🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

glCallList....

Started by
8 comments, last by V-man 15 years, 7 months ago
I'm having a very annoying problem with glCallList...recently I had changed some code that was working, and I removed some that I assumed had nothing to do with the draw function in my program -_- Anyway, I know for a fact that the code section that builds the lists is run and it works, however when I call the list nothing shows up. glColor4f(1+bmod,0+bmod,0+bmod,.99); glCallList(ruby); In the same section, I replaced the above code with the code below, just to see if maybe the program was skipping this section. But a red square showed up like it should've. glColor3f(1,0,0); glBegin(GL_QUADS); glNormal3f(0,0,1); glVertex3f(.5,.5,0); glVertex3f(-.5,.5,0); glVertex3f(-.5,-.5,0); glVertex3f(.5,-.5,0); glEnd(); Is there some sort of command to turn callists on or off and I somehow turned it off or what? This is driving me nuts O_o there's no reason for it not to work. If you want I can include the function that builds the list but it's big and I'm pretty sure it works...
Advertisement
Display lists are pretty much a macro that records commands and parameters, and calling it is equivalent to copy-pasting the code to build the list instead of calling it.

Now, if copy-pasting works but not calling the list, then check for errors when calling it. Could be something wrong with the list itself. Also, check the place you call it and make sure the rendering context is active.
Just a suggestion, that is obsolete, consider VBO for instance.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Okay, copy pasting it works, so the problem is with calling it then...like I said before it should work and was working. I'm kind of a newbie still, what do you mean by "making sure the rendering context is active"? I'll go through it again but I think the list is set up correctly. Thanks for all the help!
The rendering context is the basically what you create when you create the window. If you haven't created a window, you don't have the rendering context, and you cannot do anything with OpenGL. For example, GLUT creates the rendering context when you call glutCreateWindow, an in Win32 you do it with wglCreateContext. Don't do anything with OpenGL before that.
Well the rendering context is active, or I wouldn't be able to do jack, right? I had used "hRC=wglCreateContext(hDC)" to get the handle to the rendering context and a few lines later "wglMakeCurrent(hDC,hRC)" to activate it. If it hadn't activated it should've returned false and I'd know about it since it would give me a message box. This is probably going to turn out to be some stupid little thing that came from removing one particular line of code u_u Is it relevant that the glCallList command is in an implementation file instead of the main program file(where the openGL window was set up)? It hadn't been a problem before so I don't see why it should be now. Thanks again for all the help, and I hope these posts aren't too long winded...
If the rendering context isn't active, then you can't do anything, that's correct. But nothing in your description so far rules out that is isn't active. You can draw it fine, but you cannot build it, and that is expected when yuo try to build it before the rendering context is created.
Oooook finally got it fixed, thanks to Brother Bob. Turned out what was happening was, I had a function that built the lists in the constructor of the class I was using. Since I declared the instance of that class at the top of the program, it was trying to build the lists first thing I guess. I just made a function that built lists/loaded textures, and called it at the beginning of the main loop after the window was already set up, and everything seems to work fine. One last little question, is there any harm in rebuilding the same lists over and over? Do I need to de-allocate memory and then rebuild? Thanks again for reading.

P.S. I looked over the VBO stuff, riruilo. I admit I'm intrigued but I don't really need it for this, normal lists should work fine...as long as I pay attention to what's really going on u_u
Display lists are static, and to chage them you need to rebuild them completely. Vertex arrays, especially when using VBO, are superior to display lists on almost every point, and add to that that display lists will be removed from OpenGL in future versions (it's already marked as deprecated functionality in 3.0).
Quote: Original post by Xavien
Oooook finally got it fixed, thanks to Brother Bob. Turned out what was happening was, I had a function that built the lists in the constructor of the class I was using. Since I declared the instance of that class at the top of the program, it was trying to build the lists first thing I guess. I just made a function that built lists/loaded textures, and called it at the beginning of the main loop after the window was already set up, and everything seems to work fine. One last little question, is there any harm in rebuilding the same lists over and over? Do I need to de-allocate memory and then rebuild? Thanks again for reading.

P.S. I looked over the VBO stuff, riruilo. I admit I'm intrigued but I don't really need it for this, normal lists should work fine...as long as I pay attention to what's really going on u_u


http://www.opengl.org/wiki/index.php/Common_Mistakes#The_Object_Oriented_Language_Problem
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement