Unintended Lines And Boxes

I have a program which, simply put, is just a large collection of cuboid however, despite not being in the code, in release mode a random line comes out of every cuboid stretching on for infinity and in debug mode another cube appears this also stretches on for infinity. So I’m fairly sure its a compiler error but what causes these sort of wierd things?

These pictures might help.

release mode:

debug mode:

and the cube drawing code if it helps.


glPushMatrix();
	glBindTexture(GL_TEXTURE_2D, textures[1]);
	glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
	glTranslatef(x, y, z);
	glBegin(GL_QUADS);
	glColor4f(1.0, 1.0, 1.0, 1.0);
	//Top Face
	glTexCoord2d(0.0, 0.0);				glVertex3f(0, height, 0);
	glTexCoord2d(0.0, depth/8);		glVertex3f(0, height, depth);
	glTexCoord2d(width/8, depth/8);	glVertex3f(width, height, depth);
	glTexCoord2d(width/8, 0.0);		glVertex3f(width, height, 0);

	//Bottom Face
	glTexCoord2d(0.0, 0.0);				glVertex3f(0, 0, 0);
	glTexCoord2d(0.0, depth/8);		glVertex3f(0, 0, depth);
	glTexCoord2d(width/8, depth/8);	glVertex3f(width, 0, depth);
	glTexCoord2d(width/8, 0.0);		glVertex3f(width, 0, 0);

	//Right Face
	glTexCoord2d(0.0,0.0);				glVertex3f(0, 0, 0);
	glTexCoord2d(depth/8, 0.0);		glVertex3f(0, 0, depth);
	glTexCoord2d(depth/8, height/8);	glVertex3f(0, height, depth);
	glTexCoord2d(0.0, height/8);		glVertex3f(0, height, 0);

	//Left Face
	glTexCoord2d(0.0,0.0);				glVertex3f(width, 0, depth);
	glTexCoord2d(depth/8, 0.0);		glVertex3f(width, 0, 0);
	glTexCoord2d(depth/8, height/8);	glVertex3f(width, height, 0);
	glTexCoord2d(0.0, height/8);		glVertex3f(width, height, depth);

	//Front Face
	glTexCoord2d(0.0,0.0);				glVertex3f(width, 0, 0);
	glTexCoord2d(width/8, 0.0);		glVertex3f(0, 0, 0);
	glTexCoord2d(width/8, height/8);	glVertex3f(0, height, 0);
	glTexCoord2d(0.0, height/8);		glVertex3f(width, height, 0);
	
	//Back Face
	glTexCoord2d(0.0,0.0);				glVertex3f(width, 0, depth);
	glTexCoord2d(width/8, 0.0);		glVertex3f(0, 0, depth);
	glTexCoord2d(width/8, height/8);	glVertex3f(0, height, depth);
	glTexCoord2d(0.0, height/8);		glVertex3f(width, height, depth);
	glEnd();

	glBegin(GL_LINES);
	glColor4f(0.0, 0.0, 0.0, 1.0);

	glVertex3f(0.0, 0.0, 0.0);
	glVertex3f(width, 0.0, 0.0);
	glVertex3f(width, 0.0, 0.0);
	glVertex3f(width, 0.0, depth);
	glVertex3f(width, 0.0, depth);
	glVertex3f(0.0, 0.0, depth);
	glVertex3f(0.0, 0.0, depth);
	glVertex3f(0.0, 0.0, 0.0);

	glVertex3f(0.0, height, 0.0);
	glVertex3f(width, height, 0.0);
	glVertex3f(width, height, 0.0);
	glVertex3f(width, height, depth);
	glVertex3f(width, height, depth);
	glVertex3f(0.0, height, depth);
	glVertex3f(0.0, height, depth);
	glVertex3f(0.0, height, 0.0);

	glVertex3f(0.0, 0.0, 0.0);
	glVertex3f(0.0, height, 0.0);
	glVertex3f(width, 0.0, 0.0);
	glVertex3f(width, height, 0.0);
	glVertex3f(width, 0.0, depth);
	glVertex3f(width, height, depth);
	glVertex3f(0.0, 0.0, depth);
	glVertex3f(0.0, height,depth);

	glEnd();
	glPopMatrix();
}

if width,height and depth variables are defined as integer (int) , the result of the division by 8 will be an integer not a floating point number. To have a floating point number, divide by 8.0 or multiply by 0.125 . Example: 7/8 will be 0 . 7.0/8.0 will be 0.875 . Also, weird things can happen if some of your variables you use are not properly initialized.

It was an initialised variable in the cuboid class. I didn’t realise that you needed to put in all variables in the setter