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
Object
MarshalByRefObject
Component
Control
ScrollableControl
ContainerControl
UserControl
GLControl
Implements
IDropTarget
ISynchronizeInvoke
IWin32Window
IBindableComponent
IComponent
IDisposable
IContainerControl
Inherited Members
UserControl.ValidateChildren()
UserControl.ValidateChildren(ValidationConstraints)
UserControl.OnCreateControl()
UserControl.OnLoad(EventArgs)
UserControl.OnMouseDown(MouseEventArgs)
UserControl.WndProc(Message)
UserControl.AutoSize
UserControl.AutoSizeMode
UserControl.AutoValidate
UserControl.BorderStyle
UserControl.DefaultSize
UserControl.AutoSizeChanged
UserControl.AutoValidateChanged
UserControl.Load
ContainerControl.IContainerControl.ActivateControl(Control)
ContainerControl.AdjustFormScrollbars(Boolean)
ContainerControl.OnAutoValidateChanged(EventArgs)
ContainerControl.OnFontChanged(EventArgs)
ContainerControl.OnLayout(LayoutEventArgs)
ContainerControl.PerformAutoScale()
ContainerControl.ProcessDialogChar(Char)
ContainerControl.ProcessDialogKey(Keys)
ContainerControl.ProcessCmdKey(Message, Keys)
ContainerControl.ProcessMnemonic(Char)
ContainerControl.ProcessTabKey(Boolean)
ContainerControl.Select(Boolean, Boolean)
ContainerControl.UpdateDefaultButton()
ContainerControl.Validate()
ContainerControl.Validate(Boolean)
ContainerControl.AutoScaleDimensions
ContainerControl.AutoScaleFactor
ContainerControl.AutoScaleMode
ContainerControl.BindingContext
ContainerControl.CanEnableIme
ContainerControl.ActiveControl
ContainerControl.CurrentAutoScaleDimensions
ContainerControl.ParentForm
ScrollableControl.ScrollStateAutoScrolling
ScrollableControl.ScrollStateHScrollVisible
ScrollableControl.ScrollStateVScrollVisible
ScrollableControl.ScrollStateUserHasScrolled
ScrollableControl.ScrollStateFullDrag
ScrollableControl.GetScrollState(Int32)
ScrollableControl.OnMouseWheel(MouseEventArgs)
ScrollableControl.OnRightToLeftChanged(EventArgs)
ScrollableControl.OnPaintBackground(PaintEventArgs)
ScrollableControl.OnPaddingChanged(EventArgs)
ScrollableControl.OnVisibleChanged(EventArgs)
ScrollableControl.ScaleControl(SizeF, BoundsSpecified)
ScrollableControl.SetDisplayRectLocation(Int32, Int32)
ScrollableControl.ScrollControlIntoView(Control)
ScrollableControl.ScrollToControl(Control)
ScrollableControl.OnScroll(ScrollEventArgs)
ScrollableControl.SetAutoScrollMargin(Int32, Int32)
ScrollableControl.SetScrollState(Int32, Boolean)
ScrollableControl.AutoScroll
ScrollableControl.AutoScrollMargin
ScrollableControl.AutoScrollPosition
ScrollableControl.AutoScrollMinSize
ScrollableControl.DisplayRectangle
ScrollableControl.HScroll
ScrollableControl.HorizontalScroll
ScrollableControl.VScroll
ScrollableControl.VerticalScroll
ScrollableControl.Scroll
Control.GetAccessibilityObjectById(Int32)
Control.SetAutoSizeMode(AutoSizeMode)
Control.GetAutoSizeMode()
Control.GetPreferredSize(Size)
Control.AccessibilityNotifyClients(AccessibleEvents, Int32)
Control.AccessibilityNotifyClients(AccessibleEvents, Int32, Int32)
Control.BeginInvoke(Delegate)
Control.BeginInvoke(Delegate, Object[])
Control.BringToFront()
Control.Contains(Control)
Control.CreateAccessibilityInstance()
Control.CreateControlsInstance()
Control.CreateGraphics()
Control.CreateHandle()
Control.CreateControl()
Control.DefWndProc(Message)
Control.DestroyHandle()
Control.DoDragDrop(Object, DragDropEffects)
Control.DrawToBitmap(Bitmap, Rectangle)
Control.EndInvoke(IAsyncResult)
Control.FindForm()
Control.GetTopLevel()
Control.RaiseKeyEvent(Object, KeyEventArgs)
Control.RaiseMouseEvent(Object, MouseEventArgs)
Control.Focus()
Control.FromChildHandle(IntPtr)
Control.FromHandle(IntPtr)
Control.GetChildAtPoint(Point, GetChildAtPointSkip)
Control.GetChildAtPoint(Point)
Control.GetContainerControl()
Control.GetScaledBounds(Rectangle, SizeF, BoundsSpecified)
Control.GetNextControl(Control, Boolean)
Control.GetStyle(ControlStyles)
Control.Hide()
Control.InitLayout()
Control.Invalidate(Region)
Control.Invalidate(Region, Boolean)
Control.Invalidate()
Control.Invalidate(Boolean)
Control.Invalidate(Rectangle)
Control.Invalidate(Rectangle, Boolean)
Control.Invoke(Delegate)
Control.Invoke(Delegate, Object[])
Control.InvokePaint(Control, PaintEventArgs)
Control.InvokePaintBackground(Control, PaintEventArgs)
Control.IsKeyLocked(Keys)
Control.IsInputChar(Char)
Control.IsInputKey(Keys)
Control.IsMnemonic(Char, String)
Control.NotifyInvalidate(Rectangle)
Control.InvokeOnClick(Control, EventArgs)
Control.OnAutoSizeChanged(EventArgs)
Control.OnBackColorChanged(EventArgs)
Control.OnBackgroundImageChanged(EventArgs)
Control.OnBackgroundImageLayoutChanged(EventArgs)
Control.OnBindingContextChanged(EventArgs)
Control.OnCausesValidationChanged(EventArgs)
Control.OnContextMenuChanged(EventArgs)
Control.OnContextMenuStripChanged(EventArgs)
Control.OnCursorChanged(EventArgs)
Control.OnDockChanged(EventArgs)
Control.OnEnabledChanged(EventArgs)
Control.OnForeColorChanged(EventArgs)
Control.OnNotifyMessage(Message)
Control.OnParentBackColorChanged(EventArgs)
Control.OnParentBackgroundImageChanged(EventArgs)
Control.OnParentBindingContextChanged(EventArgs)
Control.OnParentCursorChanged(EventArgs)
Control.OnParentEnabledChanged(EventArgs)
Control.OnParentFontChanged(EventArgs)
Control.OnParentForeColorChanged(EventArgs)
Control.OnParentRightToLeftChanged(EventArgs)
Control.OnParentVisibleChanged(EventArgs)
Control.OnPrint(PaintEventArgs)
Control.OnTabIndexChanged(EventArgs)
Control.OnTabStopChanged(EventArgs)
Control.OnTextChanged(EventArgs)
Control.OnClick(EventArgs)
Control.OnClientSizeChanged(EventArgs)
Control.OnControlAdded(ControlEventArgs)
Control.OnControlRemoved(ControlEventArgs)
Control.OnLocationChanged(EventArgs)
Control.OnDoubleClick(EventArgs)
Control.OnDragEnter(DragEventArgs)
Control.OnDragOver(DragEventArgs)
Control.OnDragLeave(EventArgs)
Control.OnDragDrop(DragEventArgs)
Control.OnGiveFeedback(GiveFeedbackEventArgs)
Control.OnEnter(EventArgs)
Control.InvokeGotFocus(Control, EventArgs)
Control.OnGotFocus(EventArgs)
Control.OnHelpRequested(HelpEventArgs)
Control.OnInvalidated(InvalidateEventArgs)
Control.OnKeyDown(KeyEventArgs)
Control.OnKeyPress(KeyPressEventArgs)
Control.OnKeyUp(KeyEventArgs)
Control.OnLeave(EventArgs)
Control.InvokeLostFocus(Control, EventArgs)
Control.OnLostFocus(EventArgs)
Control.OnMarginChanged(EventArgs)
Control.OnMouseDoubleClick(MouseEventArgs)
Control.OnMouseClick(MouseEventArgs)
Control.OnMouseCaptureChanged(EventArgs)
Control.OnMouseEnter(EventArgs)
Control.OnMouseLeave(EventArgs)
Control.OnMouseHover(EventArgs)
Control.OnMouseMove(MouseEventArgs)
Control.OnMouseUp(MouseEventArgs)
Control.OnMove(EventArgs)
Control.OnQueryContinueDrag(QueryContinueDragEventArgs)
Control.OnRegionChanged(EventArgs)
Control.OnPreviewKeyDown(PreviewKeyDownEventArgs)
Control.OnSizeChanged(EventArgs)
Control.OnChangeUICues(UICuesEventArgs)
Control.OnStyleChanged(EventArgs)
Control.OnSystemColorsChanged(EventArgs)
Control.OnValidating(CancelEventArgs)
Control.OnValidated(EventArgs)
Control.PerformLayout()
Control.PerformLayout(Control, String)
Control.PointToClient(Point)
Control.PointToScreen(Point)
Control.PreProcessMessage(Message)
Control.PreProcessControlMessage(Message)
Control.ProcessKeyEventArgs(Message)
Control.ProcessKeyMessage(Message)
Control.ProcessKeyPreview(Message)
Control.RaiseDragEvent(Object, DragEventArgs)
Control.RaisePaintEvent(Object, PaintEventArgs)
Control.RecreateHandle()
Control.RectangleToClient(Rectangle)
Control.RectangleToScreen(Rectangle)
Control.ReflectMessage(IntPtr, Message)
Control.Refresh()
Control.ResetMouseEventArgs()
Control.ResetText()
Control.ResumeLayout()
Control.ResumeLayout(Boolean)
Control.Scale(SizeF)
Control.Select()
Control.SelectNextControl(Control, Boolean, Boolean, Boolean, Boolean)
Control.SendToBack()
Control.SetBounds(Int32, Int32, Int32, Int32)
Control.SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)
Control.SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)
Control.SetClientSizeCore(Int32, Int32)
Control.SizeFromClientSize(Size)
Control.SetStyle(ControlStyles, Boolean)
Control.SetTopLevel(Boolean)
Control.SetVisibleCore(Boolean)
Control.RtlTranslateAlignment(HorizontalAlignment)
Control.RtlTranslateAlignment(LeftRightAlignment)
Control.RtlTranslateAlignment(ContentAlignment)
Control.RtlTranslateHorizontal(HorizontalAlignment)
Control.RtlTranslateLeftRight(LeftRightAlignment)
Control.RtlTranslateContent(ContentAlignment)
Control.Show()
Control.SuspendLayout()
Control.Update()
Control.UpdateBounds()
Control.UpdateBounds(Int32, Int32, Int32, Int32)
Control.UpdateBounds(Int32, Int32, Int32, Int32, Int32, Int32)
Control.UpdateZOrder()
Control.UpdateStyles()
Control.IDropTarget.OnDragEnter(DragEventArgs)
Control.IDropTarget.OnDragOver(DragEventArgs)
Control.IDropTarget.OnDragLeave(EventArgs)
Control.IDropTarget.OnDragDrop(DragEventArgs)
Control.OnImeModeChanged(EventArgs)
Control.AccessibilityObject
Control.AccessibleDefaultActionDescription
Control.AccessibleDescription
Control.AccessibleName
Control.AccessibleRole
Control.AllowDrop
Control.Anchor
Control.AutoScrollOffset
Control.LayoutEngine
Control.BackColor
Control.BackgroundImage
Control.BackgroundImageLayout
Control.Bottom
Control.Bounds
Control.CanFocus
Control.CanRaiseEvents
Control.CanSelect
Control.Capture
Control.CausesValidation
Control.CheckForIllegalCrossThreadCalls
Control.ClientRectangle
Control.ClientSize
Control.CompanyName
Control.ContainsFocus
Control.ContextMenu
Control.ContextMenuStrip
Control.Controls
Control.Created
Control.Cursor
Control.DataBindings
Control.DefaultBackColor
Control.DefaultCursor
Control.DefaultFont
Control.DefaultForeColor
Control.DefaultMargin
Control.DefaultMaximumSize
Control.DefaultMinimumSize
Control.DefaultPadding
Control.IsDisposed
Control.Disposing
Control.Dock
Control.DoubleBuffered
Control.Enabled
Control.Focused
Control.Font
Control.FontHeight
Control.ForeColor
Control.Handle
Control.HasChildren
Control.Height
Control.IsHandleCreated
Control.InvokeRequired
Control.IsAccessible
Control.IsMirrored
Control.Left
Control.Location
Control.Margin
Control.MaximumSize
Control.MinimumSize
Control.ModifierKeys
Control.MouseButtons
Control.MousePosition
Control.Name
Control.Parent
Control.ProductName
Control.ProductVersion
Control.RecreatingHandle
Control.Region
Control.RenderRightToLeft
Control.ResizeRedraw
Control.Right
Control.RightToLeft
Control.ScaleChildren
Control.Site
Control.Size
Control.TabIndex
Control.TabStop
Control.Tag
Control.Text
Control.Top
Control.TopLevelControl
Control.ShowKeyboardCues
Control.ShowFocusCues
Control.UseWaitCursor
Control.Visible
Control.Width
Control.PreferredSize
Control.Padding
Control.DefaultImeMode
Control.ImeMode
Control.ImeModeBase
Control.PropagatingImeMode
Control.BackColorChanged
Control.BackgroundImageChanged
Control.BackgroundImageLayoutChanged
Control.BindingContextChanged
Control.CausesValidationChanged
Control.ClientSizeChanged
Control.ContextMenuChanged
Control.ContextMenuStripChanged
Control.CursorChanged
Control.DockChanged
Control.EnabledChanged
Control.FontChanged
Control.ForeColorChanged
Control.LocationChanged
Control.MarginChanged
Control.RegionChanged
Control.RightToLeftChanged
Control.SizeChanged
Control.TabIndexChanged
Control.TabStopChanged
Control.TextChanged
Control.VisibleChanged
Control.Click
Control.ControlAdded
Control.ControlRemoved
Control.DragDrop
Control.DragEnter
Control.DragOver
Control.DragLeave
Control.GiveFeedback
Control.HandleCreated
Control.HandleDestroyed
Control.HelpRequested
Control.Invalidated
Control.PaddingChanged
Control.Paint
Control.QueryContinueDrag
Control.QueryAccessibilityHelp
Control.DoubleClick
Control.Enter
Control.GotFocus
Control.KeyDown
Control.KeyPress
Control.KeyUp
Control.Layout
Control.Leave
Control.LostFocus
Control.MouseClick
Control.MouseDoubleClick
Control.MouseCaptureChanged
Control.MouseDown
Control.MouseEnter
Control.MouseLeave
Control.MouseHover
Control.MouseMove
Control.MouseUp
Control.MouseWheel
Control.Move
Control.PreviewKeyDown
Control.Resize
Control.ChangeUICues
Control.StyleChanged
Control.SystemColorsChanged
Control.Validating
Control.Validated
Control.ParentChanged
Control.ImeModeChanged
Component.Dispose()
Component.GetService(Type)
Component.ToString()
Component.Events
Component.Container
Component.DesignMode
Component.Disposed
MarshalByRefObject.MemberwiseClone(Boolean)
MarshalByRefObject.GetLifetimeService()
MarshalByRefObject.InitializeLifetimeService()
MarshalByRefObject.CreateObjRef(Type)
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: OpenTK
Assembly: OpenTK.GLControl.dll
Syntax
public class GLControl : UserControl, UnsafeNativeMethods.IOleControl, UnsafeNativeMethods.IOleObject, UnsafeNativeMethods.IOleInPlaceObject, UnsafeNativeMethods.IOleInPlaceActiveObject, UnsafeNativeMethods.IOleWindow, UnsafeNativeMethods.IViewObject, UnsafeNativeMethods.IViewObject2, UnsafeNativeMethods.IPersist, UnsafeNativeMethods.IPersistStreamInit, UnsafeNativeMethods.IPersistPropertyBag, UnsafeNativeMethods.IPersistStorage, UnsafeNativeMethods.IQuickActivate, ISupportOleDropSource, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IArrangedElement, IComponent, IDisposable, IContainerControl

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.

Int32 major

The major version for the OpenGL GraphicsContext.

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
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
[Browsable(false)]
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
Overrides
UserControl.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
Boolean

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

IsIdle

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

Declaration
[Browsable(false)]
public bool IsIdle { get; }
Property Value
Type Description
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
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
Boolean disposing

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

Overrides
ContainerControl.Dispose(Boolean)

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
EventArgs e

Not used.

Overrides
Control.OnHandleCreated(EventArgs)

OnHandleDestroyed(EventArgs)

Raises the HandleDestroyed event.

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

Not used.

Overrides
Control.OnHandleDestroyed(EventArgs)

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.

Overrides
Control.OnPaint(PaintEventArgs)

OnParentChanged(EventArgs)

Raises the ParentChanged event.

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

A System.EventArgs that contains the event data.

Overrides
ContainerControl.OnParentChanged(EventArgs)

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
EventArgs e

A System.EventArgs that contains the event data.

Overrides
UserControl.OnResize(EventArgs)

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()

Implements

System.Windows.Forms.IDropTarget
System.ComponentModel.ISynchronizeInvoke
System.Windows.Forms.IWin32Window
System.Windows.Forms.IBindableComponent
System.ComponentModel.IComponent
System.IDisposable
System.Windows.Forms.IContainerControl
In This Article
Back to top Generated by DocFX