全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
将灰度图的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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年盐业改革考试测试题及答案
- 2026年废物男友测试题及答案
- 2026年大学进阶英语期末测试题及答案
- 2026年四道哈佛测试题及答案
- 2026年携号转网测试题及答案
- 2026年节能建筑门窗测试题及答案
- 2026年谈恋爱前的测试题及答案
- 2026年黑龙江、吉林、辽宁、内蒙古高考物理试卷(含答案及解析)
- 2026学年江苏省江阴市四年级语文期末高分预测知识串联题(附答案)详细答案和解析
- 单招公办职业试题及答案
- 2026青海数字经济发展集团有限公司社会招聘9人笔试备考题库及答案详解
- 2026年国家公务员考试面试题及答案
- 浙江省金华市2026年中考一模 科学卷
- 河南开放大学2026年《版式设计》形考作业1-3答案终考作业答案
- 2026年中考历史考前冲刺:中国+世界(古代史|近代史|现代史) 小论文范文汇编
- 先天性无阴道患者的个案护理
- TSG08-2026《特种设备使用管理规则》解析
- 亡故患者信息保护教育培训课件
- 近似计算在数学分析中的应用毕业
- 气血疏通中级班讲义
- GB/T 4852-2002压敏胶粘带初粘性试验方法(滚球法)
评论
0/150
提交评论