快捷搜索:

《基于MFC的OpenGL编程》Part 2 Setting up OpenGL on Win

源代码下载: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.0

1, 首先下载必要的GLUT头文件,DLL和Lib文件,下载链接: glutdlls37beta.zip (149 kilobytes),解压缩后把gltu.h放到"VC98/Include/GL"下,把glut.lib和glut32.lib放到"VC9/Lib" 下,glut32.dll和glut.dll放到你创建的利用法度榜样的运行目录下

2, 创建一个MFC SDI利用法度榜样,在项目属性中加入所必要链接的库文件

1, 在stdafx.h中加入下列语句:2, 打开ClassWizard,选择CCY457OpenGLView类,为下述消息加入消息处置惩罚函数:WM_CREATE (for OnCreate), WM_DESTROY (for OnDestroy), WM_SIZE (for OnSize), WM_ERASEBACKGROUND (for OnEraseBkground).

//OpenGL Headers

#include gl/gl.h>

#include gl/glu.h>

#include gl/glut.h>

#include gl/glaux.h>

您可能还会对下面的文章感兴趣: