DGL

OpenGL rendering context on Windows.

License
Boost License 1.0.
Authors
Denis Shelomovskij

class  WGLContext;

Represents OpenGL rendering context on Windows.

Warning:
Its contruction relies on an assumption the same ICD driver is used for sequential rendering context creation on different accelerated pixel formats.

this(in ContextCreationInfo creationInfo);

Creates a new rendering context with desired context & framebuffer configuration using internal dummy window.

Note:
Context created with this constructor should be disposed in its creation thread.
Preconditions:
creationInfo is valid.

this(in ContextCreationInfo creationInfo, HDC dcHandle);

Creates a new rendering context with desired context & framebuffer configuration using dcHandle.

Preconditions:
creationInfo is valid. dcHandle is a handle to a device context suitable for rendering context creation. Device context pixel format isn't set.

this(in ContextConfig config, HDC dcHandle);

Creates a new rendering context with desired configuration using dcHandle with choosen pixel format.

Preconditions:
config is valid. dcHandle is a handle to a device context suitable for rendering context creation. Device context pixel format is set to a pixel format with OpenGL support.

const pure nothrow @property bool  disposed();

Gets whether the rendering context is disposed.


inout pure nothrow @property inout(HGLRC)  handle();

Gets the rendering context handle.


const pure nothrow @property ContextConfig  config();

Gets the rendering context configuration.

See dgl.config.ContextConfig.


const pure nothrow @property FramebufferConfig  framebufferConfig();

Gets the rendering context framebuffer configuration.

See dgl.config.FramebufferConfig.


const pure nothrow @property int  pixelFormat();

Gets the rendering context pixel format index.

The rendering context is suitable for using with any device context sharing this pixel format and created on the same device.


const void  setThisPixelFormat(HDC dcHandle);

Sets device context's pixel format to this rendering context pixel format.


void  makeCurrent(HDC dcHandle);

Makes the rendering context the calling thread's current rendering context using dcHandle.

Preconditions:
dcHandle is a handle to a device context sharing this rendering context's pixel format.

const @property bool  isCurrent();

Returns wheter this rendering context is the calling thread's current rendering context.


static @property HGLRC  currentHandle();

Gets the handle to the calling thread's current rendering context.


static void  releaseCurrent();

Makes the calling thread's current rendering context no longer current and releases the device context that is used by the rendering context.


static void  swapBuffers(HDC dcHandle, in bool wait = true);

Swaps device context color buffers.

If wait is true also waits using glFinish for actual swap to take effect.

Note:
Setting wait to false may cause flickering on control resizing.

const @property bool  controlableSwapInterval();

Returns wheter the rendering context support setting a swap interval.

Swap interval is a minimum number of video frame periods per buffer swap.

See EXT_swap_control extension.


const @property bool  hasAdaptiveSwapInterval();

Returns wheter the rendering context support setting a negative swap interval meaning late swaps occur without synchronization to the video frame.

See EXT_swap_control_tear extension.


@property void  dcSwapInterval(in int interval);
const @property int  dcSwapInterval();

Gets or sets current device context's swap interval.

Preconditions:
isCurrent && controlableSwapInterval. If interval is negative hasAdaptiveSwapInterval is also required.

void  dispose();

Releases all resources used by this class instance.

Deletes the rendering context preliminarily releasing it if it's the calling thread's current rendering context. Also deletes the internal dummy window if it was created.

This function will be called by destructor if not already disposed.

Preconditions:
!disposed