Jump to content
  • Advertisement
Sign in to follow this  
CyberSlag5k

Problem with glGenLists()

This topic is 4684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What are some reasons for why glGenLists would return 0? I am building an application that creates a model image file and displays the model. Right now everything works properly if I just create the file. The glGenLists returns a display list ID of 2 (which makes sense as there's a display list created before it), and everything draws properly. But when I have the program start up reading from the file I create, glGenLists returns zero and the display list isn't created (glIsList returns false). What is odd is that up until that point, none of the actual data is being used at that point, so the source of that data shouldn't matter:
void buildList(/*parameters*/)
{
	glPushMatrix();

	glDeleteLists(final, 1);
	final = glGenLists(1);
	glNewList(final, GL_COMPILE);

None of my data comes into play at this point, which is where the display list fails its request for an ID. I call glDeleteLists there because it's possible for the user to recreate the model. Could that be the problem? What might be some other things causing it to fail? I'll provide more info as needed. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
One possible reason, is that maybe you didnt close a glBegin()
somewhere in your code. Post the rest of the relevant code so
we can track it.

Share this post


Link to post
Share on other sites
Quote:
Original post by IceFront
One possible reason, is that maybe you didnt close a glBegin()
somewhere in your code.


Thought about that. I only call glBegin in 2 places and both are followed up with a glEnd.

Share this post


Link to post
Share on other sites
You mention that everything works fine when A
and doesnt work when B. Can you be more specific what those
A and B are?

Share this post


Link to post
Share on other sites
Quote:
Original post by IceFront
You mention that everything works fine when A
and doesnt work when B. Can you be more specific what those
A and B are?


Gladly.

In A, I make calculations for unique vertices and vertex normals and whatnot, create a display list (which works), and write the data out to a file. In B, I read in that file (we're running the program a second time, obviously) and create the display list based on that. The geometry data is coming in just fine, and the only discrepency I can see is that for some reason glGenLists is returning 0 when I've read in the file and attempt to make the display list after creating the file. The data in the file has no impact on the function at this point, as shown above in the code, yet glGenLists returns 0.

Share this post


Link to post
Share on other sites
well, i cant even specolate what can be wrong without seeing
more of the code. From my experience, glGenLists fails due to
previously occured error in the program. My advice to you is to put
glGetError() in key location throughout the code, and catch that first
error.

Share this post


Link to post
Share on other sites
Do some error checking. Insert the following code after the call to glGenLists:

int error = glGetError();
if (error != GL_NO_ERROR) {
std::cout << "An OpenGL error has occured: " << gluErrorString(error) << std::endl;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!