MFC based OpenGL programming Part 2 Setting up OpenGL on Windows

Source: Internet
Author: User

Wgl–windows OpenGL Expansion Layer

The WGL extension consists of a set of functions (Wglcreatecontext, Wgldeletecontext etc.) and structures (such as Pixelfo Rmatdescriptor, glyphmetricsfloat) etc. Thus every OpenGL implementation has a platform-specific portion which has to is set up and used according to the Particul AR platform.

Device context

The Windows graphical Device Interface (GDI) is capable of drawing to screens, to memory, to printers or to no other Devic E that provides a GDI interface layer and that can process GDI calls. GDI accomplishes this by a rendering handle to the currently selected device, or DC, which the called.

Drawing context

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 format

Pixel formats are the translation layer between OpenGL calls and the rendering operation that Windows performs.

For example, if the pixel format supports only a very small number of color values, OpenGL may draw with the converted value (128,128,128) when it draws a pixel with an RGB value (128,120,135).

The pixel format selected essentially describes such things as how colors are, displayed of field depth and resolution T additional capabilities are supported by the rendering context created.

The first OpenGL application based on MFC

Development environment: VC6.0

1, first download the required Glut header file, DLL and lib file, download link: glutdlls37beta.zip (149 kilobytes), decompression after the gltu.h into the "VC98/INCLUDE/GL", Put Glut.lib and Glut32.lib under "Vc9/lib", Glut32.dll and Glut.dll into the running directory of the application you created

2, create an MFC SDI application, add the required linked library files to the project properties

1, add the following statement to the stdafx.h:

OpenGL Headers
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#include <gl/glaux.h>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.