The wglCreateLayerContext function creates a new OpenGL rendering context for drawing to a specified layer plane on a device context.
HGLRC wglCreateLayerContext(
HDC hdc, // device context used for a rendering context
int iLayerPlane // specifies the layer plane that a rendering
// context is bound to
);
If the function succeeds, the return value is a handle to an OpenGL rendering context.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
A rendering context is a port through which all OpenGL commands pass. Every thread that makes OpenGL calls must have one current, active rendering context. A rendering context is not the same as a device context; a rendering context contains information specific to OpenGL, while a device context contains information specific to GDI.
Before you create a rendering context, set the pixel format of the device context with the SetPixelFormat function. You can use a rendering context in a specified layer plane of a window with identical pixel formats only.
With OpenGL applications that use multiple threads, you create a rendering context, select it as the current rendering context of a thread, and make OpenGL calls for the specified thread. When you are finished with the rendering context of the thread, call the wglDeleteContext function. The following code example shows how to use wglCreateLayerContext.
// The following code fragment shows how to render to overlay 1
// This example assumes that the pixel format of hdc includes
// overlay plane 1
HDC hdc;
HGLRC;
// create a rendering context for overlay plane 1
hglrc = wglCreateLayerContext(hdc, 1);
// make it the calling thread's current rendering context
wglMakeCurrent(hdc, hglrc);
// call OpenGL functions here. . .
// when the rendering context is no longer needed. . .
// make the rendering context not current
wglMakeCurrent(NULL, NULL);
// delete the rendering context
wglDeleteContext(hglrc);
Windows NT: Use version 3.5 and later.
Windows: Use Windows 95 and later.
Windows CE: Unsupported.
Header: Declared in wingdi.h.
Import Library: Link with opengl32.lib.
OpenGL on Windows NT and Windows 95 Overview, WGL Functions, PIXELFORMATDESCRIPTOR, SetPixelFormat, wglCreateContext, wglDeleteContext, wglGetCurrentContext, wglGetCurrentDC, wglMakeCurrent