全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
将灰度图的X、Y坐标作为三维图的X、Y坐标,将灰度图中各点灰度值作为Z坐标代码:/* L6.c OpenGL Framework using GLUT 3.7 Rob Fletcher 2001 Draw a quad and apply various transformations.*/#include #include /* For exit prototype */#include /* Header File For The GLUT Library */* ASCII code for the escape key. */#define ESCAPE 27GLint window; /* The number of our GLUT window */GLint Xsize=400;GLint Ysize=400;GLfloat xs=1.0,ys=1.0,zs=1.0; /* scale */* Simple window transformation routine */GLvoid Transform(GLfloat Width, GLfloat Height) glViewport(0, 0, Width, Height); /* Set the viewport */ glMatrixMode(GL_PROJECTION); /* Select the projection matrix */ glLoadIdentity();/* Reset The Projection Matrix */ gluPerspective(45.0,Width/Height,0.1,100.0); /* Calculate The Aspect Ratio Of The Window */ glMatrixMode(GL_MODELVIEW); /* Switch back to the modelview matrix */* A general OpenGL initialization function. Sets all of the initial parameters. */GLvoid InitGL(GLfloat Width, GLfloat Height) glClearColor(0.0, 0.0, 0.0, 0.0);/* This Will Clear The Background Color To Black */ glShadeModel(GL_SMOOTH); Transform( Width, Height ); /* Perform the transformation */* The function called when our window is resized */GLvoid ReSizeGLScene(GLint Width, GLint Height) if (Height=0) Height=1; /* Sanity checks */ if (Width=0) Width=1; Transform( Width, Height ); /* Perform the transformation */* The main drawing function In here we put all the OpenGL and calls to routines which manipulate the OpenGL state and environment. This is the function which will be called when a redisplay is requested.*/GLvoid DrawGLScene() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);/* Clear The Screen And The Depth Buffer */ glPushMatrix(); glLoadIdentity(); glTranslatef(0.0,0.0,-6.0); glScalef(xs,ys,zs); glBegin(GL_QUADS); glColor3f(1.0,1.0,0.0); glVertex3f( 1.0, 1.0, 1.0); glColor3f(1.0,0.0,0.0); glVertex3f(-1.0, 1.0, 1.0); glColor3f(1.0,1.0,0.0); glVertex3f(-1.0,-1.0, 1.0); glColor3f(1.0,0.0,0.0); glVertex3f( 1.0,-1.0, 1.0); glEnd(); glPopMatrix(); glFlush(); /* The function called whenever a normal key is pressed. */void NormalKey(GLubyte key, GLint x, GLint y) switch ( key ) case ESCAPE : printf(escape pressed. exit.n);glutDestroyWindow(window);/* Kill our window */exit(0); /* Very dirty exit */ break;/* Do we need this? */ case x: /* Scale x up */ xs += 0.2; glutPostRedisplay(); break; case X: xs -= 0.2; /* Scale x down */ glutPostRedisplay(); break; case y: /* Scale y up */ ys += 0.2; glutPostRedisplay(); break; case Y: ys -= 0.2; /* Scale y down */ glutPostRedisplay(); break; case z: /* Scale z up */ zs += 0.2; glutPostRedisplay(); break; case Z: zs -= 0.2; /* Scale z down */ glutPostRedisplay(); break; default:break; /* Main */int main(int argc, char *argv) /* Initialisation and window creation */ glutInit(&argc, argv); /* Initialize GLUT state. */ glutInitDisplayMode(GLUT_RGBA | /* RGB and Alpha */ GLUT_SINGLE| /* Single buffer */ GLUT_DEPTH); /* Z buffer (depth) */ glutInitWindowSize(Xsize,Ysize); /* set initial window size. */ glutInitWindowPosition(0,0); /* upper left corner of the screen. */ window = glutCreateWindow(L6); /* Open a window with a title. */ InitGL(Xsize,Ysize); /* Initialize our window. */* Now register the various callback functions */ glutDisplayFunc(DrawGLScene); /* Function to do all our OpenGL drawing. */ glutReshapeFunc(ReSizeGLScene); gl
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025中国大唐集团新能源股份有限公司本部应届毕业生招聘笔试历年常考点试题专练附带答案详解2套试卷
- 2025中国信达重庆分公司校园招聘5人笔试历年典型考试题附带答案详解(3卷合一)
- 2025中华联合财产保险股份有限公司嘉兴中心支公司招聘12人笔试历年常考点试题专练附带答案详解2套试卷
- 基于ADDIE模型的中医院新护士中医护理能力培训方案的构建及初步应用
- 浙江国企招聘2025丽水市供排水有限责任公司招聘工作人员4人笔试历年参考题库附带答案详解
- 2025重庆临空文化旅游发展有限公司社招7人笔试历年参考题库附带答案详解
- 2025自治区地矿局所属企业新疆宝地工程建设有限公司招聘16人笔试历年参考题库附带答案详解
- 2025福建厦门市翔安招商集团有限公司招聘4人笔试历年参考题库附带答案详解
- 2025湖北襄阳市襄高控股发展有限公司招聘延长笔试历年参考题库附带答案详解
- 2025浙江杭州桐庐县富春未来城开发建设有限公司招聘3人笔试历年参考题库附带答案详解
- 2025河北廊坊三河市公安局招聘警务辅助人员200人考试参考题库及答案解析
- 自行式剪刀车作业平台施工方案
- 农田土地翻耕合同范本
- 交通事故80岁赔偿
- 软件产品项目管理方案
- 2025年城市地下综合管廊建设财务可持续性研究报告
- 6.2 学会依法办事 课件-2025-2026学年统编版道德与法治 八年级上册
- 直肠癌经典表现课件
- 2025江西南昌市青山湖区招聘社区工作者(专职网格员)45人考前自测高频考点模拟试题及参考答案详解一套
- 校长在学生行为规范与纪律教育专题大会上的讲话
- 第2课 第二次鸦片战争(教学设计)-统编版八年级历史上册
评论
0/150
提交评论