opengl中的重绘问题
#include<GL\glut.h>
void init()
{
GLfloat mat_specular[]={1.0,1.0,1.0,1.0};
GLfloat mat_shininess[]={50.0};
GLfloat light_position[]={1.0,1.0,1.0,0.0};
GLfloat white_light[]={1.0,0.5,0.0,1.0};
GLfloat lmodel_ambient[]={0.1,0.1,0.1,1.0};
glClearColor(1.0,1.0,1.0,0.0);
glShadeModel(GL_SMOOTH);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
glLightfv(GL_LIGHT0,GL_POSITION,light_position);
glLightfv(GL_LIGHT0,GL_DIFFUSE,white_light);
glLightfv(GL_LIGHT0,GL_SPECULAR,white_light);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutSolidSphere(1.0,200,16);
glFlush();
}
void reshape(int w,int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-1.5,1.5,-1.5*(GLfloat)h/(GLfloat)w,1.5*(GLfloat)h/(GLfloat)w,-10.0,10.0);
else
glOrtho(-1.5,1.5,-1.5*(GLfloat)h/(GLfloat)w,1.5*(GLfloat)h/(GLfloat)w,-10.0,10.0);
//glOtho(GLdouble left,GLdouble right,GLdouble button,GLdouble top,GLdouble near,GLdouble far)
//right>left,top>button,far>near
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
glutCreateWindow("OpenGL程序");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
这段程序运行之后为什么当我在窗口中动一下鼠标或者点击鼠标的时候都会自动重绘呢,还有就是在我移动窗口的时候也会重绘,让我很郁闷,大家帮帮偶吧!!!!!!!!!!!
@.@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-.?