Export (0) Print
Expand All


The wglCopyContext function copies selected groups of rendering states from one OpenGL rendering context to another.

BOOL wglCopyContext(
  HGLRC  hglrcSrc,  // specifies the source of a rendering context
  HGLRC  hglrcDst,  // specifies the destination of a rendering 
                    // context
  UINT  mask        // specifies what rendering state information is 
                    // copied


Specifies the source OpenGL rendering context whose state information is to be copied.
Specifies the destination OpenGL rendering context to which state information is to be copied.
Specifies which groups of the hglrcSrc rendering state are to be copied to hglrcDst. It contains the bitwise-OR of the same symbolic names that are passed to the glPushAttrib function. You can use GL_ALL_ATTRIB_BITS to copy all the rendering state information.

Return Values

If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. To get extended error information, call GetLastError.


Using the wglCopyContext function, you can synchronize the rendering state of two rendering contexts. You can only copy the rendering state between two rendering contexts within the same process. The rendering contexts must be from the same OpenGL implementation. For example, you can always copy a rendering state between two rendering contexts with identical pixel format in the same process.

You can copy the same state information available only with the glPushAttrib function. You cannot copy some state information, such as pixel pack/unpack state, render mode state, select state, and feedback state. When you call wglCopyContext, make sure that the destination rendering context, hglrcDst, is not current to any thread.


  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in wingdi.h.
  Import Library: Use opengl32.lib.

See Also

OpenGL on Windows NT, Windows 2000, and Windows 95/98, WGL Functions, glPushAttrib, wglCreateLayerContext, wglCreateContext, wglShareLists


Community Additions

© 2014 Microsoft