Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ OpenGL
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
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 25-Jan-12 1:42am
Comments
Santhosh_G at 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 at 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
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 25 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100