diff --git a/Source/GLControl/CarbonGLControl.cs b/Source/GLControl/CarbonGLControl.cs
new file mode 100644
index 00000000..7b2e45b2
--- /dev/null
+++ b/Source/GLControl/CarbonGLControl.cs
@@ -0,0 +1,77 @@
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+
+using OpenTK.Graphics;
+using OpenTK.Platform;
+
+namespace OpenTK
+{
+ class CarbonGLControl : IGLControl
+ {
+ GraphicsMode mode;
+ Control control;
+
+ internal CarbonGLControl(GraphicsMode mode, Control owner)
+ {
+ this.mode = mode;
+ this.control = owner;
+ }
+
+ #region IGLControl Members
+
+ public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
+ {
+ return new GraphicsContext(mode, WindowInfo, major, minor, flags);
+ }
+
+ // TODO: Fix this
+ bool lastIsIdle = false;
+ public bool IsIdle
+ {
+ get
+ {
+ lastIsIdle = !lastIsIdle;
+ return lastIsIdle;
+ }
+ }
+
+ public IWindowInfo WindowInfo
+ {
+ get
+ {
+ return Utilities.CreateWindowInfo(mode, control.Handle, true);
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/OpenTK/Platform/Dummy/DummyGLControl.cs b/Source/GLControl/DummyGLControl.cs
similarity index 81%
rename from Source/OpenTK/Platform/Dummy/DummyGLControl.cs
rename to Source/GLControl/DummyGLControl.cs
index 3a02e167..dc778418 100644
--- a/Source/OpenTK/Platform/Dummy/DummyGLControl.cs
+++ b/Source/GLControl/DummyGLControl.cs
@@ -1,53 +1,55 @@
-#region License
-//
-// The Open Toolkit Library License
-//
-// Copyright (c) 2006 - 2008 the Open Toolkit library, except where noted.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-// the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-#endregion
-
-using OpenTK.Graphics;
-
-namespace OpenTK.Platform.Dummy
-{
- class DummyGLControl : IGLControl
- {
- #region IGLControl Members
-
- public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
- {
- return new GraphicsContext(null, null);
- }
-
- public bool IsIdle
- {
- get { return false; }
- }
-
- public IWindowInfo WindowInfo
- {
- get { return new DummyWindowInfo(); }
- }
-
- #endregion
- }
-}
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
+using OpenTK.Graphics;
+using OpenTK.Platform;
+
+namespace OpenTK
+{
+ class DummyGLControl : IGLControl
+ {
+ #region IGLControl Members
+
+ public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
+ {
+ return new GraphicsContext(null, null);
+ }
+
+ public bool IsIdle
+ {
+ get { return false; }
+ }
+
+ public IWindowInfo WindowInfo
+ {
+ get { return Utilities.CreateWindowInfo(null, IntPtr.Zero, true); }
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/OpenTK/GLControl.Designer.cs b/Source/GLControl/GLControl.Designer.cs
similarity index 96%
rename from Source/OpenTK/GLControl.Designer.cs
rename to Source/GLControl/GLControl.Designer.cs
index c82b2d7b..8a009a78 100644
--- a/Source/OpenTK/GLControl.Designer.cs
+++ b/Source/GLControl/GLControl.Designer.cs
@@ -1,45 +1,45 @@
-namespace OpenTK
-{
- partial class GLControl
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Component Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // NewGLControl
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.BackColor = System.Drawing.Color.Black;
- this.Name = "NewGLControl";
- this.ResumeLayout(false);
-
- }
-
- #endregion
- }
-}
+namespace OpenTK
+{
+ partial class GLControl
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.SuspendLayout();
+ //
+ // NewGLControl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.Color.Black;
+ this.Name = "NewGLControl";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/OpenTK/GLControl.cs b/Source/GLControl/GLControl.cs
similarity index 77%
rename from Source/OpenTK/GLControl.cs
rename to Source/GLControl/GLControl.cs
index 5f66bc59..5fb77262 100644
--- a/Source/OpenTK/GLControl.cs
+++ b/Source/GLControl/GLControl.cs
@@ -1,291 +1,310 @@
-#region --- License ---
-/* Licensed under the MIT/X11 license.
- * Copyright (c) 2006-2008 the OpenTK Team.
- * This notice may not be removed from any source distribution.
- * See license.txt for licensing detailed licensing details.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Data;
-using System.Text;
-using System.Windows.Forms;
-
-using OpenTK.Platform;
-using OpenTK.Graphics;
-using System.Diagnostics;
-
-namespace OpenTK
-{
- ///
- /// Defines a UserControl with OpenGL rendering capabilities.
- ///
- public partial class GLControl : UserControl
- {
- IGraphicsContext context;
- IGLControl implementation;
- GraphicsMode format;
- IWindowInfo window_info;
- int major, minor;
- GraphicsContextFlags flags;
-
- #region --- Constructors ---
-
- ///
- /// Constructs a new GLControl.
- ///
- public GLControl()
- : this(GraphicsMode.Default)
- { }
-
- ///
- /// 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.
- /// 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);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- DoubleBuffered = false;
-
- 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.
- // On OSX, the pixel format needs to be selected before the GL context.
- // Right now, pixel formats/visuals are selected during context creation. In the future,
- // it would be better to decouple selection from context creation, which will allow us
- // to clean up this hacky code. The best option is to do this along with multisampling
- // support.
- if (DesignMode)
- implementation = new Platform.Dummy.DummyGLControl();
- else
- implementation = Platform.Factory.Default.CreateGLControl(mode, this);
-
- this.CreateControl();
- }
-
- #endregion
-
- #region --- Protected Methods ---
-
- /// Raises the HandleCreated event.
- /// Not used.
- protected override void OnHandleCreated(EventArgs e)
- {
- base.OnHandleCreated(e);
-
- this.Context = implementation.CreateContext(major, minor, flags);
-
- this.window_info = implementation.WindowInfo;
- this.MakeCurrent();
- ((IGraphicsContextInternal)this.Context).LoadAll();
- }
-
- /// Raises the HandleDestroyed event.
- /// Not used.
- protected override void OnHandleDestroyed(EventArgs e)
- {
- base.OnHandleDestroyed(e);
- if (this.Context != null)
- {
- this.Context.Dispose();
- this.Context = null;
- }
- this.window_info.Dispose();
- this.window_info = null;
- }
-
- ///
- /// Raises the System.Windows.Forms.Control.Paint event.
- ///
- /// A System.Windows.Forms.PaintEventArgs that contains the event data.
- protected override void OnPaint(PaintEventArgs e)
- {
- if (DesignMode)
- e.Graphics.Clear(BackColor);
-
- 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 ---
-
- #region public void SwapBuffers()
-
- ///
- /// Swaps the front and back buffers, presenting the rendered scene to the screen.
- ///
- public void SwapBuffers()
- {
- Context.SwapBuffers();
- }
-
- #endregion
-
- #region public void MakeCurrent()
-
- ///
- /// Makes the underlying this GLControl current in the calling thread.
- /// All OpenGL commands issued are hereafter interpreted by this GLControl.
- ///
- public void MakeCurrent()
- {
- this.Context.MakeCurrent(this.window_info);
- }
-
- #endregion
-
- #region public bool IsIdle
-
- ///
- /// Gets a value indicating whether the current thread contains pending system messages.
- ///
- [Browsable(false)]
- public bool IsIdle
- {
- get { return implementation.IsIdle; }
- }
-
- #endregion
-
- #region public IGraphicsContext Context
-
- ///
- /// Gets an interface to the underlying GraphicsContext used by this GLControl.
- ///
- [Browsable(false)]
- public IGraphicsContext Context
- {
- get { return context; }
- private set { context = value; }
- }
-
- #endregion
-
- #region public float AspectRatio
-
- ///
- /// Gets the aspect ratio of this GLControl.
- ///
- [Description("The aspect ratio of the client area of this GLControl.")]
- public float AspectRatio
- {
- get
- {
- return this.ClientSize.Width / (float)this.ClientSize.Height;
- }
- }
-
- #endregion
-
- #region public bool VSync
-
- ///
- /// Gets or sets a value indicating whether vsync is active for this GLControl.
- ///
- [Description("Indicates whether GLControl updates are synced to the monitor's refresh.")]
- public bool VSync
- {
- get
- {
- if (Context != null)
- return Context.VSync;
- return false;
- }
- set
- {
- if (Context != null)
- Context.VSync = value;
- }
- }
-
- #endregion
-
- #region public GraphicsMode GraphicsMode
-
- ///
- /// Gets the GraphicsMode of the GraphicsContext attached to this GLControl.
- ///
- ///
- /// To change the GraphicsMode, you must destroy and recreate the GLControl.
- ///
- public GraphicsMode GraphicsMode
- {
- get { return Context.GraphicsMode; }
- }
-
- #endregion
-
- #region public Bitmap GrabScreenshot()
-
- /// Grabs a screenshot of the frontbuffer contents.
- /// A System.Drawing.Bitmap, containing the contents of the frontbuffer.
- ///
- /// Occurs when no OpenTK.Graphics.GraphicsContext is current in the calling thread.
- ///
- [Obsolete]
- public Bitmap GrabScreenshot()
- {
- throw new NotImplementedException();
- //Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
- //System.Drawing.Imaging.BitmapData data =
- // bmp.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
- // System.Drawing.Imaging.PixelFormat.Format24bppRgb);
- //GL.ReadPixels(0, 0, this.ClientSize.Width, this.ClientSize.Height, PixelFormat.Bgr, PixelType.UnsignedByte,
- // data.Scan0);
- //bmp.UnlockBits(data);
- //bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
- //return bmp;
- }
-
- #endregion
-
- #endregion
- }
-}
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Drawing;
+using System.Data;
+using System.Text;
+using System.Windows.Forms;
+
+using OpenTK.Platform;
+using OpenTK.Graphics;
+using OpenTK.Graphics.OpenGL;
+
+namespace OpenTK
+{
+ ///
+ /// Defines a UserControl with OpenGL rendering capabilities.
+ ///
+ public partial class GLControl : UserControl
+ {
+ IGraphicsContext context;
+ IGLControl implementation;
+ GraphicsMode format;
+ IWindowInfo window_info;
+ int major, minor;
+ GraphicsContextFlags flags;
+
+ #region --- Constructors ---
+
+ ///
+ /// Constructs a new GLControl.
+ ///
+ public GLControl()
+ : this(GraphicsMode.Default)
+ { }
+
+ ///
+ /// 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.
+ /// 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);
+ SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ DoubleBuffered = false;
+
+ 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.
+ // On OSX, the pixel format needs to be selected before the GL context.
+ // Right now, pixel formats/visuals are selected during context creation. In the future,
+ // it would be better to decouple selection from context creation, which will allow us
+ // to clean up this hacky code. The best option is to do this along with multisampling
+ // support.
+ if (DesignMode)
+ implementation = new DummyGLControl();
+ else
+ implementation = new GLControlFactory().CreateGLControl(mode, this);
+
+ this.CreateControl();
+ }
+
+ #endregion
+
+ #region --- Protected Methods ---
+
+ /// Raises the HandleCreated event.
+ /// Not used.
+ protected override void OnHandleCreated(EventArgs e)
+ {
+ base.OnHandleCreated(e);
+
+ this.Context = implementation.CreateContext(major, minor, flags);
+
+ this.window_info = implementation.WindowInfo;
+ this.MakeCurrent();
+ ((IGraphicsContextInternal)this.Context).LoadAll();
+ }
+
+ /// Raises the HandleDestroyed event.
+ /// Not used.
+ protected override void OnHandleDestroyed(EventArgs e)
+ {
+ base.OnHandleDestroyed(e);
+ if (this.Context != null)
+ {
+ this.Context.Dispose();
+ this.Context = null;
+ }
+ this.window_info.Dispose();
+ this.window_info = null;
+ }
+
+ ///
+ /// Raises the System.Windows.Forms.Control.Paint event.
+ ///
+ /// A System.Windows.Forms.PaintEventArgs that contains the event data.
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ if (DesignMode)
+ e.Graphics.Clear(BackColor);
+
+ 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 ---
+
+ #region public void SwapBuffers()
+
+ ///
+ /// Swaps the front and back buffers, presenting the rendered scene to the screen.
+ ///
+ public void SwapBuffers()
+ {
+ Context.SwapBuffers();
+ }
+
+ #endregion
+
+ #region public void MakeCurrent()
+
+ ///
+ /// Makes the underlying this GLControl current in the calling thread.
+ /// All OpenGL commands issued are hereafter interpreted by this GLControl.
+ ///
+ public void MakeCurrent()
+ {
+ this.Context.MakeCurrent(this.window_info);
+ }
+
+ #endregion
+
+ #region public bool IsIdle
+
+ ///
+ /// Gets a value indicating whether the current thread contains pending system messages.
+ ///
+ [Browsable(false)]
+ public bool IsIdle
+ {
+ get { return implementation.IsIdle; }
+ }
+
+ #endregion
+
+ #region public IGraphicsContext Context
+
+ ///
+ /// Gets an interface to the underlying GraphicsContext used by this GLControl.
+ ///
+ [Browsable(false)]
+ public IGraphicsContext Context
+ {
+ get { return context; }
+ private set { context = value; }
+ }
+
+ #endregion
+
+ #region public float AspectRatio
+
+ ///
+ /// Gets the aspect ratio of this GLControl.
+ ///
+ [Description("The aspect ratio of the client area of this GLControl.")]
+ public float AspectRatio
+ {
+ get
+ {
+ return this.ClientSize.Width / (float)this.ClientSize.Height;
+ }
+ }
+
+ #endregion
+
+ #region public bool VSync
+
+ ///
+ /// Gets or sets a value indicating whether vsync is active for this GLControl.
+ ///
+ [Description("Indicates whether GLControl updates are synced to the monitor's refresh.")]
+ public bool VSync
+ {
+ get
+ {
+ if (Context != null)
+ return Context.VSync;
+ return false;
+ }
+ set
+ {
+ if (Context != null)
+ Context.VSync = value;
+ }
+ }
+
+ #endregion
+
+ #region public GraphicsMode GraphicsMode
+
+ ///
+ /// Gets the GraphicsMode of the GraphicsContext attached to this GLControl.
+ ///
+ ///
+ /// To change the GraphicsMode, you must destroy and recreate the GLControl.
+ ///
+ public GraphicsMode GraphicsMode
+ {
+ get { return Context.GraphicsMode; }
+ }
+
+ #endregion
+
+ #region public Bitmap GrabScreenshot()
+
+ /// Grabs a screenshot of the frontbuffer contents.
+ /// A System.Drawing.Bitmap, containing the contents of the frontbuffer.
+ ///
+ /// Occurs when no OpenTK.Graphics.GraphicsContext is current in the calling thread.
+ ///
+ [Obsolete("This method will be removed. Please provide your own code to capture framebuffer contents.")]
+ public Bitmap GrabScreenshot()
+ {
+ Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
+ System.Drawing.Imaging.BitmapData data =
+ bmp.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
+ System.Drawing.Imaging.PixelFormat.Format24bppRgb);
+ GL.ReadPixels(0, 0, this.ClientSize.Width, this.ClientSize.Height, PixelFormat.Bgr, PixelType.UnsignedByte,
+ data.Scan0);
+ bmp.UnlockBits(data);
+ bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
+ return bmp;
+ }
+
+ #endregion
+
+ #endregion
+ }
+}
diff --git a/Source/OpenTK/GLControl.resx b/Source/GLControl/GLControl.resx
similarity index 100%
rename from Source/OpenTK/GLControl.resx
rename to Source/GLControl/GLControl.resx
diff --git a/Source/GLControl/GLControlFactory.cs b/Source/GLControl/GLControlFactory.cs
new file mode 100644
index 00000000..2077fb0b
--- /dev/null
+++ b/Source/GLControl/GLControlFactory.cs
@@ -0,0 +1,47 @@
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using OpenTK.Graphics;
+
+namespace OpenTK
+{
+ // Constructs GLControls.
+ class GLControlFactory
+ {
+ public IGLControl CreateGLControl(GraphicsMode mode, Control control)
+ {
+ if (Configuration.RunningOnWindows) return new WinGLControl(mode, control);
+ else if (Configuration.RunningOnX11) return new X11GLControl(mode, control);
+ else if (Configuration.RunningOnMacOS) return new CarbonGLControl(mode, control);
+ else throw new PlatformNotSupportedException();
+ }
+ }
+}
diff --git a/Source/GLControl/IGLControl.cs b/Source/GLControl/IGLControl.cs
new file mode 100644
index 00000000..85904a9b
--- /dev/null
+++ b/Source/GLControl/IGLControl.cs
@@ -0,0 +1,43 @@
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using OpenTK.Graphics;
+using OpenTK.Platform;
+
+namespace OpenTK
+{
+ internal interface IGLControl
+ {
+ IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags);
+ bool IsIdle { get; }
+ IWindowInfo WindowInfo { get; }
+ }
+}
diff --git a/Source/GLControl/OpenTK.GLControl.csproj b/Source/GLControl/OpenTK.GLControl.csproj
new file mode 100644
index 00000000..8ff60d0e
--- /dev/null
+++ b/Source/GLControl/OpenTK.GLControl.csproj
@@ -0,0 +1,182 @@
+
+
+ Local
+ 9.0.30729
+ 2.0
+ {8CC9D641-0000-0000-0000-000000000000}
+ Debug
+ AnyCPU
+
+
+
+
+ OpenTK.GLControl
+ JScript
+ Grid
+ IE50
+ false
+ v2.0
+ Library
+
+
+ OpenTK.GLControl
+
+
+
+
+
+
+ 2.0
+
+
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
+
+
+ True
+ 285212672
+ False
+
+
+ DEBUG;TRACE;
+ OpenTK.GLControl.xml
+ True
+ 4096
+ False
+ ..\..\Binaries\Debug\
+ False
+ False
+ False
+ 4
+ False
+
+
+
+
+ True
+ 285212672
+ False
+
+
+ TRACE;
+ OpenTK.GLControl.xml
+ False
+ 4096
+ True
+ ..\..\Binaries\Release\
+ False
+ False
+ False
+ 4
+ False
+
+
+
+
+
+ System
+ False
+
+
+ System.Data
+ False
+
+
+ System.Drawing
+ False
+
+
+ System.Windows.Forms
+ False
+
+
+ System.Xml
+ False
+
+
+
+
+ OpenTK
+ {2C035F6B-0000-0000-0000-000000000000}
+ {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ False
+
+
+
+
+ Code
+
+
+ Code
+
+
+ UserControl
+
+
+ GLControl.cs
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+
+
+ False
+ .NET Framework Client Profile
+ false
+
+
+ False
+ .NET Framework 2.0 %28x86%29
+ true
+
+
+ False
+ .NET Framework 3.0 %28x86%29
+ false
+
+
+ False
+ .NET Framework 3.5
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/GLControl/Properties/AssemblyInfo.cs b/Source/GLControl/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..106bebbb
--- /dev/null
+++ b/Source/GLControl/Properties/AssemblyInfo.cs
@@ -0,0 +1,38 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("OpenTK.GLControl")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("OpenTK.GLControl")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("5414b90b-d7be-4382-b0e1-f07ce154f7f7")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+[assembly: System.CLSCompliant(true)]
\ No newline at end of file
diff --git a/Source/GLControl/WinGLControl.cs b/Source/GLControl/WinGLControl.cs
new file mode 100644
index 00000000..b1f731e2
--- /dev/null
+++ b/Source/GLControl/WinGLControl.cs
@@ -0,0 +1,158 @@
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2009 the Open Toolkit library, except where noted.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+
+using OpenTK.Graphics;
+using OpenTK.Platform;
+
+namespace OpenTK
+{
+ class WinGLControl : IGLControl
+ {
+ #region P/Invoke declarations
+
+ #region Message
+
+ struct MSG
+ {
+ public IntPtr HWnd;
+ public uint Message;
+ public IntPtr WParam;
+ public IntPtr LParam;
+ public uint Time;
+ public POINT Point;
+ //internal object RefObject;
+
+ public override string ToString()
+ {
+ return String.Format("msg=0x{0:x} ({1}) hwnd=0x{2:x} wparam=0x{3:x} lparam=0x{4:x} pt=0x{5:x}", (int)Message, Message.ToString(), HWnd.ToInt32(), WParam.ToInt32(), LParam.ToInt32(), Point);
+ }
+ }
+
+ #endregion
+
+ #region Point
+
+ struct POINT
+ {
+ public int X;
+ public int Y;
+
+ public POINT(int x, int y)
+ {
+ this.X = x;
+ this.Y = y;
+ }
+
+ public System.Drawing.Point ToPoint()
+ {
+ return new System.Drawing.Point(X, Y);
+ }
+
+ public override string ToString()
+ {
+ return "Point {" + X.ToString() + ", " + Y.ToString() + ")";
+ }
+ }
+
+ #endregion
+
+ #region PeekMessage
+
+ [System.Security.SuppressUnmanagedCodeSecurity]
+ [System.Runtime.InteropServices.DllImport("User32.dll")]
+ static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
+
+ #endregion
+
+ #region
+
+ #endregion
+
+ #endregion
+
+ #region Fields
+
+ MSG msg = new MSG();
+ IWindowInfo window_info;
+ GraphicsMode mode;
+
+ #endregion
+
+ #region Constructors
+
+ public WinGLControl(GraphicsMode mode, Control control)
+ {
+ this.mode = mode;
+
+ control.HandleCreated += delegate(object sender, EventArgs e)
+ {
+ if (window_info != null)
+ window_info.Dispose();
+ window_info = Utilities.CreateWindowInfo(mode, ((Control)sender).Handle, true);
+ };
+
+ control.HandleDestroyed += delegate(object sender, EventArgs e)
+ {
+ if (window_info != null)
+ {
+ window_info.Dispose();
+ window_info = null;
+ }
+ };
+ }
+
+ #endregion
+
+ #region IGLControl Members
+
+ public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
+ {
+ return new GraphicsContext(mode, window_info, major, minor, flags);
+ }
+
+ public bool IsIdle
+ {
+ get { return !PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); }
+ }
+
+ public IWindowInfo WindowInfo
+ {
+ get
+ {
+ // This method forces the creation of the control. Beware of this side-effect!
+ return window_info;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/GLControl/X11GLControl.cs b/Source/GLControl/X11GLControl.cs
new file mode 100644
index 00000000..cbf75c73
--- /dev/null
+++ b/Source/GLControl/X11GLControl.cs
@@ -0,0 +1,67 @@
+#region --- License ---
+/* Licensed under the MIT/X11 license.
+ * Copyright (c) 2006-2008 the OpenTK Team.
+ * This notice may not be removed from any source distribution.
+ * See license.txt for licensing detailed licensing details.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+
+using OpenTK.Graphics;
+using OpenTK.Platform;
+
+namespace OpenTK
+{
+ class X11GLControl : IGLControl
+ {
+ #region P/Invokes
+
+ [DllImport("libX11")]
+ public extern static int XPending(IntPtr diplay);
+
+ #endregion
+
+ #region Fields
+
+ GraphicsMode mode;
+ Control control;
+ IWindowInfo window_info;
+
+ #endregion
+
+ internal X11GLControl(GraphicsMode mode, Control control)
+ {
+ this.mode = mode;
+ this.control = control;
+
+ window_info = Utilities.CreateWindowInfo(mode, control.Handle, true);
+ }
+
+ #region IGLControl Members
+
+ public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
+ {
+ return new GraphicsContext(mode, this.WindowInfo, major, minor, flags);
+ }
+
+ public bool IsIdle
+ {
+ get { return XPending(((Platform.X11.X11WindowInfo)window_info).Display) == 0; }
+ }
+
+ public IWindowInfo WindowInfo
+ {
+ get
+ {
+ return window_info;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/OpenTK/Platform/Egl/EglContext.cs b/Source/OpenTK/Platform/Egl/EglContext.cs
index 2048b316..bbc9e4e9 100644
--- a/Source/OpenTK/Platform/Egl/EglContext.cs
+++ b/Source/OpenTK/Platform/Egl/EglContext.cs
@@ -118,18 +118,6 @@ namespace OpenTK.Platform.Egl
}
}
- // Todo: implement this!
- public bool ErrorChecking
- {
- get
- {
- return false;
- }
- set
- {
- }
- }
-
#endregion
#region IGraphicsContextInternal Members
diff --git a/Source/OpenTK/Platform/Factory.cs b/Source/OpenTK/Platform/Factory.cs
index d070ddb3..2e67b8fe 100644
--- a/Source/OpenTK/Platform/Factory.cs
+++ b/Source/OpenTK/Platform/Factory.cs
@@ -89,11 +89,6 @@ namespace OpenTK.Platform
return default_implementation.CreateNativeWindow(x, y, width, height, title, mode, options, device);
}
- public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
- {
- return default_implementation.CreateGLControl(mode, owner);
- }
-
public IDisplayDeviceDriver CreateDisplayDeviceDriver()
{
return default_implementation.CreateDisplayDeviceDriver();
@@ -134,11 +129,6 @@ namespace OpenTK.Platform
throw new PlatformNotSupportedException(error_string);
}
- public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
- {
- throw new PlatformNotSupportedException(error_string);
- }
-
public IDisplayDeviceDriver CreateDisplayDeviceDriver()
{
throw new PlatformNotSupportedException(error_string);
diff --git a/Source/OpenTK/Platform/IGLControl.cs b/Source/OpenTK/Platform/IGLControl.cs
deleted file mode 100644
index 456dd93a..00000000
--- a/Source/OpenTK/Platform/IGLControl.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-#region --- License ---
-/* Licensed under the MIT/X11 license.
- * Copyright (c) 2006-2008 the OpenTK Team.
- * This notice may not be removed from any source distribution.
- * See license.txt for licensing detailed licensing details.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using OpenTK.Graphics;
-
-namespace OpenTK.Platform
-{
- internal interface IGLControl
- {
- GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags);
- bool IsIdle { get; }
- IWindowInfo WindowInfo { get; }
- }
-}
diff --git a/Source/OpenTK/Platform/IPlatformFactory.cs b/Source/OpenTK/Platform/IPlatformFactory.cs
index 3deb813d..f0678473 100644
--- a/Source/OpenTK/Platform/IPlatformFactory.cs
+++ b/Source/OpenTK/Platform/IPlatformFactory.cs
@@ -37,8 +37,6 @@ namespace OpenTK.Platform
{
INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device);
- IGLControl CreateGLControl(GraphicsMode mode, GLControl owner);
-
IDisplayDeviceDriver CreateDisplayDeviceDriver();
IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags);
diff --git a/Source/OpenTK/Platform/MacOS/AglContext.cs b/Source/OpenTK/Platform/MacOS/AglContext.cs
index ff2e1c46..86e901ed 100644
--- a/Source/OpenTK/Platform/MacOS/AglContext.cs
+++ b/Source/OpenTK/Platform/MacOS/AglContext.cs
@@ -228,7 +228,7 @@ namespace OpenTK.Platform.MacOS
windowPort = API.GetWindowPort(carbonWindow.WindowRef);
return windowPort;
}
- public void Update(IWindowInfo window)
+ public override void Update(IWindowInfo window)
{
CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window;
diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLControl.cs b/Source/OpenTK/Platform/MacOS/CarbonGLControl.cs
deleted file mode 100644
index 48dd25bb..00000000
--- a/Source/OpenTK/Platform/MacOS/CarbonGLControl.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows.Forms;
-
-namespace OpenTK.Platform.MacOS
-{
- using Graphics;
-
- class CarbonGLControl : IGLControl
- {
- GraphicsMode mode;
- Control control;
-
- internal CarbonGLControl(GraphicsMode mode, Control owner)
- {
- this.mode = mode;
- this.control = owner;
- }
-
- #region IGLControl Members
-
- public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
- {
- return new GraphicsContext(mode, WindowInfo, major, minor, flags);
- }
-
- // TODO: Fix this
- bool lastIsIdle = false;
- public bool IsIdle
- {
- get
- {
- lastIsIdle = !lastIsIdle;
- return lastIsIdle;
- }
- }
-
- public IWindowInfo WindowInfo
- {
- get
- {
- control.CreateControl();
- return new CarbonWindowInfo(control.Handle, false, true);
- }
- }
-
- #endregion
- }
-}
diff --git a/Source/OpenTK/Platform/MacOS/MacOSFactory.cs b/Source/OpenTK/Platform/MacOS/MacOSFactory.cs
index 756a03aa..02f3be41 100644
--- a/Source/OpenTK/Platform/MacOS/MacOSFactory.cs
+++ b/Source/OpenTK/Platform/MacOS/MacOSFactory.cs
@@ -42,11 +42,6 @@ namespace OpenTK.Platform.MacOS
return new CarbonGLNative(x, y, width, height, title, mode, options, device);
}
- public virtual IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
- {
- return new CarbonGLControl(mode, owner);
- }
-
public virtual IDisplayDeviceDriver CreateDisplayDeviceDriver()
{
return new QuartzDisplayDeviceDriver();
diff --git a/Source/OpenTK/Platform/Utilities.cs b/Source/OpenTK/Platform/Utilities.cs
index 7efdaf1a..ee25db84 100644
--- a/Source/OpenTK/Platform/Utilities.cs
+++ b/Source/OpenTK/Platform/Utilities.cs
@@ -263,7 +263,7 @@ namespace OpenTK.Platform
public static void CreateGraphicsContext(GraphicsMode mode, IntPtr cntrlHandle,
out IGraphicsContext context, out IWindowInfo info)
{
- info = CreateWindowInfo(mode, cntrlHandle);
+ info = CreateWindowInfo(mode, cntrlHandle, true);
context = new GraphicsContext(mode, info);
context.MakeCurrent(info);
@@ -273,30 +273,19 @@ namespace OpenTK.Platform
#region --- CreateWindowInfo ---
- ///
- /// Creates an object which implements the IWindowInfo interface for the platform
- /// currently running on. This will create a handle for the control, so it is not
- /// recommended that this be called in the constructor of a custom control.
- ///
- /// The desired GraphicsMode for this window.
- /// A to get the IWindowInfo from.
- ///
- public static IWindowInfo CreateWindowInfo(GraphicsMode mode, Control cntrl)
- {
- return CreateWindowInfo(mode, cntrl.Handle);
- }
///
/// Creates an object which implements the IWindowInfo interface for the platform
/// currently running on.
///
/// The desired GraphicsMode for this window.
/// The handle to the control, obtained from Control.Handle.
+ /// Set to true if this is a Windows.Forms control.
///
- public static IWindowInfo CreateWindowInfo(GraphicsMode mode, IntPtr controlHandle)
+ public static IWindowInfo CreateWindowInfo(GraphicsMode mode, IntPtr controlHandle, bool isControl)
{
if (Configuration.RunningOnWindows) return CreateWinWindowInfo(controlHandle);
- else if (Configuration.RunningOnX11) return CreateX11WindowInfo(mode, controlHandle);
- else if (Configuration.RunningOnMacOS) return CreateMacOSCarbonWindowInfo(controlHandle);
+ else if (Configuration.RunningOnX11) return CreateX11WindowInfo(mode, controlHandle, isControl);
+ else if (Configuration.RunningOnMacOS) return CreateMacOSCarbonWindowInfo(controlHandle, isControl);
else
throw new PlatformNotSupportedException("Refer to http://www.opentk.com for more information.");
}
@@ -305,37 +294,42 @@ namespace OpenTK.Platform
#region --- X11 Platform-specific implementation ---
- private static IWindowInfo CreateX11WindowInfo(GraphicsMode mode, IntPtr controlHandle)
+ private static IWindowInfo CreateX11WindowInfo(GraphicsMode mode, IntPtr controlHandle, bool isControl)
{
Platform.X11.X11WindowInfo window = new OpenTK.Platform.X11.X11WindowInfo();
-
- Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
- if (xplatui == null) throw new PlatformNotSupportedException(
- "System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
-
window.WindowHandle = controlHandle;
- // get the required handles from the X11 API.
- window.Display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
- window.RootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
- window.Screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
+ if (isControl)
+ {
+ Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
+ if (xplatui == null) throw new PlatformNotSupportedException(
+ "System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
- // get the X11 Visual info for the display.
- Platform.X11.XVisualInfo info = new Platform.X11.XVisualInfo();
+ // get the required handles from the X11 API.
+ window.Display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
+ window.RootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
+ window.Screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
- if (!mode.Index.HasValue)
- throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
+ // get the X11 Visual info for the display.
+ Platform.X11.XVisualInfo info = new Platform.X11.XVisualInfo();
- info.VisualID = mode.Index.Value;
- int dummy;
- window.VisualInfo = (Platform.X11.XVisualInfo)Marshal.PtrToStructure(
- Platform.X11.Functions.XGetVisualInfo(window.Display, Platform.X11.XVisualInfoMask.ID,
- ref info, out dummy), typeof(Platform.X11.XVisualInfo));
+ if (!mode.Index.HasValue)
+ throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
- // set the X11 colormap.
- SetStaticFieldValue(xplatui, "CustomVisual", window.VisualInfo.Visual);
- SetStaticFieldValue(xplatui, "CustomColormap",
- Platform.X11.Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0));
+ info.VisualID = mode.Index.Value;
+ int dummy;
+ window.VisualInfo = (Platform.X11.XVisualInfo)Marshal.PtrToStructure(
+ Platform.X11.Functions.XGetVisualInfo(window.Display, Platform.X11.XVisualInfoMask.ID,
+ ref info, out dummy), typeof(Platform.X11.XVisualInfo));
+
+ // set the X11 colormap.
+ SetStaticFieldValue(xplatui, "CustomVisual", window.VisualInfo.Visual);
+ SetStaticFieldValue(xplatui, "CustomColormap",
+ Platform.X11.Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0));
+ }
+ else
+ {
+ }
return window;
}
@@ -351,9 +345,9 @@ namespace OpenTK.Platform
#endregion
#region --- Mac OS X Platform-specific implementation ---
- private static IWindowInfo CreateMacOSCarbonWindowInfo(IntPtr controlHandle)
+ private static IWindowInfo CreateMacOSCarbonWindowInfo(IntPtr controlHandle, bool isControl)
{
- return new OpenTK.Platform.MacOS.CarbonWindowInfo(controlHandle, false, true);
+ return new OpenTK.Platform.MacOS.CarbonWindowInfo(controlHandle, false, isControl);
}
#endregion
diff --git a/Source/OpenTK/Platform/Windows/WinFactory.cs b/Source/OpenTK/Platform/Windows/WinFactory.cs
index 7766cfb8..abf23979 100644
--- a/Source/OpenTK/Platform/Windows/WinFactory.cs
+++ b/Source/OpenTK/Platform/Windows/WinFactory.cs
@@ -43,11 +43,6 @@ namespace OpenTK.Platform.Windows
return new WinGLNative(x, y, width, height, title, options, device);
}
- public virtual IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
- {
- return new WinGLControl(mode, owner);
- }
-
public virtual IDisplayDeviceDriver CreateDisplayDeviceDriver()
{
return new WinDisplayDeviceDriver();
diff --git a/Source/OpenTK/Platform/Windows/WinGLControl.cs b/Source/OpenTK/Platform/Windows/WinGLControl.cs
deleted file mode 100644
index 8bd7fe22..00000000
--- a/Source/OpenTK/Platform/Windows/WinGLControl.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-#region --- License ---
-/* Licensed under the MIT/X11 license.
- * Copyright (c) 2006-2008 the OpenTK Team.
- * This notice may not be removed from any source distribution.
- * See license.txt for licensing detailed licensing details.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows.Forms;
-
-using OpenTK.Graphics;
-
-namespace OpenTK.Platform.Windows
-{
- class WinGLControl : IGLControl
- {
- MSG msg = new MSG();
- GraphicsMode mode;
- Control control;
- WinWindowInfo window_info;
-
- internal WinGLControl(GraphicsMode mode, Control control)
- {
- this.mode = mode;
- this.control = control;
- this.control.HandleCreated += delegate(object sender, EventArgs e)
- {
- if (window_info != null)
- window_info.Dispose();
- window_info = new WinWindowInfo(this.control.Handle, null);
- };
- this.control.HandleDestroyed += delegate(object sender, EventArgs e)
- {
- if (window_info != null)
- {
- window_info.Dispose();
- window_info = null;
- }
- };
- }
-
- #region --- IGLControl Members ---
-
- public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
- {
- // Make sure the Control exists before create the context.
- if (window_info == null)
- window_info = new WinWindowInfo(control.Handle, null);
-
- return new GraphicsContext(mode, window_info, major, minor, flags);
- }
-
- public bool IsIdle
- {
- get { return !OpenTK.Platform.Windows.Functions.PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); }
- }
-
- public IWindowInfo WindowInfo
- {
- get
- {
- // This method forces the creation of the control. Beware of this side-effect!
- return window_info;
- }
- }
-
- #endregion
- }
-}
diff --git a/Source/OpenTK/Platform/X11/X11Factory.cs b/Source/OpenTK/Platform/X11/X11Factory.cs
index a6fcaf4c..c8714821 100644
--- a/Source/OpenTK/Platform/X11/X11Factory.cs
+++ b/Source/OpenTK/Platform/X11/X11Factory.cs
@@ -15,11 +15,6 @@ namespace OpenTK.Platform.X11
return new X11GLNative(x, y, width, height, title, mode, options, device);
}
- public virtual IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
- {
- return new X11GLControl(mode, owner);
- }
-
public virtual IDisplayDeviceDriver CreateDisplayDeviceDriver()
{
return new X11XrandrDisplayDevice();
diff --git a/Source/OpenTK/Platform/X11/X11GLControl.cs b/Source/OpenTK/Platform/X11/X11GLControl.cs
deleted file mode 100644
index 49d2275c..00000000
--- a/Source/OpenTK/Platform/X11/X11GLControl.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-#region --- License ---
-/* Licensed under the MIT/X11 license.
- * Copyright (c) 2006-2008 the OpenTK Team.
- * This notice may not be removed from any source distribution.
- * See license.txt for licensing detailed licensing details.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows.Forms;
-using System.Runtime.InteropServices;
-
-using OpenTK.Graphics;
-
-namespace OpenTK.Platform.X11
-{
- class X11GLControl : IGLControl
- {
- GraphicsMode mode;
- Control control;
- IntPtr display;
-
- internal X11GLControl(GraphicsMode mode, Control control)
- {
- if (!mode.Index.HasValue)
- throw new GraphicsModeException("Invalid GraphicsMode.");
-
- this.mode = mode;
- this.control = control;
-
- X11WindowInfo window = (X11WindowInfo)this.WindowInfo;
- XVisualInfo info = new XVisualInfo();
-
- info.VisualID = mode.Index.Value;
- int dummy;
- window.VisualInfo = (XVisualInfo)Marshal.PtrToStructure(
- Functions.XGetVisualInfo(window.Display, XVisualInfoMask.ID, ref info, out dummy), typeof(XVisualInfo));
-
- Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
- xplatui.GetField("CustomVisual", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
- .SetValue(null, window.VisualInfo.Visual);
- xplatui.GetField("CustomColormap", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
- .SetValue(null, Functions.XCreateColormap(window.Display, window.RootWindow, window.VisualInfo.Visual, 0));
- }
-
- #region --- IGLControl Members ---
-
- public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
- {
- return new GraphicsContext(mode, this.WindowInfo, major, minor, flags);
- }
-
- public bool IsIdle
- {
- get { return Functions.XPending(display) == 0; }
- }
-
- public IWindowInfo WindowInfo
- {
- get
- {
- Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
- if (xplatui == null) throw new PlatformNotSupportedException(
- "System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
-
- X11WindowInfo window = new X11WindowInfo();
-
- if (control.IsHandleCreated)
- window.WindowHandle = control.Handle;
-
- display =
- window.Display = (IntPtr)xplatui.GetField("DisplayHandle",
- System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
- window.RootWindow = (IntPtr)xplatui.GetField("RootWindow",
- System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
- window.Screen = (int)xplatui.GetField("ScreenNo",
- System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
-
- if (control.IsHandleCreated)
- window.WindowHandle = control.Handle;
-
- return window;
- }
- }
-
- #endregion
- }
-}
diff --git a/Source/OpenTK/Properties/Resources.Designer.cs b/Source/OpenTK/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..5d81e741
--- /dev/null
+++ b/Source/OpenTK/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.4918
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace OpenTK.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenTK.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Source/OpenTK/Properties/Resources.resx b/Source/OpenTK/Properties/Resources.resx
new file mode 100644
index 00000000..5ea0895e
--- /dev/null
+++ b/Source/OpenTK/Properties/Resources.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file