The Open Toolkit library  1.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Member Functions | Protected Member Functions | Properties | List of all members
OpenTK.GLControl Class Reference

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. More...

Inherits UserControl.

Public Member Functions

 GLControl ()
 Constructs a new instance. More...
 
 GLControl (GraphicsMode mode)
 Constructs a new instance with the specified GraphicsMode. More...
 
 GLControl (GraphicsMode mode, int major, int minor, GraphicsContextFlags flags)
 Constructs a new instance with the specified GraphicsMode. More...
 
void 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. More...
 
void MakeCurrent ()
 
Bitmap GrabScreenshot ()
 Grabs a screenshot of the frontbuffer contents. When using multiple GLControls, ensure that Context is current before accessing this property.

See Also
Context, MakeCurrent
More...
 

Protected Member Functions

override void OnHandleCreated (EventArgs e)
 Raises the HandleCreated event. More...
 
override void OnHandleDestroyed (EventArgs e)
 Raises the HandleDestroyed event. More...
 
override void OnPaint (PaintEventArgs e)
 Raises the System.Windows.Forms.Control.Paint event. More...
 
override void OnResize (EventArgs e)
 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. More...
 
override void OnParentChanged (EventArgs e)
 Raises the ParentChanged event. More...
 
override void Dispose (bool disposing)
 Clean up any resources being used. More...
 

Properties

override CreateParams CreateParams [get]
 Gets the CreateParams instance for this GLControl More...
 
bool IsIdle [get]
 Gets a value indicating whether the current thread contains pending system messages. More...
 
IGraphicsContext Context [get, set]
 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.

See Also
MakeCurrent
More...
 
float AspectRatio [get]
 Gets the aspect ratio of this GLControl. More...
 
bool VSync [get, set]
 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.

See Also
Context, MakeCurrent
More...
 
GraphicsMode GraphicsMode [get]
 Gets the GraphicsMode of the IGraphicsContext associated with this GLControl. If you wish to change GraphicsMode, you must destroy and recreate the GLControl. More...
 
IWindowInfo WindowInfo [get]
 Gets the OpenTK.Platform.IWindowInfo for this instance. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

OpenTK.GLControl.GLControl ( )

Constructs a new instance.

OpenTK.GLControl.GLControl ( GraphicsMode  mode)

Constructs a new instance with the specified GraphicsMode.

Parameters
modeThe OpenTK.Graphics.GraphicsMode of the control.
OpenTK.GLControl.GLControl ( GraphicsMode  mode,
int  major,
int  minor,
GraphicsContextFlags  flags 
)

Constructs a new instance with the specified GraphicsMode.

Parameters
modeThe OpenTK.Graphics.GraphicsMode of the control.
majorThe major version for the OpenGL GraphicsContext.
minorThe minor version for the OpenGL GraphicsContext.
flagsThe GraphicsContextFlags for the OpenGL GraphicsContext.

Member Function Documentation

override void OpenTK.GLControl.Dispose ( bool  disposing)
protected

Clean up any resources being used.

Parameters
disposingtrue if managed resources should be disposed; otherwise, false.
Bitmap OpenTK.GLControl.GrabScreenshot ( )

Grabs a screenshot of the frontbuffer contents. When using multiple GLControls, ensure that Context is current before accessing this property.

See Also
Context, MakeCurrent

Returns
A System.Drawing.Bitmap, containing the contents of the frontbuffer.
Exceptions
OpenTK.Graphics.GraphicsContextExceptionOccurs when no OpenTK.Graphics.GraphicsContext is current in the calling thread.
void OpenTK.GLControl.MakeCurrent ( )

Makes GLControl.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.

See Also
Context

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

override void OpenTK.GLControl.OnHandleCreated ( EventArgs  e)
protected

Raises the HandleCreated event.

Parameters
eNot used.
override void OpenTK.GLControl.OnHandleDestroyed ( EventArgs  e)
protected

Raises the HandleDestroyed event.

Parameters
eNot used.
override void OpenTK.GLControl.OnPaint ( PaintEventArgs  e)
protected

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

Parameters
eA System.Windows.Forms.PaintEventArgs that contains the event data.
override void OpenTK.GLControl.OnParentChanged ( EventArgs  e)
protected

Raises the ParentChanged event.

Parameters
eA System.EventArgs that contains the event data.
override void OpenTK.GLControl.OnResize ( EventArgs  e)
protected

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.

Parameters
eA System.EventArgs that contains the event data.
void OpenTK.GLControl.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.

Property Documentation

float OpenTK.GLControl.AspectRatio
get

Gets the aspect ratio of this GLControl.

IGraphicsContext OpenTK.GLControl.Context
getset

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.

See Also
MakeCurrent

override CreateParams OpenTK.GLControl.CreateParams
getprotected

Gets the CreateParams instance for this GLControl

GraphicsMode OpenTK.GLControl.GraphicsMode
get

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

bool OpenTK.GLControl.IsIdle
get

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

bool OpenTK.GLControl.VSync
getset

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.

See Also
Context, MakeCurrent

IWindowInfo OpenTK.GLControl.WindowInfo
get

Gets the OpenTK.Platform.IWindowInfo for this instance.