Sign in to follow this  
zacharya

why cant I use list when I use multiple textures

Recommended Posts

I just finished reading nehe's lesson 7 on texture filter and lighting....and I made a little bit of change from the code given. I tried using list instead of just calling glVertex3f over and over again. the problem is when I use glCallList(...) it didn't display anything....I just wondering if it is because I use multiple textures? my code : didn't work :
void setList(void)
{
	
	glNewList(list,GL_COMPILE);
	
		glBegin(GL_QUADS);

			glNormal3f(0.0f,0.0f,1.0f);
			glTexCoord2f(0.0f,1.0f);
			glVertex3f(-1.0f,1.0f,1.0f);
			glTexCoord2f(1.0f,1.0f);
			glVertex3f(1.0f,1.0f,1.0f);
			glTexCoord2f(1.0f,0.0f);
			glVertex3f(1.0f,-1.0f,1.0f);
			glTexCoord2f(0.0f,0.0f);
			glVertex3f(-1.0f,-1.0f,1.0f);
			
			glNormal3f(0.0,0.0f,-1.0f);
			glTexCoord2f(1.0f,1.0f);
			glVertex3f(-1.0f,1.0f,-1.0f);
			glTexCoord2f(0.0f,1.0f);
			glVertex3f(1.0f,1.0f,-1.0f);
			glTexCoord2f(0.0f,0.0f);
			glVertex3f(1.0f,-1.0f,-1.0f);
			glTexCoord2f(1.0f,0.0f);
			glVertex3f(-1.0f,-1.0f,-1.0f);
		
			glNormal3f(-1.0f,0.0f,0.0f);
			glTexCoord2f(0.0f,0.0f);
			glVertex3f(-1.0f,-1.0f,-1.0f);
			glTexCoord2f(1.0f,0.0f);
			glVertex3f(-1.0f,-1.0f,1.0f);
			glTexCoord2f(1.0f,1.0f);
			glVertex3f(-1.0f,1.0f,1.0f);
			glTexCoord2f(0.0f,1.0f);
			glVertex3f(-1.0f,1.0f,-1.0f);
			
			
			glNormal3f(1.0f,0.0f,0.0f);
			glTexCoord2f(1.0f,0.0f);
			glVertex3f(1.0f,-1.0f,-1.0f);
			glTexCoord2f(0.0f,0.0f);
			glVertex3f(1.0f,-1.0f,1.0f);
			glTexCoord2f(0.0f,1.0f);
			glVertex3f(1.0f,1.0f,1.0f);
			glTexCoord2f(1.0f,1.0f);
			glVertex3f(1.0f,1.0f,-1.0f);
		
			glNormal3f(0.0f,1.0f,0.0f);
			glTexCoord2f(0.0f,0.0f);
			glVertex3f(-1.0f,1.0f,1.0f);
			glTexCoord2f(0.0f,1.0f);
			glVertex3f(-1.0f,1.0f,-1.0f);
			glTexCoord2f(1.0f,1.0f);
			glVertex3f(1.0f,1.0f,-1.0f);
			glTexCoord2f(1.0f,0.0f);
			glVertex3f(1.0f,1.0f,1.0f);
			
			
			glNormal3f(0.0f,-1.0f,0.0f);
			glTexCoord2f(1.0f,0.0f);
			glVertex3f(-1.0f,-1.0f,1.0f);
			glTexCoord2f(1.0f,1.0f);
			glVertex3f(-1.0f,-1.0f,-1.0f);
			glTexCoord2f(0.0f,1.0f);
			glVertex3f(1.0f,-1.0f,-1.0f);
			glTexCoord2f(0.0f,0.0f);
			glVertex3f(1.0f,-1.0f,1.0f);


		glEnd();

	glEndList();
}

int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	

	glLoadIdentity();									
	glTranslatef(0.0f,0.0f,z);	
	
	glRotatef(xrot,1.0f,0.0f,0.0f);
	glRotatef(yrot,0.0f,1.0f,0.0f);
	
	
	glBindTexture(GL_TEXTURE_2D, texture[filter]);
	glCallList(list);

	xrot +=xspeed;
	yrot +=yspeed;

	return TRUE;										
}


I use the ::setList() function in the initGL() function..... this code works.... int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f,0.0f,z); glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(yrot,0.0f,1.0f,0.0f); glBindTexture(GL_TEXTURE_2D, texture[filter]); glBegin(GL_QUADS); glNormal3f(0.0f,0.0f,1.0f); glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f,1.0f,1.0f); glTexCoord2f(1.0f,1.0f); glVertex3f(1.0f,1.0f,1.0f); glTexCoord2f(1.0f,0.0f); glVertex3f(1.0f,-1.0f,1.0f); glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,-1.0f,1.0f); glNormal3f(0.0,0.0f,-1.0f); glTexCoord2f(1.0f,1.0f); glVertex3f(-1.0f,1.0f,-1.0f); glTexCoord2f(0.0f,1.0f); glVertex3f(1.0f,1.0f,-1.0f); glTexCoord2f(0.0f,0.0f); glVertex3f(1.0f,-1.0f,-1.0f); glTexCoord2f(1.0f,0.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glNormal3f(-1.0f,0.0f,0.0f); glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glTexCoord2f(1.0f,0.0f); glVertex3f(-1.0f,-1.0f,1.0f); glTexCoord2f(1.0f,1.0f); glVertex3f(-1.0f,1.0f,1.0f); glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f,1.0f,-1.0f); glNormal3f(1.0f,0.0f,0.0f); glTexCoord2f(1.0f,0.0f); glVertex3f(1.0f,-1.0f,-1.0f); glTexCoord2f(0.0f,0.0f); glVertex3f(1.0f,-1.0f,1.0f); glTexCoord2f(0.0f,1.0f); glVertex3f(1.0f,1.0f,1.0f); glTexCoord2f(1.0f,1.0f); glVertex3f(1.0f,1.0f,-1.0f); glNormal3f(0.0f,1.0f,0.0f); glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,1.0f,1.0f); glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f,1.0f,-1.0f); glTexCoord2f(1.0f,1.0f); glVertex3f(1.0f,1.0f,-1.0f); glTexCoord2f(1.0f,0.0f); glVertex3f(1.0f,1.0f,1.0f); glNormal3f(0.0f,-1.0f,0.0f); glTexCoord2f(1.0f,0.0f); glVertex3f(-1.0f,-1.0f,1.0f); glTexCoord2f(1.0f,1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glTexCoord2f(0.0f,1.0f); glVertex3f(1.0f,-1.0f,-1.0f); glTexCoord2f(0.0f,0.0f); glVertex3f(1.0f,-1.0f,1.0f); glEnd(); //glCallList(list); xrot +=xspeed; yrot +=yspeed; return TRUE; } [/source] I just curious why can't I use list here.....or did I make another stupid mistake......

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this