Trouble with cube

A newbie question :slight_smile: I tryed to work out a function that making a cube with parameters.
Problem is the cube doesn’t look right. why?
code:
void createRoom(float langd, float hojd, float bredd, GLuint texture_id)
{
glPushMatrix();
glBindTexture ( GL_TEXTURE_2D, texture_id);
glBegin(GL_QUADS);
/front/
glTexCoord2f(1.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); //bottom left
glTexCoord2f(1.0f, 1.0f); glVertex3f(langd, 0.0f, 0.0f); //bottom right
glTexCoord2f(0.0f, 1.0f); glVertex3f(langd, hojd, 0.0f); // top right
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, hojd ,0.0f); //top left
/Back/
glTexCoord2f(0.0f, 0.0f); glVertex3f(langd, 0.0f, bredd); //bottom right
glTexCoord2f(1.0f, 0.0f); glVertex3f(langd, hojd, bredd); //top right
glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, hojd, bredd); // top left
glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 0.0f, bredd); //bottom left
/Top/
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, hojd, 0.0f); //top left
glTexCoord2f(1.0f, 0.0f); glVertex3f(0.0f, hojd, bredd); //bottom left
glTexCoord2f(1.0f, 1.0f); glVertex3f(langd, hojd,bredd); //bottom right
glTexCoord2f(0.0f, 1.0f); glVertex3f(langd, hojd, 0.0f); //top right
/botten/
glTexCoord2f(1.0f, 0.0f); glVertex3f(langd, 0.0f, 0.0f); //top right
glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, 0.0f, 0.0f); //top left
glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 0.0f, bredd); //bottom left
glTexCoord2f(0.0f, 0.0f); glVertex3f(langd, 0.0f, bredd); //bottom right
/Right/
glTexCoord2f(1.0f, 0.0f); glVertex3f(langd, 0.0f, bredd); // bottom right
glTexCoord2f(1.0f, 1.0f); glVertex3f(langd, hojd, bredd); // top right
glTexCoord2f(0.0f, 1.0f); glVertex3f(langd, hojd, 0.0f); // top left
glTexCoord2f(0.0f, 0.0f); glVertex3f(langd, 0.0f, 0.0f); // bottom left
/Left/
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f); //bottom left
glTexCoord2f(1.0f, 0.0f); glVertex3f(0.0f, 0.0f, bredd); //bottom right
glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, hojd, bredd); //top right
glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, hojd, 0.0f); //top left

	glEnd();	
glPopMatrix();

}

Looked like a cube in my code… What exactly does “doesn’t look right” mean for you?

hm, strange, I mean that the sides doesn’t look correct. Some sides seems to invisible and some sides seems to be triangles. But my values have to be correct (wrong order?) cause I wrote it down in an “plane in space” on paper.
Have u tryed to rotate the cube and see if all the sides are perfect?

It looks correct from all angles. Invisible faces can be explained with face bulling. All faces of the cube don’t have the same winding order; some faces are ordered clockwise, some counter clockwise. When turning on face culling, some faces will “incorrectly” be culled since they appear in the wrong order.

Try drawing the cube without a texture. It could be your texture mapping is wrong.