The issue, I believe, is from your use of glTranslate
.
As an example we have 3 cubes. We wish to draw them at (0,0,0)
, (1,0,0)
, (2,0,0)
. According to your use of glTranslate
the following will happen:
Cube 1
will be drawn at (0,0,0)
as glTranslate(0,0,0)
is envoked.
Cube 2
will be drawn at (1,0,0)
as glTranslate(1,0,0)
is envoked.
Cube 3
will be drawn at (3,0,0)
as glTranslate(2,0,0)
is envoked.
Did you catch what went wrong?
glTranslate
translates from the current matrix, not the origin. So you need to reset the matrix back to the origin (0,0,0)
at the end of each call to VBOrender
. So:
{
glTranslate(x,y,z);
// ...
glTranslate(-x,-y,-z);
}
I suggest using some sort of matrix-stack or creating your own to avoid issues like this in the future.