关于glRotatef(angle, x, y, z)函数

不知道为什么

glLoadIdentity();
glTranslatef(0.0f,0.0f,-6.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,0.0f, 0.0f);
glVertex3f(1.0f,0.0f, 0.0f);
glVertex3f(0.0f,1.0f, 0.0f);
glEnd();

这样的话总是无法显示,求大神告诉

旋转语句的旋转中心(0.0f, 0.0f, 0.0f)这个点。

#include<GL/glut.h>

void display()
{  
	glClearColor(0.0,0.0,0.0,0.0);
	glOrtho(-10,10,-10,10,-10,10);
	glClear(GL_COLOR_BUFFER_BIT);   
      

/*
glTranslatef(0.0f,0.0f,-6.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,0.0f, 0.0f);
glVertex3f(1.0f,0.0f, 0.0f);
glVertex3f(0.0f,1.0f, 0.0f);
glEnd();*/

glRotatef(45,0.0f,0.0f,1.0f);
glTranslatef(2.0f,0.0f,-6.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,0.0f, 0.0f);
glVertex3f(1.0f,0.0f, 0.0f);
glVertex3f(0.0f,1.0f, 0.0f);
glEnd();

	glFlush();
}

int main(int argc, char* argv[])
{
	 
    glutInit(&argc, argv);

	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(500, 500);
	glutInitWindowPosition(0, 0);
	glutCreateWindow("Simple");
    glClearColor(1.0,1.0,1.0,0.0);
	glutDisplayFunc(display);
    
	glutMainLoop();   //使程序一直处在监听状态中
        
  
	return 0;
}


你可能感兴趣的:(OpenGL)