《基於MFC的OpenGL編程》Part 2 Setting up OpenGL on Windows

來源:互聯網
上載者:User

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>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.