#include <GL/glut.h>
#include"math.h"
GLint winWidth = 600, winHeight = 600;
GLfloat x = -40.0, y = 200.0, z = 250;
GLfloat xref = 50.0, yref = 50.0, zref = 50.0;
GLfloat Vx = 0.0, Vy = 1.0, Vz = 0.0;
GLfloat xwMin = -20.0, ywMin = -20.0, xwMax = 20.0, ywMax =20.0;
GLfloat dnear = 20.0, dfar = 400.0;
void init (void)
{
glClearColor (1.0, 1.0, 1.0, 0.0); //背景颜色
glMatrixMode (GL_MODELVIEW);
gluLookAt (x, y, z, xref, yref, zref, Vx, Vy, Vz);
glMatrixMode (GL_PROJECTION);
glFrustum (xwMin, xwMax, ywMin, ywMax, dnear, dfar);
GLfloat mat_specular[]={0.0,0.0,1.0,0.0};
GLfloat light_position[]={70.0,80.0,80.0,1.0}; //光的位置
GLfloat white_light[]={1.0,0.2,0.8,1.0}; //
GLfloat light0_ambient[]={0.2,0.8,0.2,1.0}; //环境光的光照
glLightfv(GL_LIGHT0,GL_POSITION,light_position); //指定光源位置
glLightfv(GL_LIGHT0,GL_DIFFUSE,white_light); //漫反射
glLightfv(GL_LIGHT0,GL_SPECULAR,white_light); //镜面反射
glLightfv(GL_LIGHT0,GL_AMBIENT,light0_ambient); //环境光
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载