The Open Toolkit library  1.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
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. More...
 
void MakeCurrent ()
 Makes the underlying this GLControl current in the calling thread. All OpenGL commands issued are hereafter interpreted by this GLControl. More...
 
Bitmap GrabScreenshot ()
 Grabs a screenshot of the frontbuffer contents. 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

bool IsIdle [get]
 Gets a value indicating whether the current thread contains pending system messages. More...
 
IGraphicsContext Context [get, set]
 Gets an interface to the underlying GraphicsContext used by this GLControl. 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. More...
 
GraphicsMode GraphicsMode [get]
 Gets the GraphicsMode of the GraphicsContext attached to this 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.

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 the underlying this GLControl current in the calling thread. All OpenGL commands issued are hereafter interpreted by this GLControl.

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.

Property Documentation

float OpenTK.GLControl.AspectRatio
get

Gets the aspect ratio of this GLControl.

IGraphicsContext OpenTK.GLControl.Context
getset

Gets an interface to the underlying GraphicsContext used by this GLControl.

GraphicsMode OpenTK.GLControl.GraphicsMode
get

Gets the GraphicsMode of the GraphicsContext attached to this GLControl.

To change the 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.

IWindowInfo OpenTK.GLControl.WindowInfo
get

Gets the OpenTK.Platform.IWindowInfo for this instance.