The Open Toolkit library  1.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
OpenTK.Graphics.GraphicsContext Class Reference

Represents and provides methods to manipulate an OpenGL render context. More...

+ Inheritance diagram for OpenTK.Graphics.GraphicsContext:

Public Member Functions

 GraphicsContext (GraphicsMode mode, IWindowInfo window)
 Constructs a new GraphicsContext with the specified GraphicsMode and attaches it to the specified window. More...
 
 GraphicsContext (GraphicsMode mode, IWindowInfo window, int major, int minor, GraphicsContextFlags flags)
 Constructs a new GraphicsContext with the specified GraphicsMode, version and flags, and attaches it to the specified window. More...
 
 GraphicsContext (ContextHandle handle, IWindowInfo window)
 Constructs a new GraphicsContext from a pre-existing context created outside of OpenTK. More...
 
 GraphicsContext (ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, int major, int minor, GraphicsContextFlags flags)
 Constructs a new GraphicsContext from a pre-existing context created outside of OpenTK. More...
 
override string ToString ()
 Returns a System.String representing this instance. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
override bool Equals (object obj)
 Compares two instances. More...
 
void SwapBuffers ()
 Swaps buffers on a context. This presents the rendered scene to the user. More...
 
void MakeCurrent (IWindowInfo window)
 Makes the GraphicsContext the current rendering target. More...
 
void Update (IWindowInfo window)
 Updates the graphics context. This must be called when the render target is resized for proper behavior on Mac OS X. More...
 
void LoadAll ()
 Loads all OpenGL entry points. More...
 
void Dispose ()
 Disposes of the GraphicsContext. More...
 

Static Public Member Functions

static GraphicsContext CreateDummyContext ()
 Creates a dummy GraphicsContext to allow OpenTK to work with contexts created by external libraries. More...
 
static GraphicsContext CreateDummyContext (ContextHandle handle)
 Creates a dummy GraphicsContext to allow OpenTK to work with contexts created by external libraries. More...
 
static void Assert ()
 Checks if a GraphicsContext exists in the calling thread and throws a GraphicsContextMissingException if it doesn't. More...
 

Properties

static IGraphicsContext CurrentContext [get]
 Gets the GraphicsContext that is current in the calling thread. More...
 
static bool ShareContexts [get, set]
 Gets or sets a System.Boolean, indicating whether GraphicsContext resources are shared More...
 
static bool DirectRendering [get, set]
 Gets or sets a System.Boolean, indicating whether GraphicsContexts will perform direct rendering. More...
 
bool ErrorChecking [get, set]
 Gets or sets a System.Boolean, indicating whether automatic error checking should be performed. Influences the debug version of OpenTK.dll, only. More...
 
bool IsCurrent [get]
 Gets a System.Boolean indicating whether this instance is current in the calling thread. More...
 
bool IsDisposed [get, set]
 Gets a System.Boolean indicating whether this instance has been disposed. It is an error to access any instance methods if this property returns true. More...
 
bool VSync [get, set]
 [obsolete] Use SwapInterval property instead. Gets or sets a value indicating whether VSync is enabled. When VSync is enabled, SwapBuffers() calls will be synced to the refresh rate of the DisplayDevice that contains improving visual quality and reducing CPU usage. However, systems that cannot maintain the requested rendering rate will suffer from large jumps in performance. This can be counteracted by increasing the SwapInterval value. More...
 
int SwapInterval [get, set]
 Gets or sets a positive integer in the range [1, n), indicating the number of DisplayDevice refreshes between consecutive SwapBuffers() calls. The maximum value for n is implementation-dependent. The default value is 1. This value will only affect instances where VSync is enabled. Invalid values will be clamped to the valid range. More...
 
GraphicsMode GraphicsMode [get]
 Gets the GraphicsMode of the context. More...
 
- Properties inherited from OpenTK.Graphics.IGraphicsContext
bool IsCurrent [get]
 Gets a System.Boolean indicating whether this instance is current in the calling thread. More...
 
bool IsDisposed [get]
 Gets a System.Boolean indicating whether this instance has been disposed. It is an error to access any instance methods if this property returns true. More...
 
bool VSync [get, set]
 Gets or sets a value indicating whether VSync is enabled. When VSync is enabled, SwapBuffers() calls will be synced to the refresh rate of the DisplayDevice that contains improving visual quality and reducing CPU usage. However, systems that cannot maintain the requested rendering rate will suffer from large jumps in performance. This can be counteracted by increasing the SwapInterval value. More...
 
int SwapInterval [get, set]
 Gets or sets a positive integer in the range [1, n), indicating the number of DisplayDevice refreshes between consecutive SwapBuffers() calls. The maximum value for n is implementation-dependent. The default value is 1. This value will only affect instances where VSync is enabled. Invalid values will be clamped to the valid range. More...
 
GraphicsMode GraphicsMode [get]
 Gets the GraphicsMode of this instance. More...
 
bool ErrorChecking [get, set]
 Gets or sets a System.Boolean, indicating whether automatic error checking should be performed. More...
 
- Properties inherited from OpenTK.Graphics.IGraphicsContextInternal
IGraphicsContext Implementation [get]
 Gets the internal implementation of the current instance. More...
 
ContextHandle Context [get]
 Gets a handle to the OpenGL rendering context. More...
 

Detailed Description

Represents and provides methods to manipulate an OpenGL render context.

Constructor & Destructor Documentation

OpenTK.Graphics.GraphicsContext.GraphicsContext ( GraphicsMode  mode,
IWindowInfo  window 
)

Constructs a new GraphicsContext with the specified GraphicsMode and attaches it to the specified window.

Parameters
modeThe OpenTK.Graphics.GraphicsMode of the GraphicsContext.
windowThe OpenTK.Platform.IWindowInfo to attach the GraphicsContext to.
OpenTK.Graphics.GraphicsContext.GraphicsContext ( GraphicsMode  mode,
IWindowInfo  window,
int  major,
int  minor,
GraphicsContextFlags  flags 
)

Constructs a new GraphicsContext with the specified GraphicsMode, version and flags, and attaches it to the specified window.

Parameters
modeThe OpenTK.Graphics.GraphicsMode of the GraphicsContext.
windowThe OpenTK.Platform.IWindowInfo to attach the GraphicsContext to.
majorThe major version of the new GraphicsContext.
minorThe minor version of the new GraphicsContext.
flagsThe GraphicsContextFlags for the GraphicsContext.

Different hardware supports different flags, major and minor versions. Invalid parameters will be silently ignored.

OpenTK.Graphics.GraphicsContext.GraphicsContext ( ContextHandle  handle,
IWindowInfo  window 
)

Constructs a new GraphicsContext from a pre-existing context created outside of OpenTK.

Parameters
handleThe handle of the existing context. This must be a valid, unique handle that is not known to OpenTK.
windowThe window this context is bound to. This must be a valid window obtained through Utilities.CreateWindowInfo.
Exceptions
GraphicsContextExceptionOccurs if handle is identical to a context already registered with OpenTK.
OpenTK.Graphics.GraphicsContext.GraphicsContext ( ContextHandle  handle,
IWindowInfo  window,
IGraphicsContext  shareContext,
int  major,
int  minor,
GraphicsContextFlags  flags 
)

Constructs a new GraphicsContext from a pre-existing context created outside of OpenTK.

Parameters
handleThe handle of the existing context. This must be a valid, unique handle that is not known to OpenTK.
windowThe window this context is bound to. This must be a valid window obtained through Utilities.CreateWindowInfo.
shareContextA different context that shares resources with this instance, if any. Pass null if the context is not shared or if this is the first GraphicsContext instruct you construct.
majorThe major version of the context (e.g. "2" for "2.1").
minorThe minor version of the context (e.g. "1" for "2.1").
flagsA bitwise combination of GraphicsContextFlags that describe this context.
Exceptions
GraphicsContextExceptionOccurs if handle is identical to a context already registered with OpenTK.

Member Function Documentation

static void OpenTK.Graphics.GraphicsContext.Assert ( )
static

Checks if a GraphicsContext exists in the calling thread and throws a GraphicsContextMissingException if it doesn't.

Exceptions
GraphicsContextMissingExceptionGenerated when no GraphicsContext is current in the calling thread.
static GraphicsContext OpenTK.Graphics.GraphicsContext.CreateDummyContext ( )
static

Creates a dummy GraphicsContext to allow OpenTK to work with contexts created by external libraries.

Returns
A new, dummy GraphicsContext instance.

Instances created by this method will not be functional. Instance methods will have no effect.

This method requires that a context is current on the calling thread.

static GraphicsContext OpenTK.Graphics.GraphicsContext.CreateDummyContext ( ContextHandle  handle)
static

Creates a dummy GraphicsContext to allow OpenTK to work with contexts created by external libraries.

Parameters
handleThe handle of a context.
Returns
A new, dummy GraphicsContext instance.

Instances created by this method will not be functional. Instance methods will have no effect.

void OpenTK.Graphics.GraphicsContext.Dispose ( )

Disposes of the GraphicsContext.

override bool OpenTK.Graphics.GraphicsContext.Equals ( object  obj)

Compares two instances.

Parameters
objThe instance to compare to.
Returns
True, if obj is equal to this instance; false otherwise.
override int OpenTK.Graphics.GraphicsContext.GetHashCode ( )

Returns the hash code for this instance.

Returns
A System.Int32 with the hash code of this instance.
void OpenTK.Graphics.GraphicsContext.LoadAll ( )

Loads all OpenGL entry points.

Exceptions
OpenTK.Graphics.GraphicsContextExceptionOccurs when this instance is not current on the calling thread.

Implements OpenTK.Graphics.IGraphicsContext.

void OpenTK.Graphics.GraphicsContext.MakeCurrent ( IWindowInfo  window)

Makes the GraphicsContext the current rendering target.

Parameters
windowA valid OpenTK.Platform.IWindowInfo structure.

You can use this method to bind the GraphicsContext to a different window than the one it was created from.

Implements OpenTK.Graphics.IGraphicsContext.

void OpenTK.Graphics.GraphicsContext.SwapBuffers ( )

Swaps buffers on a context. This presents the rendered scene to the user.

Implements OpenTK.Graphics.IGraphicsContext.

override string OpenTK.Graphics.GraphicsContext.ToString ( )

Returns a System.String representing this instance.

Returns
A System.String that contains a string representation of this instance.
void OpenTK.Graphics.GraphicsContext.Update ( IWindowInfo  window)

Updates the graphics context. This must be called when the render target is resized for proper behavior on Mac OS X.

Parameters
window

Implements OpenTK.Graphics.IGraphicsContext.

Property Documentation

IGraphicsContext OpenTK.Graphics.GraphicsContext.CurrentContext
staticget

Gets the GraphicsContext that is current in the calling thread.

Note: this property will not function correctly when both desktop and EGL contexts are available in the same process. This scenario is very unlikely to appear in practice.

bool OpenTK.Graphics.GraphicsContext.DirectRendering
staticgetset

Gets or sets a System.Boolean, indicating whether GraphicsContexts will perform direct rendering.

If DirectRendering is true, new contexts will be constructed with direct rendering capabilities, if possible. If DirectRendering is false, new contexts will be constructed with indirect rendering capabilities.

This property does not affect existing GraphicsContexts, unless they are recreated.

This property is ignored on Operating Systems without support for indirect rendering, like Windows and OS X.

bool OpenTK.Graphics.GraphicsContext.ErrorChecking
getset

Gets or sets a System.Boolean, indicating whether automatic error checking should be performed. Influences the debug version of OpenTK.dll, only.

Automatic error checking will clear the OpenGL error state. Set CheckErrors to false if you use the OpenGL error state in your code flow (e.g. for checking supported texture formats).

GraphicsMode OpenTK.Graphics.GraphicsContext.GraphicsMode
get

Gets the GraphicsMode of the context.

bool OpenTK.Graphics.GraphicsContext.IsCurrent
get

Gets a System.Boolean indicating whether this instance is current in the calling thread.

bool OpenTK.Graphics.GraphicsContext.IsDisposed
getset

Gets a System.Boolean indicating whether this instance has been disposed. It is an error to access any instance methods if this property returns true.

bool OpenTK.Graphics.GraphicsContext.ShareContexts
staticgetset

Gets or sets a System.Boolean, indicating whether GraphicsContext resources are shared

If ShareContexts is true, new GLContexts will share resources. If this value is false, new GLContexts will not share resources.

Changing this value will not affect already created GLContexts.

int OpenTK.Graphics.GraphicsContext.SwapInterval
getset

Gets or sets a positive integer in the range [1, n), indicating the number of DisplayDevice refreshes between consecutive SwapBuffers() calls. The maximum value for n is implementation-dependent. The default value is 1. This value will only affect instances where VSync is enabled. Invalid values will be clamped to the valid range.

bool OpenTK.Graphics.GraphicsContext.VSync
getset

[obsolete] Use SwapInterval property instead. Gets or sets a value indicating whether VSync is enabled. When VSync is enabled, SwapBuffers() calls will be synced to the refresh rate of the DisplayDevice that contains improving visual quality and reducing CPU usage. However, systems that cannot maintain the requested rendering rate will suffer from large jumps in performance. This can be counteracted by increasing the SwapInterval value.