For each block (x
,y
,z
) you iterate over all elements of skipHere
in the most inner loop. At maximum one of these iterations could lead blockNumber == skipHere[i]
and set skip
to true
.
However you also set skip = false
afterwards in each loop iteration. So practically you will print each block at least 6 times (because it will only be skipped at most once of the seven iterations for i
).
You should move the part
if(skip == false)
{
glPushMatrix();
UpdateTransform(Xres,Yres,Zres);
drawOneCube();
glPopMatrix();
}
skip = false;
outside the most inner loop, so there is at most one printing of each block and only if neither of the seven most inner loop iterations led to skip = true
.
for(int i = 0; i < 7; i++)
{
if(blockNumber == skipHere[i])
{
skip = true;
}
}
if(!skip)
{
glPushMatrix();
UpdateTransform(Xres,Yres,Zres);
drawOneCube();
glPopMatrix();
}
skip = false;