OpenGL画出的图角度不对
现在根好像是躺着的。我希望画出来的根是竖着的,能够看清楚大部分部位。
GLsizei width,height;
GLdouble aspect;
width = cx;
height = cy;
if(cy==0)
{
aspect = (GLdouble)width;
}
else
{
aspect = (GLdouble)width/(GLdouble)height;
}
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// gluOrtho2D(0.0,500.0*aspect,0.0,500.0);
gluPerspective(60, aspect, 0, -100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
float light_position[]={5.0,5.0,5.0,1.0}; //设置光源
float light_diffuse[]={1.0,1.0,1.0,1.0};
float light_ambient[]={1.0,1.0,1.0,1.0};
float light_specular[]={1.0,1.0,1.0,1.0};
glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient);
glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse);
glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDrawBuffer (GL_BACK);