オブジェクトは 0,0,0 を中心に回転していますが、Y 軸を中心に回転させたいです。他のケースもあると思います
しかし、ローテーションの前に翻訳がなく、まだ機能しません。
私の編集コード:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(_angle,0.0f,1.0f,0.0f);
glPushMatrix();
glTranslatef(0.0f,0.0f,-6.0f);
glBegin(GL_TRIANGLES);
//Front
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
//Back
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f(1.0f, 1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(1.0f, -1.0f, -1.0f);
glVertex3f(1.0f, 1.0f, -1.0f);
//Right
glVertex3f(1.0f, 1.0f, 1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glVertex3f(1.0f, -1.0f, -1.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
glVertex3f(1.0f, 1.0f, -1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
//Left
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
//Top
glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f(1.0f, 1.0f, -1.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
//Bottom
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(1.0f, -1.0f, -1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glEnd();
glPopMatrix();
glutSwapBuffers();
私の元のコード:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(angle,0.0f,1.0f,0.0f); //The angle is a float that slowly increases until it reaches 360 Degrees, and then resets to 0.0
/* This is a Cube */
glBegin(GL_TRIANGLES);
//Front
glVertex3f(-1.0f, -1.0f, -5.0f);
glVertex3f(-1.0f, 1.0f, -5.0f);
glVertex3f(1.0f, 1.0f, -5.0f);
glVertex3f(-1.0f, -1.0f, -5.0f);
glVertex3f(1.0f, -1.0f, -5.0f);
glVertex3f(1.0f, 1.0f, -5.0f);
//Back
glVertex3f(-1.0f, -1.0f, -7.0f);
glVertex3f(-1.0f, 1.0f, -7.0f);
glVertex3f(1.0f, 1.0f, -7.0f);
glVertex3f(-1.0f, -1.0f, -7.0f);
glVertex3f(1.0f, -1.0f, -7.0f);
glVertex3f(1.0f, 1.0f, -7.0f);
//Right
glVertex3f(1.0f, 1.0f, -5.0f);
glVertex3f(1.0f, -1.0f, -5.0f);
glVertex3f(1.0f, -1.0f, -7.0f);
glVertex3f(1.0f, 1.0f, -5.0f);
glVertex3f(1.0f, 1.0f, -7.0f);
glVertex3f(1.0f, -1.0f, -5.0f);
//Left
glVertex3f(-1.0f, 1.0f, -5.0f);
glVertex3f(-1.0f, -1.0f, -5.0f);
glVertex3f(-1.0f, -1.0f, -7.0f);
glVertex3f(-1.0f, 1.0f, -5.0f);
glVertex3f(-1.0f, 1.0f, -7.0f);
glVertex3f(-1.0f, -1.0f, -7.0f);
//Top
glVertex3f(-1.0f, 1.0f, -7.0f);
glVertex3f(-1.0f, 1.0f, -5.0f);
glVertex3f(1.0f, 1.0f, -5.0f);
glVertex3f(-1.0f, 1.0f, -7.0f);
glVertex3f(1.0f, 1.0f, -7.0f);
glVertex3f(1.0f, 1.0f, -5.0f);
//Bottom
glVertex3f(-1.0f, -1.0f, -7.0f);
glVertex3f(-1.0f, -1.0f, -5.0f);
glVertex3f(1.0f, -1.0f, -5.0f);
glVertex3f(-1.0f, -1.0f, -7.0f);
glVertex3f(1.0f, -1.0f, -7.0f);
glVertex3f(1.0f, -1.0f, -5.0f);
glEnd();
glutSwapBuffers();