全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
将灰度图的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年秋人教版新教材九年级上册英语期中质量评价试卷(含答案)
- 高中数学 加练 专题8 第71练 直线与圆、圆与圆的位置关系
- 1.语文九年级上册第一单元晨读配套练习学生版
- 试用期劳动合同中止协议书模板-1
- 普洱开业营销方案策划(3篇)
- 果蔬社区营销方案(3篇)
- 毛石砼浇筑施工方案(3篇)
- 游戏营销产品方案模版(3篇)
- 物业部门应急预案范文(3篇)
- 盘山耐磨地坪施工方案(3篇)
- 2026天津石油职业技术学院招聘20人笔试备考题库及答案详解
- 2026年成都高新投资集团有限公司下属高新发展、社事投资公司公开招聘22人笔试参考题库及答案详解
- 2026年6月青少年软件编程Scratch等级考试一级真题(含答案)
- 2026江苏连云港东海县事业单位招聘工作人员14人重点基础提升(共500题)附带答案详解
- 机加工中心刀具寿命管理规范
- 法律服务采购服务方案投标文件(技术标)
- 品牌使用管理办法
- 咖啡店劳动合同书(标准版)
- 连续化生产管理制度
- 江苏省常州市三校联考2025-2026学年高一年级上册期中考试英语试题(含答案)
- 检身工考试试题及答案
评论
0/150
提交评论