From 8b32c9aa5ef87686fe282ab54881d179ad50c9f8 Mon Sep 17 00:00:00 2001 From: Jarl Gullberg Date: Tue, 13 Jun 2017 22:08:23 +0200 Subject: [PATCH] Improved comments. --- src/OpenTK.GLWidget/GLWidget.cs | 135 +++++++++++++++++++++++++++++++++------- 1 file changed, 112 insertions(+), 23 deletions(-) diff --git a/src/OpenTK.GLWidget/GLWidget.cs b/src/OpenTK.GLWidget/GLWidget.cs index a0f862f..d5f4a43 100644 --- a/src/OpenTK.GLWidget/GLWidget.cs +++ b/src/OpenTK.GLWidget/GLWidget.cs @@ -39,6 +39,9 @@ using OpenTK.X11; namespace OpenTK { + /// + /// The is a GTK widget for which an OpenGL context can be used to draw arbitrary graphics. + /// [ToolboxItem(true)] public class GLWidget: DrawingArea { @@ -61,34 +64,55 @@ namespace OpenTK #region Properties - /// Use a single buffer versus a double buffer. + /// + /// Use a single buffer versus a double buffer. + /// [Browsable(true)] public bool SingleBuffer { get; set; } - /// Color Buffer Bits-Per-Pixel + /// + /// Color Buffer Bits-Per-Pixel + /// public int ColorBPP { get; set; } - /// Accumulation Buffer Bits-Per-Pixel + /// + /// Accumulation Buffer Bits-Per-Pixel + /// public int AccumulatorBPP { get; set; } - /// Depth Buffer Bits-Per-Pixel + /// + /// Depth Buffer Bits-Per-Pixel + /// public int DepthBPP { get; set; } - /// Stencil Buffer Bits-Per-Pixel + /// + /// Stencil Buffer Bits-Per-Pixel + /// public int StencilBPP { get; set; } - /// Number of samples + /// + /// Number of samples + /// public int Samples { get; set; } - /// Indicates if steropic renderering is enabled + /// + /// Indicates if steropic renderering is enabled + /// public bool Stereo { get; set; } - /// The major version of OpenGL to use. + /// + /// The major version of OpenGL to use. + /// public int GlVersionMajor { get; set; } - /// The minor version of OpenGL to use. + /// + /// The minor version of OpenGL to use. + /// public int GlVersionMinor { get; set; } + /// + /// The set for this widget. + /// public GraphicsContextFlags GraphicsContextFlags { get @@ -105,7 +129,9 @@ namespace OpenTK #region Construction/Destruction - /// Constructs a new GLWidget. + /// + /// Initializes a new instance of the class. + /// public GLWidget() : this(GraphicsMode.Default) { @@ -117,7 +143,15 @@ namespace OpenTK { } - /// Constructs a new GLWidget + /// + /// Initializes a new instance of the class. + /// + /// The which the widget should be constructed with. + /// The major OpenGL version to attempt to initialize. + /// The minor OpenGL version to attempt to initialize. + /// + /// Any flags which should be used during initialization of the . + /// public GLWidget(GraphicsMode graphicsMode, int glVersionMajor, int glVersionMinor, GraphicsContextFlags graphicsContextFlags) { this.DoubleBuffered = false; @@ -135,17 +169,27 @@ namespace OpenTK GraphicsContextFlags = graphicsContextFlags; } + /// + /// Destructs this object. + /// ~GLWidget() { Dispose(false); } #if GTK3 - public override void Destroy() { + /// + /// Destroys this , disposing it and destroying it in the context of GTK. + /// + public override void Destroy() #else + /// + /// Disposes the current object, releasing any native resources it was using. + /// + /// public override void Dispose() - { #endif + { GC.SuppressFinalize(this); Dispose(true); #if GTK3 @@ -155,6 +199,10 @@ namespace OpenTK #endif } + /// + /// Disposes the current object, releasing any native resources it was using. + /// + /// public virtual void Dispose(bool disposing) { if (disposing) @@ -174,45 +222,73 @@ namespace OpenTK #region New Events - // Called when the first GraphicsContext is created in the case of GraphicsContext.ShareContexts == True; + /// + /// Called when the first is created in the case where + /// GraphicsContext.ShareContexts == true; + /// public static event EventHandler GraphicsContextInitialized; + /// + /// Invokes the event. + /// static void OnGraphicsContextInitialized() { if (GraphicsContextInitialized != null) GraphicsContextInitialized(null, EventArgs.Empty); } - // Called when the first GraphicsContext is being destroyed in the case of GraphicsContext.ShareContexts == True; + /// + /// Called when the first is being destroyed in the case where + /// GraphicsContext.ShareContext == true; + /// public static event EventHandler GraphicsContextShuttingDown; + /// + /// Invokes the event. + /// static void OnGraphicsContextShuttingDown() { if (GraphicsContextShuttingDown != null) GraphicsContextShuttingDown(null, EventArgs.Empty); } - // Called when this GLWidget has a valid GraphicsContext + /// + /// Called when this has finished initializing and has a valid + /// . + /// public event EventHandler Initialized; + /// + /// Invokes the event. + /// protected virtual void OnInitialized() { if (Initialized != null) Initialized(this, EventArgs.Empty); } - // Called when this GLWidget needs to render a frame + /// + /// Called when this needs to render a frame. + /// public event EventHandler RenderFrame; + /// + /// Invokes the event. + /// protected virtual void OnRenderFrame() { if (RenderFrame != null) RenderFrame(this, EventArgs.Empty); } - // Called when this GLWidget is being Disposed + /// + /// Called when this is being disposed. + /// public event EventHandler ShuttingDown; + /// + /// Invokes the event. + /// protected virtual void OnShuttingDown() { if (ShuttingDown != null) @@ -221,13 +297,19 @@ namespace OpenTK #endregion - // Called when a widget is realized. (window handles and such are valid) - // protected override void OnRealized() { base.OnRealized(); } - - // Called when the widget needs to be (fully or partially) redrawn. #if GTK3 + /// + /// Called when the widget needs to be (fully or partially) redrawn. + /// + /// + /// protected override bool OnDrawn(Cairo.Context cr) #else + /// + /// Called when the widget is exposed. + /// + /// + /// protected override bool OnExposeEvent(Gdk.EventExpose evnt) #endif { @@ -253,7 +335,11 @@ namespace OpenTK return result; } - // Called on Resize + /// + /// Called whenever the widget is resized. + /// + /// + /// protected override bool OnConfigureEvent(Gdk.EventConfigure evnt) { bool result = base.OnConfigureEvent(evnt); @@ -264,6 +350,9 @@ namespace OpenTK return result; } + /// + /// Initializes the with its given values and creates a . + /// void Initialize() { _Initialized = true; -- 2.7.4