资源预览内容
第1页 / 共103页
第2页 / 共103页
第3页 / 共103页
第4页 / 共103页
第5页 / 共103页
第6页 / 共103页
第7页 / 共103页
第8页 / 共103页
第9页 / 共103页
第10页 / 共103页
亲,该文档总共103页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
光荣在于平淡,艰巨因为漫长基于 MFC 的 OpenGL 编程系列文章 1, 基于 MFC 的 OpenGL 编程Part 1 A Primer2, 基于 MFC 的 OpenGL 编程Part 2 Setting up OpenGL on Windows3, 基于 MFC 的 OpenGL 编程Part 3 Drawing Simple 2D Shapes4, 基于 MFC 的 OpenGL 编程Part 4 Drawing Simple 3D objects5, 基于 MFC 的 OpenGL 编程Part 5 Transformations - Rotations, Translations and Scaling6, 基于 MFC 的 OpenGL 编程Part 6 Keyboard and Mouse Control 7, 基于 MFC 的 OpenGL 编程Part 7 Animation 8, 基于 MFC 的 OpenGL 编程Part 8 Colors 9, 基于 MFC 的 OpenGL 编程Part 9 Lighting 10, 基于 MFC 的 OpenGL 编程Part 10 Texture Mapping 11, 基于 MFC 的 OpenGL 编程Part 11 Blending, Antialiasing and Fog 12, 基于 MFC 的 OpenGL 编程Part 12 Creating and Using Display Lists 13, 基于 MFC 的 OpenGL 编程Part 13 Creating 2D and 3D Text 14, 基于 MFC 的 OpenGL 编程Part 14 Quadrics 15, 基于 MFC 的 OpenGL 编程Part 15 Selection 16, 基于 MFC 的 OpenGL 编程Part 16 Reflection 17, 基于 MFC 的 OpenGL 编程Part 17 Shadows 18, 基于 MFC 的 OpenGL 编程Part 18 Reading objects from the OBJ File Format 19, 基于 MFC 的 OpenGL 编程Part 19 Creating a Virtual Reality Walkthrough Application 2 0 (请您对文章做出评价)光荣在于平淡,艰巨因为漫长基于 MFC 的 OpenGL 编程Part 1 A Primer 3D 图形学基本概念PerspectivePerspective refers to the angles between the lines that lend the illusion of three dimensions. Colors and ShadingMoving beyond line drawing, we need to add color to create a solid object. Shading refers to the way the color is applied to the polygon. Shading can be of two types in OpenGL - Flat or Smooth.Lights and ShadowsPlain solid color doesnt offer enough realism. By applying Lighting effects we can make objects appear as they would in reality depending on their material properties and the lighting parameters. Adding a shadow further increases realism.Texture MappingWith Texture Mapping we can have wood grains, cloth textures, brick like textures etc instead of plain materials. This technique of applying an image to the surface of a polygon is called Texture Mapping. The image we use is called the Texture and the individual elements of the texture are called Texels.FogFog is an atmospheric effect that adds haziness to objects in a scene depending on how far the objects are from the viewer. Blending and TransparencyBlending is the combination of colors of objects on the screen. This effect can be used for a variety of purposes. By varying the amount each object is blended with the scene we can make objects look transparent.Anti-AliasingAliasing is an effect that is visible on screen due to the fact that an image consists of discrete pixels. By carefully blending the lines with the background color we can eliminate jagged edges and give them a smooth appearance. This blending technique is called anti-aliasing. 第一个 OpenGL 程序/Simple.cpp - First OpenGL Program#include /Required for every Windows Program#include /Required for using the GLUT library /Perform OpenGL Initialization here void SetupRC()/Set the background clearing color to blueglClearColor(0.0f,0.0f,1.0f,1.0f);/设置背景色为蓝色/The drawing callback functionvoid RenderScene()/Clear the color buffer glClear(GL_COLOR_BUFFER_BIT);/Flush the rendering pipelineglFlush();void main()/Choose the display mode settingsglutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);/初始化显示模式( 单缓冲,RGB)/Create the WindowglutCreateWindow(Simple);/创建窗口/Set the RenderScsne function as the display callbackglutDisplayFunc(RenderScene);/绘制回调函数,当窗口需要绘制时,GLUT 会调用此函数 /Initialize OpenGLSetupRC();/初始化 OpenGL/Start the GLUT frameworkglutMainLoop();/开始消息循环光荣在于平淡,艰巨因为漫长基于 MFC 的 OpenGL 编程Part 2 Setting up OpenGL on Windows 源代码下载:OpenGL_ch2.rar WGL Windows 的 OpenGL 扩展层 The WGL extension consists of a set of functions (wglCreateContext, wglDeleteContext etc.) and structures (such as PIXELFORMATDESCRIPTOR, GLYPHMETRICSFLOAT) etc. Thus every OpenGL implementation has a platform-specific portion which has to be set up and used according to the particular platform. 设备上下文The Windows Graphical Device Interface (GDI) is capable of drawing to screen, to memory, to printers or to any other device that provides a GDI interface layer and that can process GDI calls. GDI accomplishes this by a rendering handle to the currently selected device, which is called the device context, or DC. 绘制上下文A rendering context is the OpenGL equivalent of the GDI DC. All OpenGL calls are rendered to the device through a RC. The rendering context maintains OpenGL state variables such as current background color, current color etc. just as the DC maintains GDI state variables such as current pen, current brush etc. 像素格式Pixel formats are the translation layer between OpenGL calls and the rendering operation that Windows performs. 举个例子,若像素格式只支持很少一部分颜色值,则 OpenGL 在用 RGB值(128,120,135)绘制一个像素时,就可能使用转换后的值(128,128,128)来绘制. The pixel format selected essentially describes such things as how colors are displayed, depth of field resolution and what additional capabilities are supported by the rendering context created. 第一个基于 MFC 的 OpenGL 应用程开发环境:VC6.01, 首先下载需要的 GL
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号