openGL显示窗口弹不出来,希望大神看看是什么问题
我设置了一个长20宽20高100的立体形,利用光照显示3D图形,除了窗口弹不出来,设置光照的时候是不是有点不对,求大神解答,谢谢voidinit(){glClearCol...
我设置了一个长20宽20高100的立体形,利用光照显示3D图形,除了窗口弹不出来,设置光照的时候是不是有点不对,求大神解答,谢谢
void init()
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
}
void ondisplay()
{ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
int i=0;
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3,GL_FLOAT,0,colors);
glColorPointer(3,GL_FLOAT,0,vertex);
GLfloat position[]={30,40.0,0.0};
glRotated((GLfloat)spin,0.0,1.0,0.0);
glLightfv(GL_LIGHT0,GL_POSITION,position);
glBegin(GL_TRIANGLE_FAN);
for(i=0;i<600;i++)
glArrayElement(i);
glEnd();
glFlush();
}
void onshape(int w,int h)
{
glViewport(0,0,w,h);
glMatrixMode( GL_PROJECTION );// 先设置投影矩阵
glLoadIdentity();
gluPerspective(100.0,(GLfloat)w/h,0.1f,1000.0f);
gluLookAt(0, 0, 50,0, 0, 0, 0,1,0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void Idle()
{
spin=(spin+5)%360;
glutPostRedisplay();
Sleep(20);
}
void main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(1000,700);
glutInitWindowPosition(100,100);
glutCreateWindow("dingdian");
glutIdleFunc(Idle);
glutDisplayFunc(ondisplay);
glutReshapeFunc(onshape);
init();
glutMainLoop();
} 展开
void init()
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
}
void ondisplay()
{ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
int i=0;
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3,GL_FLOAT,0,colors);
glColorPointer(3,GL_FLOAT,0,vertex);
GLfloat position[]={30,40.0,0.0};
glRotated((GLfloat)spin,0.0,1.0,0.0);
glLightfv(GL_LIGHT0,GL_POSITION,position);
glBegin(GL_TRIANGLE_FAN);
for(i=0;i<600;i++)
glArrayElement(i);
glEnd();
glFlush();
}
void onshape(int w,int h)
{
glViewport(0,0,w,h);
glMatrixMode( GL_PROJECTION );// 先设置投影矩阵
glLoadIdentity();
gluPerspective(100.0,(GLfloat)w/h,0.1f,1000.0f);
gluLookAt(0, 0, 50,0, 0, 0, 0,1,0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void Idle()
{
spin=(spin+5)%360;
glutPostRedisplay();
Sleep(20);
}
void main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(1000,700);
glutInitWindowPosition(100,100);
glutCreateWindow("dingdian");
glutIdleFunc(Idle);
glutDisplayFunc(ondisplay);
glutReshapeFunc(onshape);
init();
glutMainLoop();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询