Tao.Platform.Windows SDK Documentation

Wgl.wglCreateLayerContext Method 

The wglCreateLayerContext function creates a new OpenGL rendering context for drawing to a specified layer plane on a device context.

[Visual Basic]
Public Shared Function wglCreateLayerContext( _
   ByVal deviceContext As IntPtr, _
   ByVal layerPlane As Integer _
) As IntPtr
[C#]
public static IntPtr wglCreateLayerContext(
   IntPtr deviceContext,
   int layerPlane
);

Parameters

deviceContext

Specifies the device context for a new rendering context.

layerPlane

Specifies the layer plane to which you want to bind a rendering context. The value 0 identifies the main plane. Positive values of layerPlane identify overlay planes, where 1 is the first overlay plane over the main plane, 2 is the second overlay plane over the first overlay plane, and so on. Negative values identify underlay planes, where ?–1 is the first underlay plane under the main plane, ?–2 is the second underlay plane under the first underlay plane, and so on. The number of overlay and underlay planes is given in the bReserved member of the Gdi.PIXELFORMATDESCRIPTOR structure.

Return Value

If the function succeeds, the return value is a handle to an OpenGL rendering context.

If the function fails, the return lue is Zero. To get extended error information, call GetLastWin32Error.

Remarks

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
            IntPtr hdc;
            IntPtr hglrc;
            // create a rendering context for overlay plane 1
            hglrc = Wgl.wglCreateLayerContext(hdc, 1);
            // make it the calling thread's current rendering context
            Wgl.wglMakeCurrent(hdc, hglrc);
            // call OpenGL functions here...
            // when the rendering context is no longer needed...
            // make the rendering context not current
            Wgl.wglMakeCurrent(IntPtr.Zero, IntPtr.Zero);
            // delete the rendering context
            Wgl.wglDeleteContext(hglrc);
            

See Also

Wgl Class | Tao.Platform.Windows Namespace | Gdi.PIXELFORMATDESCRIPTOR | SetPixelFormat | wglCreateContext | wglDeleteContext | wglGetCurrentContext | wglGetCurrentDC | wglMakeCurrent