vc将灰度图转化为三维图

vc将灰度图转化为三维图

ID:8981118

大小:16.32 KB

页数:4页

时间:2018-04-13

vc将灰度图转化为三维图_第1页
vc将灰度图转化为三维图_第2页
vc将灰度图转化为三维图_第3页
vc将灰度图转化为三维图_第4页
资源描述:

《vc将灰度图转化为三维图》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、将灰度图的X、Y坐标作为三维图的X、Y坐标,将灰度图中各点灰度值作为Z坐标代码:/*L6.cOpenGLFrameworkusingGLUT3.7RobFletcher2001Drawaquadandapplyvarioustransformations.*/#include#include/*For"exit"prototype*/#include/*HeaderFileForTheGLUTLibrary*//*ASCIIcodefortheesca

2、pekey.*/#defineESCAPE27GLintwindow;/*ThenumberofourGLUTwindow*/GLintXsize=400;GLintYsize=400;GLfloatxs=1.0,ys=1.0,zs=1.0;/*scale*//*Simplewindowtransformationroutine*/GLvoidTransform(GLfloatWidth,GLfloatHeight){glViewport(0,0,Width,Height);/*Settheviewport*/

3、glMatrixMode(GL_PROJECTION);/*Selecttheprojectionmatrix*/glLoadIdentity();/*ResetTheProjectionMatrix*/gluPerspective(45.0,Width/Height,0.1,100.0);/*CalculateTheAspectRatioOfTheWindow*/glMatrixMode(GL_MODELVIEW);/*Switchbacktothemodelviewmatrix*/}/*AgeneralOp

4、enGLinitializationfunction.Setsalloftheinitialparameters.*/GLvoidInitGL(GLfloatWidth,GLfloatHeight){glClearColor(0.0,0.0,0.0,0.0);/*ThisWillClearTheBackgroundColorToBlack*/glShadeModel(GL_SMOOTH);Transform(Width,Height);/*Performthetransformation*/}/*Thefunc

5、tioncalledwhenourwindowisresized*/GLvoidReSizeGLScene(GLintWidth,GLintHeight){if(Height==0)Height=1;/*Sanitychecks*/if(Width==0)Width=1;Transform(Width,Height);/*Performthetransformation*/}/*ThemaindrawingfunctionInhereweputalltheOpenGLandcallstoroutineswhic

6、hmanipulatetheOpenGLstateandenvironment.Thisisthefunctionwhichwillbecalledwhena"redisplay"isrequested.*/GLvoidDrawGLScene(){glClear(GL_COLOR_BUFFER_BIT

7、GL_DEPTH_BUFFER_BIT);/*ClearTheScreenAndTheDepthBuffer*/glPushMatrix();glLoadIdentity();glTranslatef(0.0,0

8、.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(

9、);glFlush();}/*Thefunctioncalledwhenevera"normal"keyispressed.*/voidNormalKey(GLubytekey,GLintx,GLinty){switch(key){caseESCAPE:printf("escapepressed.exit.");glutDestroyWindow(window);/*Killour

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。