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中加入下列語句:
//OpenGL Headers
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#include <gl/glaux.h>