Sign in to follow this  

lesson7, but with textures "looking" to inside.

This topic is 4689 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 want to draw a box like lesson7, but with the textures "looking" to inside the box. The textures must too be transparent to who look the textures by behind. In other words, a box that can be only seen the inside textures. I've tried sommeting, but not worked properly. And only work with transparent textures. Must work with normal textures. Oh, i forgot, the box have 9 QUADS per side. My draw code:
	int drawGLScene( GLvoid )
	{
		/* These are to calculate our fps */
		static GLint T0     = 0;
		static GLint Frames = 0;
		
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
		glColor3f( 1.0f,  1.0f,  1.0f );
		
		
		glLoadIdentity();
		glTranslatef( 0.0f, 0.0f, distance );
		glRotatef(movx, 1.0, 0.0, 0.0);
		glRotatef(movy, 0.0, 1.0, 0.0);
		glRotatef(movz, 0.0, 0.0, 1.0);
		glColor3f( 1.0f,  1.0f,  1.0f );
		
		
		//Cubo principal, formado por 27 outros cubos de 1m³ cada(R: Cubo de 9m³).
		//Lado de baixo
		glTranslatef( -2.0, 2.0, -3.0 );
		glBindTexture( GL_TEXTURE_2D, texture[1] );
		glBegin(GL_QUADS);
		//glTexCoord2f( 0.0f, 1.0f ); 
		glVertex3f( -1.0f, -1.0f, 0.0f );
		//glTexCoord2f( 1.0f, 1.0f ); 
		glVertex3f(  1.0f, -1.0f, 0.0f );
		//glTexCoord2f( 1.0f, 0.0f ); 
		glVertex3f(  1.0f,  1.0f, 0.0f );
		//glTexCoord2f( 0.0f, 0.0f ); 
		glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( -4.0, -2.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( -4.0, -2.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glEnd( );
		
		//Lado de Cima
		glTranslatef( 0.0, 4.0, 6.0 );
		//glBindTexture( GL_TEXTURE_2D, texture[1] );
		glBegin(GL_QUADS);
		//glTexCoord2f( 0.0f, 1.0f ); 
		glVertex3f(  1.0f, -1.0f, 0.0f );
		//glTexCoord2f( 1.0f, 1.0f ); 
		glVertex3f( -1.0f, -1.0f, 0.0f );
		//glTexCoord2f( 1.0f, 0.0f ); 
		glVertex3f( -1.0f,  1.0f, 0.0f );
		//glTexCoord2f( 0.0f, 0.0f ); 
		glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( -2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( -2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( 4.0, -2.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( -2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( -2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( 4.0, -2.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( -2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		glTranslatef( -2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 0.0f );
		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 0.0f );
		glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 0.0f );
		glEnd( );
		
		//Lado Direito
		glTranslatef( 4.0, 4.0, -1.0 );
		//glBindTexture( GL_TEXTURE_2D, texture[1] );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, -2.0, 4.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, -2.0, 4.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		//Lado Esquerdo
		glTranslatef( -6.0, 4.0, 4.0 );
		//glBindTexture( GL_TEXTURE_2D, texture[1] );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, -2.0, 4.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, -2.0, 4.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 0.0, 0.0, -2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		//Lado da frente
		glTranslatef( 2.0, 4.0, 0.0 );
		//glBindTexture( GL_TEXTURE_2D, texture[1] );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( -4.0, 0.0, 2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( -4.0, 0.0, 2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		//Lado de Trás
		glTranslatef( -4.0, -6.0, -4.0 );
		//glBindTexture( GL_TEXTURE_2D, texture[1] );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( -4.0, 0.0, 2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( -4.0, 0.0, 2.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		glTranslatef( 2.0, 0.0, 0.0 );
		glBegin(GL_QUADS);
		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 );
		glEnd( );
		
		SDL_GL_SwapBuffers( );

Share this post


Link to post
Share on other sites
So what's wrong with that code, exactly? What're you seeing?

Basically, you'll just want to specify the triangles so they're facing in the opposite direction as they are now, have the texture coords match the new triangle coords and make sure that you cull rear triangles.

Share this post


Link to post
Share on other sites
I have put two shots from my app. I put a transparent texture, so the results can be see more easily. With a opaque texture, que box gets completely opaque too.
What I see from the 2nd side:
http://geocities.yahoo.com.br/megaspeedlinux/now.jpg

What must apear, except for the top surface:
http://geocities.yahoo.com.br/megaspeedlinux/must.jpg

See the surface in front hiding the surface in back? This cannot happen. AND, the number '2' inverse, cannot appear, only the appear normal "front".

Ah, must work with opaque textures, not only transparents.

Share this post


Link to post
Share on other sites
Render the cube two times like this.

1. enable face culling.
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_FRONT_FACE);

2. set the frontface winding order to clockwise (normaly it counter clockwise), glFrontFace(GL_CW);

3. render the cube.

4. set the winding order to glFrontFace(GL_CCW);

5. render the cube again.

Now if you don't want the textures reversed on the backside you could make two functions of the render cube function where one(the one to be renderd first) has the u value of the texture coords "inverted"(1=0,0=1).

Share this post


Link to post
Share on other sites
Now the box is strange :)
http://geocities.yahoo.com.br/megaspeedlinux/strange.jpg
It's completely opaque now, and others faces has been dislocated.
From, inside the box, everything looks good, only from ouside appear strange. This before and now.
Am, I don't understand very well what you mean to clear the backside of the textures...

Share this post


Link to post
Share on other sites
thats because you do all those translations, do a glPushMatrix(); before you start drawing the box, in the code you provided it would be right after the second glColor3f.
Then do a glPopMatrix(); right after drawing the cube, in the code you provided it would be right before the SDL_GL_SwapBuffers call.

Share this post


Link to post
Share on other sites
Yeah, now works!
It's the GL_CULL. I only enable and set to glEnable(GL_CULL_FACE); and glCullFace(GL_BACK);. Now Works perfectly. Oh, and drawing only one time.
Thanks guys!

Share this post


Link to post
Share on other sites

This topic is 4689 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.

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