Click here to Skip to main content
15,868,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. I am trying to texturemap some faces. But when i run the program, everything is white.

Code:

(Please note that the class Texture is a part of a starterkit i use. It has worked before perfectly good before. I do not get any IO errors
C++
void PartCubes::drawShaft(Texture floor, Texture wall)
{
	float w = 140;
	float l = 280;
	float fixedOffset = 140;
	glBegin(GL_QUADS);
		//glColor3f(0.0, 1.0, 0.0);
		for(int i = 0; i < (l / w); i++)
		{
			floor.enable();
			//floor
			glTexCoord2f(1, 1); glVertex3f(-fixedOffset + (i + 1) * w, 0, w / 2); 
			glTexCoord2f(1, 0); glVertex3f(-fixedOffset + (i + 1) * w, 0, 0  - (w / 2)); 
			glTexCoord2f(0, 0); glVertex3f(-fixedOffset + i * w, 0, 0 - (w / 2)); 
			glTexCoord2f(0, 1); glVertex3f(-fixedOffset + i * w, 0, w / 2); 
			floor.disable();
			//glColor3f(0, 0, 1);
			//Wall(s)
			wall.enable();
			glTexCoord2f(1, 1); glVertex3f(-fixedOffset + (i + 1) * w, w, w / 2);
			glTexCoord2f(1, 0); glVertex3f(-fixedOffset + (i + 1) * w, 0, w / 2);
			glTexCoord2f(0, 0); glVertex3f(-fixedOffset + i * w, 0, w / 2);
			glTexCoord2f(0, 1); glVertex3f(-fixedOffset + i * w, w, w / 2);
			//Another wall
			glTexCoord2f(1, 1); glVertex3f(-fixedOffset + (i + 1) * w, w, 0 - (w / 2));
			glTexCoord2f(1, 0); glVertex3f(-fixedOffset + (i + 1) * w, 0, 0 - (w / 2));
			glTexCoord2f(0, 0); glVertex3f(-fixedOffset + i * w, 0, 0 - (w / 2));
			glTexCoord2f(0, 1); glVertex3f(-fixedOffset + i * w, w, 0 - (w / 2));
			wall.disable();
			//glColor3f(0, 1, 0);
			//Start wall
			glVertex3f(-fixedOffset, 0, w / 2);
			glVertex3f(-fixedOffset, 0, 0 - (w / 2));
			glVertex3f(-fixedOffset, w, 0 - (w / 2));
			glVertex3f(-fixedOffset, w, w / 2);
		}
	glEnd();

}
Posted
Comments
Santhosh G_ 29-Jan-12 12:59pm    
Is there any shaders enabled before calling drawShaft()?

Hope floor.enable(); will call glEnable( GL_TEXTURE_2D ); and floor.disable() will call glDisable( GL_TEXTURE_2D );.

Please confirm Texture class properly binds the expected texture.
smokindinesh 3-May-12 10:25am    
Post the code how you bind the texture you may pass the wrong value to the function glTextImage2D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900