Advertisement

Problem with NeHe tutorial, all sorts of weirdness!

Started by October 06, 2002 12:09 AM
4 comments, last by Springer 22 years, 4 months ago
I am having some weird trouble with tutorial 6 from NeHe's site. I was making the 3d cube, no big deal. I was in a rush to texture one face of it and see what it looked like so i only made the top, front, and bottom of the cube. They were rotating perfectly, everything looked good! That is when i decided to throw a texture on the front face of the cube. Well at first it was almost pitch black, i had to comment out the top and bottom faces of my cube and then the texture is tiled on the front face of the cube!!! I will post the Redering function so you can tell me if i am doing anything wrong.
    int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing

{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer

	glLoadIdentity();									// Reset The Current Modelview Matrix

	
	glTranslatef(0.0f, 0.0f, -6.0f);

	//glRotatef(rquad,0.0f,1.0f,0.0f);


	glRotatef(xrot, 1.0f, 0.0f, 0.0f);
	glRotatef(yrot, 0.0f, 1.0f, 0.0f);
	glRotatef(zrot, 0.0f, 0.0f, 1.0f);

	glBindTexture(GL_TEXTURE_2D, texture[0]);

	glBegin(GL_QUADS);
	//Top of cube

	glColor3f(0.0f, 1.0f, 0.0f);	
	glVertex3f(1.0f, 1.0f, -1.0f);
	glVertex3f(-1.0f, 1.0f, -1.0f);
	glVertex3f(-1.0f, 1.0f, 1.0f);
	glVertex3f(1.0f, 1.0f, 1.0f);
	
	//Bottom of cube

	glColor3f(1.0f, 0.0f, 0.0f);
	glVertex3f(1.0f, -1.0f, -1.0f);
	glVertex3f(-1.0f, -1.0f, -1.0f);
	glVertex3f(-1.0f, -1.0f, 1.0f);
	glVertex3f(1.0f, -1.0f, 1.0f);

	//Front of cube.

	//glColor3f(0.0f, 0.0f, 1.0f);

	glTexCoord2f(1.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, -1.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
	glTexCoord2f(1.0f, -1.0f); glVertex3f(1.0f, -1.0f, 1.0f);

	glEnd();

	xrot+=0.3f;
	yrot+=0.2f;
	zrot+=0.4f;

		
	//rquad-=0.15f;


	return TRUE;
}    
EDIT:: Sorry i figured out why it was tiling, DOH! That still does not clear up the issue as to why it gets really dark when i try to draw in the top and bottom faces of the cube. They were looking great before i textured it. [edited by - Springer on October 6, 2002 1:14:09 AM]
Try putting a glColor3f(1, 1, 1); before you set the tex coords and vertex for the textured face.
"...."
Advertisement
thank you, that worked. I thought that was the white color?
What exactly did that do by setting the color like that?

Also, why does the tutorial not have that in the code but yet his cube isnt dark at all?

Thanks for the help
The texture coordinates only go from 0 to 1 not -1
Ya i know that is why i edited my post, the only thing i need help with is the light.

When i draw the other faces everything turns almost pitch black.

Only when i put all the colors to white does it make everything show up. THe only problem is that all the faces turn blue, the untextured ones that is.
Change the color to bright white, before u draw the quads.

This topic is closed to new replies.

Advertisement