图形学实验代码.doc

  1. 1、本文档共8页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
图形学实验代码

#include stdafx.h #include windows.h #include gl/glut.h void myinit(void) { GLfloat light_position[]={0.0,3.0,1.0,0.0}; GLfloat light_ambient[]={0.0,1.0,0.0,1.0}; GLfloat light_diffuse[]={1.0,1.0,1.0,1.0}; GLfloat light_specular[]={0.8,1.0,0.0,1.0}; GLfloat lmodel_ambient[]={0.0,1.0,1.0,1.0}; GLfloat local_view[]={0.0}; glLightfv(GL_LIGHT0,GL_POSITION,light_position); glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient); glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse); glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient); glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER,local_view); glClearColor(0.0,0.0,0.0,0.0); glShadeModel(GL_SMOOTH); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); } void display(void) { GLfloat d=-7.0; GLfloat no_mat[]={0.0,0.0,1.0,1.0}; GLfloat mat_ambient[]={0.0,0.1,1.0,1.0}; GLfloat mat_diffus[]={0.6,0.5,0.1,1.0}; GLfloat mat_specular[]={1.0,1.0,1.0,1.0}; GLfloat mat_shininess[]={50.0}; GLfloat no_shininess[]={0.0}; GLfloat low_shininess[]={5.0}; GLfloat high_shininess[]={100.0}; GLfloat mat_emission[]={0.3,0.2,0.2,0.0}; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glTranslatef(-4.5,0.0,d); glMaterialfv(GL_FRONT,GL_AMBIENT,no_mat); glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffus); glMaterialfv(GL_FRONT,GL_SPECULAR,no_mat); glMaterialfv(GL_FRONT,GL_SHININESS,no_shininess); glMaterialfv(GL_FRONT,GL_EMISSION,no_mat); glutSolidOctahedron(); glPopMatrix(); glPushMatrix(); glTranslatef(-1.5,-1.5,d); glMaterialfv(GL_FRONT,GL_AMBIENT,no_mat); glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffus); glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular); glMaterialfv(GL_FRONT,GL_SHININESS,low_shininess); glMaterialfv(GL_FRONT,GL_EMISSION,no_mat); glutSolidSphere(1.0,30,30); glPopMatrix(); glPushMatrix(); glTranslatef(1.5,-1.5,d); glMaterialfv(GL_FRONT,GL_AMBIENT,no_mat); glMaterialfv(GL_FRONT

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档