欢迎来到第壹文秘! | 帮助中心 分享价值,成长自我!
第壹文秘
全部分类
  • 幼儿/小学教育>
  • 中学教育>
  • 高等教育>
  • 研究生考试>
  • 外语学习>
  • 资格/认证考试>
  • 论文>
  • IT计算机>
  • 法律/法学>
  • 建筑/环境>
  • 通信/电子>
  • 医学/心理学>
  • ImageVerifierCode 换一换
    首页 第壹文秘 > 资源分类 > PPT文档下载
    分享到微信 分享到微博 分享到QQ空间

    计算机图形学computergraphics课件5.ppt

    • 资源ID:477576       资源大小:1.06MB        全文页数:23页
    • 资源格式: PPT        下载积分:10金币
    快捷下载 游客一键下载
    账号登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    快捷下载时,如果您不填写信息,系统将为您自动创建临时账号,适用于临时下载。
    如果您填写信息,用户名和密码都是您填写的【邮箱或者手机号】(系统自动生成),方便查询和重复下载。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    计算机图形学computergraphics课件5.ppt

    1Programming with OpenGLPart 2:Complete Programs2ObjectivesRefine the first program Alter the default values Introduce a standard program structureSimple viewing Twodimensional viewing as a special case of threedimensional viewingFundamental OpenGL primitivesAttributes3Program Structure Most OpenGL programs have a similar structure that consists of the following functionsmain():defines the callback functions opens one or more windows with the required properties enters event loop(last executable statement)init():sets the state variables Viewing Attributes callbacks Display function Input and window functions4simple.c revisitedIn this version,we shall see the same output but we have defined all the relevant state values through function calls using the default valuesIn particular,we set Colors Viewing conditions Window properties5simple.c#include void mydisplay()glClear(GL_COLOR_BUFFER_BIT);/glColor3f(1.0f,0.0f,0.0f);glBegin(GL_POLYGON);glVertex2f(-0.5,-0.5);glVertex2f(-0.5,0.5);glVertex2f(0.5,0.5);glVertex2f(0.5,-0.5);glEnd();glFlush();int main(int argc,char*argv)glutCreateWindow(simple);glutDisplayFunc(mydisplay);glutMainLoop();6main.c#include int main(int argc,char*argv)glutInit(&argc,argv);glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);glutInitWindowSize(500,500);glutInitWindowPosition(0,0);glutCreateWindow(simple);glutDisplayFunc(mydisplay);init();glutMainLoop();includes gl.hdefine window propertiesset OpenGL stateenter event loopdisplay callback7GLUT functionsglutInit allows application to get command line arguments and initializes systemgluInitDisplayMode requests properties for the window(the rendering context)RGB color Single buffering Properties logically ORed togetherglutWindowSize in pixelsglutWindowPosition from topleft corner of displayglutCreateWindow create window with title“simple”glutDisplayFunc display callbackglutMainLoop enter infinite event loop8init.cvoid init()glClearColor(0.0,0.0,0.0,1.0);glColor3f(1.0,1.0,1.0);glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);black clear coloropaque windowfill/draw with whiteviewing volume9Coordinate SystemsThe units in glVertex are determined by the application and are called object or world coordinatesThe viewing specifications are also in object coordinates and it is the size of the viewing volume that determines what will appear in the imageInternally,OpenGL will convert to camera(eye)coordinates and later to screen coordinates OpenGL also uses some internal representations that usually are not visible to the application10OpenGL CameraOpenGL places a camera at the origin in object space pointing in the negative z directionThe default viewing volume is a box centered at the origin with a side of length 2glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);11Orthographic Viewingz=0z=0In the default orthographic view,points are projected forward along the z axis onto theplane z=012Transformations and Viewing In OpenGL,projection is carried out by a projection matrix(transformation)There is only one set of transformation functions so we must set the matrix mode first glMatrixMode(GL_PROJECTION)Transformation functions are incremental so we start with an identity matrix and alter it with a projection matrix that gives the view volume glLoadIdentity();glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);13Two-and three-dimensional viewing In glOrtho(left,right,bottom,top,near,far)the near and far distances are measured from the camera Twodimensional vertex commands place all vertices in the plane z=0 If the application is in two dimensions,we can use the function gluOrtho2D(left,right,bottom,top)In two dimensions,the view or clipping volume becomes a clipping window14mydisplay.cvoid mydisplay()glClear(GL_COLOR_BUFFER_BIT);glBegin(GL_POLYGON);glVertex2f(-0.5,-0.5);glVertex2f(-0.5,0.5);glVertex2f(0.5,0.5);glVertex2f(0.5,-0.5);glEnd();glFlush();15OpenGL Primitives16Polygon Issues OpenGL will only display polygons correctly that are Simple:edges cannot cross Convex:All points on line segment between two points in a polygon are also in the polygon Flat:all vertices are in the same plane User program can check if above true OpenGL will produce output if these conditions are violated but it may not be what is desired Triangles satisfy all conditionsnonsimple polygonnonconvex polygonApproximating a Sphere1718AttributesAttributes are part of the OpenGL state and determine the appearance of objects Color(points,lines,polygons)Size and width(points,lines)Stipple pattern(lines,polygons)Polygon mode Display as filled:solid color or stipple pattern Display edges Display vertices19RGB color Each color component is stored separately in the frame buffer Usually 8 bits per component in buffer Note in glColor3f the color values range from 0.0(none)to 1.0(all),whereas in glColor3ub the values range from 0 to 25520Indexed ColorColors are indices into tables of RGB valuesRequires less memory indices usually 8 bits not as important now Memory inexpensive Need more colors for shadin

    注意事项

    本文(计算机图形学computergraphics课件5.ppt)为本站会员(p**)主动上传,第壹文秘仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知第壹文秘(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 1wenmi网站版权所有

    经营许可证编号:宁ICP备2022001189号-1

    本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。第壹文秘仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知第壹文秘网,我们立即给予删除!

    收起
    展开