diff --git a/Source/OpenTK/GLControl.cs b/Source/OpenTK/GLControl.cs index 0340ec48..a2d74839 100644 --- a/Source/OpenTK/GLControl.cs +++ b/Source/OpenTK/GLControl.cs @@ -30,8 +30,10 @@ namespace OpenTK IGLControl implementation; GraphicsMode format; IWindowInfo window_info; + int major, minor; + GraphicsContextFlags flags; - #region --- Constructor --- + #region --- Constructors --- /// /// Constructs a new GLControl. @@ -40,18 +42,22 @@ namespace OpenTK : this(GraphicsMode.Default) { } - /// This method is obsolete and will be removed in future versions. - /// Obsolete. - [Obsolete] - public GLControl(DisplayMode mode) - : this(mode.ToGraphicsMode()) + /// + /// Constructs a new GLControl with the specified GraphicsMode. + /// + /// The OpenTK.Graphics.GraphicsMode of the control. + public GLControl(GraphicsMode mode) + : this(mode, 1, 0, GraphicsContextFlags.Default) { } /// /// Constructs a new GLControl with the specified GraphicsMode. /// /// The OpenTK.Graphics.GraphicsMode of the control. - public GLControl(GraphicsMode mode) + /// The major version for the OpenGL GraphicsContext. + /// The minor version for the OpenGL GraphicsContext. + /// The GraphicsContextFlags for the OpenGL GraphicsContext. + public GLControl(GraphicsMode mode, int major, int minor, GraphicsContextFlags flags) { SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.UserPaint, true); @@ -61,6 +67,9 @@ namespace OpenTK InitializeComponent(); this.format = mode; + this.major = major; + this.minor = minor; + this.flags = flags; // On Windows, you first need to create the window, then set the pixel format. // On X11, you first need to select the visual, then create the window. @@ -77,22 +86,18 @@ namespace OpenTK this.CreateControl(); } + #region Obsolete + + /// This method is obsolete and will be removed in future versions. + /// Obsolete.v + [Obsolete] + public GLControl(DisplayMode mode) + : this(mode.ToGraphicsMode()) + { } + #endregion - protected override void OnResize(EventArgs e) - { - if (context != null) - context.Update(window_info); - - base.OnResize(e); - } - protected override void OnParentChanged(EventArgs e) - { - if (context != null) - context.Update(window_info); - - base.OnParentChanged(e); - } + #endregion #region --- Protected Methods --- @@ -102,7 +107,7 @@ namespace OpenTK { base.OnHandleCreated(e); - this.Context = implementation.CreateContext(); + this.Context = implementation.CreateContext(major, minor, flags); this.window_info = implementation.WindowInfo; this.MakeCurrent(); @@ -133,6 +138,30 @@ namespace OpenTK base.OnPaint(e); } + /// + /// Raises the Resize event. + /// + /// A System.EventArgs that contains the event data. + protected override void OnResize(EventArgs e) + { + if (context != null) + context.Update(window_info); + + base.OnResize(e); + } + + /// + /// Raises the ParentChanged event. + /// + /// A System.EventArgs that contains the event data. + protected override void OnParentChanged(EventArgs e) + { + if (context != null) + context.Update(window_info); + + base.OnParentChanged(e); + } + #endregion #region --- Public Methods --- diff --git a/Source/OpenTK/Platform/Dummy/DummyGLControl.cs b/Source/OpenTK/Platform/Dummy/DummyGLControl.cs index 23c01148..12a31e3d 100644 --- a/Source/OpenTK/Platform/Dummy/DummyGLControl.cs +++ b/Source/OpenTK/Platform/Dummy/DummyGLControl.cs @@ -6,7 +6,7 @@ namespace OpenTK.Platform.Dummy { #region IGLControl Members - public OpenTK.Graphics.GraphicsContext CreateContext() + public OpenTK.Graphics.GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags) { return new GraphicsContext(null, null); } diff --git a/Source/OpenTK/Platform/IGLControl.cs b/Source/OpenTK/Platform/IGLControl.cs index ee283ad7..456dd93a 100644 --- a/Source/OpenTK/Platform/IGLControl.cs +++ b/Source/OpenTK/Platform/IGLControl.cs @@ -16,7 +16,7 @@ namespace OpenTK.Platform { internal interface IGLControl { - GraphicsContext CreateContext(); + GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags); bool IsIdle { get; } IWindowInfo WindowInfo { get; } } diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLControl.cs b/Source/OpenTK/Platform/MacOS/CarbonGLControl.cs index 707528e3..39c1a457 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLControl.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLControl.cs @@ -20,9 +20,9 @@ namespace OpenTK.Platform.MacOS #region IGLControl Members - public OpenTK.Graphics.GraphicsContext CreateContext() + public OpenTK.Graphics.GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags) { - return new GraphicsContext(mode, WindowInfo); + return new GraphicsContext(mode, WindowInfo, major, minor, flags); } // TODO: Fix this diff --git a/Source/OpenTK/Platform/Windows/WinGLControl.cs b/Source/OpenTK/Platform/Windows/WinGLControl.cs index 4bcb4850..5f75e446 100644 --- a/Source/OpenTK/Platform/Windows/WinGLControl.cs +++ b/Source/OpenTK/Platform/Windows/WinGLControl.cs @@ -29,10 +29,10 @@ namespace OpenTK.Platform.Windows #region --- IGLControl Members --- - public GraphicsContext CreateContext() + public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags) { WinWindowInfo window = new WinWindowInfo(control.Handle, null); - return new GraphicsContext(mode, window); + return new GraphicsContext(mode, window, major, minor, flags); } public bool IsIdle diff --git a/Source/OpenTK/Platform/X11/X11GLControl.cs b/Source/OpenTK/Platform/X11/X11GLControl.cs index 51b642c9..6dc0b90a 100644 --- a/Source/OpenTK/Platform/X11/X11GLControl.cs +++ b/Source/OpenTK/Platform/X11/X11GLControl.cs @@ -44,9 +44,9 @@ namespace OpenTK.Platform.X11 #region --- IGLControl Members --- - public GraphicsContext CreateContext() + public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags) { - return new GraphicsContext(mode, this.WindowInfo); + return new GraphicsContext(mode, this.WindowInfo, major, minor, flags); } public bool IsIdle