Jump to content
  • Advertisement
Sign in to follow this  
zacharya

why cant I use list when I use multiple textures

This topic is 5036 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

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
Advertisement
in SetList() function, add this line on top:
list = glGenLists(1);
before glNewList(list,GL_COMPILE); now should work (i hope :P )

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!