Unintended Lines And Boxes

closed account (2NywAqkS)
I have a program, using OpenGL, 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?

edit:

In release mode:
http://i.imgur.com/pksFf.png

In debug mode:
http://i.imgur.com/XOq3e.png

and the code if it helps:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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();
}
Last edited on
So I'm fairly sure its a compiler error


That's not a safe assumption at all. Modern compilers are very solid and the odds of you exposing such a bug is very slim.

As the saying goes, "only a poor worker blames his tools". It's all but guaranteed that the problem is because of your code.

A screenshot or something might help diagnose, but it's hard to say for sure what could be causing it. Heap corruption si my ever-present "go to" answer for strange, otherwise unexplainable errors.

But yeah without seeing details of the problem or any code I can't really say.
Last edited on
closed account (2NywAqkS)
It was an initialised variable in the cuboid class. I didn't realise that you needed to put in all variables in the setter
Topic archived. No new replies allowed.