void RenderBrain(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
ifstream myFile("brainData.txt");
if (!myFile.is_open())
{
cout << "Unable to open file";
exit(1); // terminate with error
}
glRotatef(80.0f, 1.0f, 0.0f, 0.0f);
while (! myFile.eof())
{
myFile>>a[0];
myFile>>a[1];
myFile>>a[2];
myFile>>a[3];
glColor3f(0.60f,0.80f,0.90f);
glLoadIdentity();
glTranslatef((a[0]-1.15)*26, a[2]*30, a[1]*30);
glutSolidSphere(6, 5, 5);
}
myFile.close();
glFlush();
glutSwapBuffers();
}
以上是我的代码的一部分,在添加 glLoadIdentity(); 后我无法让它旋转;循环内。如果我移除它,我的所有球体都会飞向各个方向。
有人可以帮忙吗?