Archived

This topic is now archived and is closed to further replies.

Jonny K

Why can't I create a display list?

Recommended Posts

Jonny K    122
Why can''t I create a display list? Here''s my code:
//Make a display list for the alien

void Alien::make_display_list()
{
	//Generate one display list

	alien_list = glGenLists(1);

	glNewList(alien_list,GL_COMPILE);

		//Draw quad (square) with texture on it

		glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 0.0f); glVertex2f(-0.02, -0.02);// Bottom Left Of The Texture and Quad

			glTexCoord2f(1.0f, 0.0f); glVertex2f(0.02, -0.02);// Bottom Right Of The Texture and Quad

			glTexCoord2f(1.0f, 1.0f); glVertex2f(0.02, 0.02);// Top Right Of The Texture and Quad

			glTexCoord2f(0.0f, 1.0f); glVertex2f(-0.02, 0.02);// Top Left Of The Texture and Quad

		glEnd();

	glEndList();
}
alien_list is an unsigned integer, declared as a private variable in the class. (GLuint = unsigned int). When I investigate this code, I find that after "alien_list = glGenLists(1);", alien_list is still equal to 0 (the initial value). What''s up? Thanks.

Share this post


Link to post
Share on other sites
TomasH    360
Well... Maybe you call that function before creating an OpenGL context?
If that''s not it, try using glGetError() to check what went wrong.

Share this post


Link to post
Share on other sites
Jonny K    122
Aw crap! I'm calling it from a constructor...so yeah, it's possible I'm calling it BEFORE openGL is fully set up! DOH!

*bangs head on table*

I'll take a look. Thanks.

Update: Yeah, that's the problem. Thanks. :-)

[edited by - Jonny K on May 27, 2004 1:07:28 PM]

Share this post


Link to post
Share on other sites