26.4. OpenGL code in Windows

OpenGL is a platform-neutral library. It can run on operating systems such as X-Windows, the Macintosh, or Windows. In each of these systems you add a little extra code in order to interface your system to OpenGL.

The basic Win32 library includes a few built-in data types and functions to be used with OpenGL. Here’s a block of code that shows how we initialize a window and update it. The data types PIXELFORMATDESCRIPTOR and HGLR are special built-in Windows types used for working with OpenGL. And ::ChoosePixelFormat, ::SelectPixelFormat, ::wglCreateContext, and ::SwapBuffers are built-in Windows methods for use with OpenGL.

 PIXELFORMATDESCRIPTOR pixelformat; int pixelformat_index; HGLR openglrenderingcontext; HDC ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.