Class OpenGLComponent
Inherited Members
Namespace: OpenTK.Platform.Native.Windows
Assembly: OpenTK.Platform.dll
Syntax
public class OpenGLComponent : IOpenGLComponent, IPalComponent
Properties
CanCreateFromSurface
True if the component driver can create a context from surfaces using CreateFromSurface().
Declaration
public bool CanCreateFromSurface { get; }
Property Value
Type | Description |
---|---|
bool |
CanCreateFromWindow
True if the component driver can create a context from windows using CreateFromWindow(WindowHandle).
Declaration
public bool CanCreateFromWindow { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
CanShareContexts
True if the component driver has the capability to share display lists between OpenGL contexts.
Declaration
public bool CanShareContexts { get; }
Property Value
Type | Description |
---|---|
bool |
Logger
The logger that this component uses to log diagnostic messages.
Declaration
public ILogger? Logger { get; set; }
Property Value
Type | Description |
---|---|
ILogger |
See Also
Name
Name of the abstraction layer component.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
Provides
Specifies which PAL components this object provides.
Declaration
public PalComponents Provides { get; }
Property Value
Type | Description |
---|---|
PalComponents |
Methods
CreateFromSurface()
Create and OpenGL context for a surface.
Declaration
public OpenGLContextHandle CreateFromSurface()
Returns
Type | Description |
---|---|
OpenGLContextHandle | An OpenGL context handle. |
CreateFromWindow(WindowHandle)
Create an OpenGL context for a window.
Declaration
public OpenGLContextHandle CreateFromWindow(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window for which the OpenGL context should be created. |
Returns
Type | Description |
---|---|
OpenGLContextHandle | An OpenGL context handle. |
See Also
DestroyContext(OpenGLContextHandle)
Destroy an OpenGL context.
Declaration
public void DestroyContext(OpenGLContextHandle handle)
Parameters
Type | Name | Description |
---|---|---|
OpenGLContextHandle | handle | Handle to the OpenGL context to destroy. |
See Also
GetBindingsContext(OpenGLContextHandle)
Gets a IBindingsContext from an OpenGLContextHandle. Pass this to LoadBindings(IBindingsContext) to load the OpenGL bindings.
Declaration
public IBindingsContext GetBindingsContext(OpenGLContextHandle handle)
Parameters
Type | Name | Description |
---|---|---|
OpenGLContextHandle | handle | The handle to get a bindings context for. |
Returns
Type | Description |
---|---|
IBindingsContext | The created bindings context. |
See Also
GetCurrentContext()
Get the current OpenGL context for this thread.
Declaration
public OpenGLContextHandle? GetCurrentContext()
Returns
Type | Description |
---|---|
OpenGLContextHandle | Handle to the current OpenGL context, null if no context is current. |
See Also
GetHGLRC(OpenGLContextHandle)
Gets the win32 HGLRC
opengl context handle associated with the context.
This OpenGL context is associated with the window or surface that was used to create this context.
Modifying the context outsite of OpenTK functions may cause side effects when calling OpenTK functions.
Declaration
public nint GetHGLRC(OpenGLContextHandle handle)
Parameters
Type | Name | Description |
---|---|---|
OpenGLContextHandle | handle | The OpenGL context to get the associated win32 |
Returns
Type | Description |
---|---|
nint | The native |
GetProcedureAddress(OpenGLContextHandle, string)
Get the procedure address for an OpenGL command.
Declaration
public nint GetProcedureAddress(OpenGLContextHandle handle, string procedureName)
Parameters
Type | Name | Description |
---|---|---|
OpenGLContextHandle | handle | Handle to an OpenGL context. |
string | procedureName | Name of the OpenGL command. |
Returns
Type | Description |
---|---|
nint | The procedure address to the OpenGL command. |
GetSharedContext(OpenGLContextHandle)
Gets the context which the given context shares display lists with.
Declaration
public OpenGLContextHandle? GetSharedContext(OpenGLContextHandle handle)
Parameters
Type | Name | Description |
---|---|---|
OpenGLContextHandle | handle | Handle to the OpenGL context. |
Returns
Type | Description |
---|---|
OpenGLContextHandle | Handle to the OpenGL context the given context shares display lists with. |
See Also
GetSwapInterval()
Gets the swap interval of the current OpenGL context, or -1
if no context is current.
Declaration
public int GetSwapInterval()
Returns
Type | Description |
---|---|
int | The current swap interval, or |
Initialize(ToolkitOptions)
Initialize the component.
Declaration
public void Initialize(ToolkitOptions options)
Parameters
Type | Name | Description |
---|---|---|
ToolkitOptions | options | The options to initialize the component with. |
See Also
SetCurrentContext(OpenGLContextHandle?)
Set the current OpenGL context for this thread.
Declaration
public bool SetCurrentContext(OpenGLContextHandle? handle)
Parameters
Type | Name | Description |
---|---|---|
OpenGLContextHandle | handle | Handle to the OpenGL context to make current, or null to make no context current. |
Returns
Type | Description |
---|---|
bool | true when the OpenGL context is successfully made current. |
See Also
SetSwapInterval(int)
Sets the swap interval of the current OpenGL context.
Declaration
public void SetSwapInterval(int interval)
Parameters
Type | Name | Description |
---|---|---|
int | interval | The new swap interval. |
SwapBuffers(OpenGLContextHandle)
Swaps the buffer of the specified context.
Declaration
public void SwapBuffers(OpenGLContextHandle handle)
Parameters
Type | Name | Description |
---|---|---|
OpenGLContextHandle | handle | Handle to the context. |
See Also
Uninitialize()
Uninitialize the component. Frees any native resources used by the component.
Declaration
public void Uninitialize()
See Also
UseDwmFlushIfApplicable(OpenGLContextHandle, bool)
Sets whether calls to SwapBuffers(OpenGLContextHandle) should use DwmFlush()
to sync if DWM compositing is enabled.
This can improve vsync performance on systems with multiple monitors using different refresh rates, but is likely to break in a multi-window scenario.
If using multiple windows, only one window should have this property set.
By default this value is set to false
.
Declaration
public void UseDwmFlushIfApplicable(OpenGLContextHandle handle, bool enable)
Parameters
Type | Name | Description |
---|---|---|
OpenGLContextHandle | handle | The OpenGL context that should |
bool | enable | Whether to enable |