You need to call glPushMatrix
before glTranslatef
and glPopMatrix
after glEnd
.
glTranslatef
doesn't set the transformation, it appends it to the existing transformation. What you need to do is push the existing matrix on the matrix stack, apply the transformation, then restore the original. That way the translations don't accumulate.