diff --git a/OpenTK.sln b/OpenTK.sln
index 8fd3a12c..696cf0a3 100644
--- a/OpenTK.sln
+++ b/OpenTK.sln
@@ -23,7 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specifications", "Specifica
Specifications\glxenumext.spec = Specifications\glxenumext.spec
Specifications\glxext.spec = Specifications\glxext.spec
Specifications\try.spec = Specifications\try.spec
- Specifications\TypeMap.txt = Specifications\TypeMap.txt
Specifications\wgl.spec = Specifications\wgl.spec
Specifications\wgl.tm = Specifications\wgl.tm
Specifications\wglenum.spec = Specifications\wglenum.spec
@@ -49,8 +48,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OpenGL", "OpenGL", "{2F3FEA
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.OpenGL", "Source\OpenGL\OpenGL\OpenTK.OpenGL.csproj", "{836876D1-0C8D-4240-BEE4-859D9D3D46CB}"
ProjectSection(ProjectDependencies) = postProject
- {FDFA00B6-FA81-4658-86E1-F312EFB42E1C} = {FDFA00B6-FA81-4658-86E1-F312EFB42E1C}
{1EDDE592-3923-4898-9006-3D69579E1745} = {1EDDE592-3923-4898-9006-3D69579E1745}
+ {FDFA00B6-FA81-4658-86E1-F312EFB42E1C} = {FDFA00B6-FA81-4658-86E1-F312EFB42E1C}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.OpenGL.Bind", "Source\OpenGL\Bind\OpenTK.OpenGL.Bind.csproj", "{1EDDE592-3923-4898-9006-3D69579E1745}"
@@ -65,7 +64,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Platform.X", "Source
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{508EF114-8C2A-470D-89FE-5AC15B336B4C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework", "Source\Framework\Framework.csproj", "{26B55626-4EAB-4CAE-82FE-93CD6564D9EA}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Framework", "Source\Framework\OpenTK.Framework.csproj", "{26B55626-4EAB-4CAE-82FE-93CD6564D9EA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs b/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs
index f751e8cb..a485cda2 100644
--- a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs
+++ b/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs
@@ -11,7 +11,7 @@ using OpenTK.OpenGL;
namespace OpenTK.Examples.OpenGL.GLSL
{
- public partial class Cube : Framework
+ public partial class Cube : OpenTK.Frameworks.Framework
{
#region Shaders
string[] vertex_shader_source =
@@ -88,6 +88,9 @@ namespace OpenTK.Examples.OpenGL.GLSL
{
base.OnResize(e);
+// if (this.Context == null)
+// return;
+
if (ClientSize.Height == 0)
ClientSize = new System.Drawing.Size(ClientSize.Width, 1);
@@ -126,7 +129,7 @@ namespace OpenTK.Examples.OpenGL.GLSL
DrawCube();
Context.SwapBuffers();
- //this.Invalidate();
+ this.Invalidate();
}
#endregion
@@ -198,4 +201,4 @@ namespace OpenTK.Examples.OpenGL.GLSL
}
#endregion
}
-}
\ No newline at end of file
+}
diff --git a/Source/Examples/OpenGL/GLSL/Lesson01/GLSL.Lesson01.csproj b/Source/Examples/OpenGL/GLSL/Lesson01/GLSL.Lesson01.csproj
index c80395de..9d317c27 100644
--- a/Source/Examples/OpenGL/GLSL/Lesson01/GLSL.Lesson01.csproj
+++ b/Source/Examples/OpenGL/GLSL/Lesson01/GLSL.Lesson01.csproj
@@ -5,16 +5,23 @@
8.0.50727
2.0
{46980D11-67FA-4B33-903F-BC9D8A4FE60F}
- Exe
+ WinExe
Properties
OpenTK.Examples.OpenGL.GLSL
GLSL.Lesson01
-
-
+ False
+ False
+ False
+ False
+ Auto
+ 4194304
+ AnyCPU
+ 4096
+ false
true
- full
+ Full
false
..\..\..\..\..\Binaries\Debug\Examples\
DEBUG;TRACE
@@ -63,9 +70,9 @@
-
+
{26B55626-4EAB-4CAE-82FE-93CD6564D9EA}
- Framework %28Projects\OpenTK\Framework\Framework%29
+ OpenTK.Framework
{836876D1-0C8D-4240-BEE4-859D9D3D46CB}
@@ -76,5 +83,5 @@
OpenTK.Platform.Windows
-
+
\ No newline at end of file
diff --git a/Source/Framework/Framework.cs b/Source/Framework/Framework.cs
index 25e0bc38..509bb97f 100644
--- a/Source/Framework/Framework.cs
+++ b/Source/Framework/Framework.cs
@@ -15,40 +15,111 @@ using System.Runtime.InteropServices;
using OpenTK.OpenGL.Platform;
using OpenTK.OpenGL;
-namespace OpenTK
+namespace OpenTK.Frameworks
{
- public class Framework : Form, IDisposable
+ public partial class Framework : Form, IDisposable
{
+ #region Public properties
+
#region Context
+
private GLContext _context;
public GLContext Context
{
get { return _context; }
- set { _context = value; }
+ protected set { _context = value; }
}
+
#endregion
- delegate bool IsIdleDelegate();
- IsIdleDelegate IsIdle;
+ #region Fullscreen property
+
+ private bool _fullscreen;
+
+ public bool Fullscreen
+ {
+ get { return _fullscreen; }
+ set { _fullscreen = Implementation.ToggleFullscreen(_fullscreen); }
+ }
+
+ #endregion
+
+ #region DesktopResolution property
+
+ private Size _desktop_resolution;
+
+ public Size DesktopResolution
+ {
+ get { return _desktop_resolution; }
+ protected set { _desktop_resolution = value; }
+ }
+
+ #endregion
+
+ #region DesktopRefreshRate property
+
+ private float _desktop_refresh_rate;
+
+ public float DesktopRefreshRate
+ {
+ get { return _desktop_refresh_rate; }
+ protected set { _desktop_refresh_rate = value; }
+ }
+
+ #endregion
+
+ #endregion
+
+ FrameworkImplementation Implementation;
#region Constructors
public Framework()
{
- Open(null, 640, 480, 8, 8, 8, 8, 16, 0, false);
+ Setup(null, 640, 480, 8, 8, 8, 8, 16, 0, false);
}
public Framework(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
{
- Open(title, width, height, red, green, blue, alpha, depth, stencil, fullscreen);
+ Setup(title, width, height, red, green, blue, alpha, depth, stencil, fullscreen);
}
#endregion
- public void Open(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
+ public void Setup(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
{
- Application.Idle += new EventHandler(OnIdle);
+ // Set platform.
+ try
+ {
+ if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32Windows)
+ {
+ Implementation = new WindowsImplementation(this);
+ }
+ else if (Environment.OSVersion.Platform == PlatformID.Unix)
+ {
+ Implementation = new X11Implementation();
+ }
+ else
+ {
+ throw new PlatformNotSupportedException("The platform on which you are trying to run this program is not currently supported. Sorry for the inconvenience.");
+ }
+ }
+ catch (Exception e)
+ {
+ MessageBox.Show(e.ToString());
+ throw e;
+ }
+
+ Implementation.Setup();
+ this.HandleCreated += new EventHandler(Implementation.OnHandleCreated);
+
+ //Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
+ //if (xplatui != null)
+ //{
+ // Context = GLContext.Create(this, 8, 8, 8, 8, 16, 0);
+ // //Context.MakeCurrent();
+ //}
Context = GLContext.Create(this, red, green, blue, alpha, depth, stencil);
@@ -60,85 +131,15 @@ namespace OpenTK
//this.SetStyle(ControlStyles.ResizeRedraw, true); // Redraw On Resize
this.SetStyle(ControlStyles.UserPaint, true); // We'll Handle Painting Ourselves
- try
- {
- if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
- Environment.OSVersion.Platform == PlatformID.Win32Windows)
- {
- IsIdle = new IsIdleDelegate(WindowsIsIdle);
- WindowsOpen(title, width, height, red, green, blue, alpha, depth, stencil, fullscreen);
- }
- else if (Environment.OSVersion.Platform == PlatformID.Unix)
- {
- IsIdle = new IsIdleDelegate(XIsIdle);
- }
- else
- {
- throw new PlatformNotSupportedException("The platform on which you are trying to run this program is not currently supported. Sorry for the inconvenience.");
- }
- }
- catch (Exception e)
- {
- MessageBox.Show(e.ToString());
- }
- }
-
- #region Open functions
-
- public void WindowsOpen(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
- {
if (title == null)
title = "OpenTK Windows application";
this.Text = title;
- if (fullscreen)
- {
- Api.DeviceMode ScreenSettings = new Api.DeviceMode(); // Device Mode
- ScreenSettings.Size = (short)Marshal.SizeOf(ScreenSettings); // Size Of The Devmode Structure
- ScreenSettings.PelsWidth = width; // Selected Screen Width
- ScreenSettings.PelsHeight = height; // Selected Screen Height
- ScreenSettings.BitsPerPel = red + green + blue + alpha; // Selected Bits Per Pixel
- ScreenSettings.Fields = Api.Constants.DM_BITSPERPEL | Api.Constants.DM_PELSWIDTH | Api.Constants.DM_PELSHEIGHT;
-
- // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
- if (Api.ChangeDisplaySettings(ref ScreenSettings, Api.Constants.CDS_FULLSCREEN) == Api.Constants.DISP_CHANGE_SUCCESSFUL)
- {
- this.FormBorderStyle = FormBorderStyle.None;
- this.StartPosition = FormStartPosition.Manual;
- this.Location = new System.Drawing.Point(0, 0);
- this.Region = new Region(new Rectangle(0, 0, width, height));
- this.Capture = true;
- this.SetTopLevel(true);
- Cursor.Hide();
- }
- else
- {
- // Handle failure.
- }
- }
-
this.Size = new Size(width, height);
+
+ Application.Idle += new EventHandler(OnIdle);
}
- public void XOpen(string title, int width, int height, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen)
- {
- Context = GLContext.Create(this, red, green, blue, alpha, depth, stencil);
-
- if (title == null)
- title = "OpenTK X application";
- this.Text = title;
-
- this.Size = new Size(width, height);
- }
-
- #endregion
-
- //override protected void WndProc(ref Message m)
- //{
- // base.WndProc(ref m);
- // //OnPaint(null);
- //}
-
#region Event Handlers
///
@@ -146,9 +147,9 @@ namespace OpenTK
///
/// Not used.
/// Not used.
- private void OnIdle(object sender, EventArgs e)
+ protected void OnIdle(object sender, EventArgs args)
{
- while (IsIdle())
+ while (Implementation.IsIdle())
{
if (ActiveForm != this)
Thread.Sleep(100);
@@ -156,21 +157,6 @@ namespace OpenTK
}
}
- ///
- /// Checks if there all pending messages have been processed.
- ///
- /// Returns true if there are no messages left, false otherwise.
- private bool WindowsIsIdle()
- {
- Api.Message msg;
- return !OpenTK.Platform.Windows.Api.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
- }
-
- private bool XIsIdle()
- {
- throw new NotImplementedException("IsIdle handler not implemented yet!");
- }
-
#endregion
#region IDisposable Members
diff --git a/Source/Framework/FrameworkImplementation.cs b/Source/Framework/FrameworkImplementation.cs
new file mode 100644
index 00000000..35ba90ca
--- /dev/null
+++ b/Source/Framework/FrameworkImplementation.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+
+namespace OpenTK.Frameworks
+{
+ public partial class Framework
+ {
+ internal abstract class FrameworkImplementation
+ {
+ abstract public void OnHandleCreated(object sender, EventArgs args);
+ abstract public bool IsIdle();
+ abstract public void Setup();
+ //abstract public void CloseWindow();
+ abstract public bool ToggleFullscreen(bool fullscreen);
+ }
+ }
+}
diff --git a/Source/Framework/Framework.csproj b/Source/Framework/OpenTK.Framework.csproj
similarity index 82%
rename from Source/Framework/Framework.csproj
rename to Source/Framework/OpenTK.Framework.csproj
index 494dca43..3ac5840e 100644
--- a/Source/Framework/Framework.csproj
+++ b/Source/Framework/OpenTK.Framework.csproj
@@ -7,8 +7,10 @@
{26B55626-4EAB-4CAE-82FE-93CD6564D9EA}
Library
Properties
- Framework
- Framework
+ OpenTK
+ OpenTK.Framework
+
+
true
@@ -38,7 +40,16 @@
Form
+
+ Form
+
+
+ Form
+
+
+ Form
+
@@ -54,6 +65,9 @@
OpenTK.Platform.X
+
+
+