Show / Hide Table of Contents

Class GLControl

OpenGL-aware WinForms control. The WinForms designer will always call the default constructor. Inherit from this class and call one of its specialized constructors to enable antialiasing or custom GraphicsModes.

Inheritance
UserControl
GLControl
Namespace: OpenTK
Assembly: cs.temp.dll.dll
Syntax
public class GLControl : UserControl

Constructors

GLControl()

Constructs a new instance.

Declaration
public GLControl()

GLControl(GraphicsMode)

Constructs a new instance with the specified GraphicsMode.

Declaration
public GLControl(GraphicsMode mode)
Parameters
Type Name Description
GraphicsMode mode

The OpenTK.Graphics.GraphicsMode of the control.

GLControl(GraphicsMode, Int32, Int32, GraphicsContextFlags)

Constructs a new instance with the specified GraphicsMode.

Declaration
public GLControl(GraphicsMode mode, int major, int minor, GraphicsContextFlags flags)
Parameters
Type Name Description
GraphicsMode mode

The OpenTK.Graphics.GraphicsMode of the control.

System.Int32 major

The major version for the OpenGL GraphicsContext.

System.Int32 minor

The minor version for the OpenGL GraphicsContext.

GraphicsContextFlags flags

The GraphicsContextFlags for the OpenGL GraphicsContext.

Properties

AspectRatio

Gets the aspect ratio of this GLControl.

Declaration
public float AspectRatio { get; }
Property Value
Type Description
System.Single

Context

Gets the IGraphicsContext instance that is associated with the GLControl. The associated IGraphicsContext is updated whenever the GLControl handle is created or recreated. When using multiple GLControls, ensure that Context is current before performing any OpenGL operations. MakeCurrent()

Declaration
public IGraphicsContext Context { get; }
Property Value
Type Description
IGraphicsContext

CreateParams

Gets the CreateParams instance for this GLControl

Declaration
protected override CreateParams CreateParams { get; }
Property Value
Type Description
CreateParams

GraphicsMode

Gets the GraphicsMode of the IGraphicsContext associated with this GLControl. If you wish to change GraphicsMode, you must destroy and recreate the GLControl.

Declaration
public GraphicsMode GraphicsMode { get; }
Property Value
Type Description
GraphicsMode

HasValidContext

Gets a value indicating whether [failed to create OpenGL context]. So that the application stays running and is able to recover.

Declaration
public bool HasValidContext { get; }
Property Value
Type Description
System.Boolean

true if [failed create context]; otherwise, false.

IsIdle

Gets a value indicating whether the current thread contains pending system messages.

Declaration
public bool IsIdle { get; }
Property Value
Type Description
System.Boolean

VSync

Gets or sets a value indicating whether vsync is active for this GLControl. When using multiple GLControls, ensure that Context is current before accessing this property. Context MakeCurrent()

Declaration
public bool VSync { get; set; }
Property Value
Type Description
System.Boolean

WindowInfo

Gets the IWindowInfo for this instance.

Declaration
public IWindowInfo WindowInfo { get; }
Property Value
Type Description
IWindowInfo

Methods

Dispose(Boolean)

Clean up any resources being used.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing

true if managed resources should be disposed; otherwise, false.

MakeCurrent()

Makes Context current in the calling thread. All OpenGL commands issued are hereafter interpreted by this context.

When using multiple GLControls, calling MakeCurrent on one control will make all other controls non-current in the calling thread.

Context

A GLControl can only be current in one thread at a time. To make a control non-current, call GLControl.Context.MakeCurrent(null).

Declaration
public void MakeCurrent()

OnHandleCreated(EventArgs)

Raises the HandleCreated event.

Declaration
protected override void OnHandleCreated(EventArgs e)
Parameters
Type Name Description
System.EventArgs e

Not used.

OnHandleDestroyed(EventArgs)

Raises the HandleDestroyed event.

Declaration
protected override void OnHandleDestroyed(EventArgs e)
Parameters
Type Name Description
System.EventArgs e

Not used.

OnPaint(PaintEventArgs)

Raises the System.Windows.Forms.Control.Paint event.

Declaration
protected override void OnPaint(PaintEventArgs e)
Parameters
Type Name Description
PaintEventArgs e

A System.Windows.Forms.PaintEventArgs that contains the event data.

OnParentChanged(EventArgs)

Raises the ParentChanged event.

Declaration
protected override void OnParentChanged(EventArgs e)
Parameters
Type Name Description
System.EventArgs e

A System.EventArgs that contains the event data.

OnResize(EventArgs)

Raises the Resize event. Note: this method may be called before the OpenGL context is ready. Check that IsHandleCreated is true before using any OpenGL methods.

Declaration
protected override void OnResize(EventArgs e)
Parameters
Type Name Description
System.EventArgs e

A System.EventArgs that contains the event data.

PerformContextUpdate()

Execute the delayed context update

Declaration
public void PerformContextUpdate()

SwapBuffers()

Swaps the front and back buffers, presenting the rendered scene to the screen. This method will have no effect on a single-buffered GraphicsMode.

Declaration
public void SwapBuffers()
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX