基于MFC的OpenGL编程

上传人:飞*** 文档编号:28704145 上传时间:2018-01-19 格式:DOC 页数:103 大小:823KB
返回 下载 相关 举报
基于MFC的OpenGL编程_第1页
第1页 / 共103页
基于MFC的OpenGL编程_第2页
第2页 / 共103页
基于MFC的OpenGL编程_第3页
第3页 / 共103页
基于MFC的OpenGL编程_第4页
第4页 / 共103页
基于MFC的OpenGL编程_第5页
第5页 / 共103页
点击查看更多>>
资源描述

《基于MFC的OpenGL编程》由会员分享,可在线阅读,更多相关《基于MFC的OpenGL编程(103页珍藏版)》请在金锄头文库上搜索。

1、光荣在于平淡,艰巨因为漫长基于 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, Translatio

2、ns 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 的 O

3、penGL 编程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 o

4、bjects 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 an

5、d 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 c

6、an 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 techniqu

7、e 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 vie

8、wer. 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 scre

9、en 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

10、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_BUFFE

11、R_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);/绘制回调函数,当窗口需要绘制时,G

12、LUT 会调用此函数 /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.)

13、 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,

14、 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

15、 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

16、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

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号