diff --git a/Build/Build-Mono.bat b/Build/Build-Mono.bat new file mode 100644 index 00000000..8fb1a5a3 --- /dev/null +++ b/Build/Build-Mono.bat @@ -0,0 +1,4 @@ +cd.. +Build\Prebuild.exe /target nant /file prebuild.xml +NAnt.exe -t:mono-2.0 +Build\PostBuild.bat \ No newline at end of file diff --git a/Build/Build-Net.bat b/Build/Build-Net.bat new file mode 100644 index 00000000..206e3847 --- /dev/null +++ b/Build/Build-Net.bat @@ -0,0 +1,4 @@ +cd.. +Build\Prebuild.exe /target nant /file prebuild.xml +NAnt.exe -t:net-2.0 +Build\PostBuild.bat \ No newline at end of file diff --git a/Build/Build.bat b/Build/PostBuild.bat similarity index 88% rename from Build/Build.bat rename to Build/PostBuild.bat index 8419ddad..1a471325 100644 --- a/Build/Build.bat +++ b/Build/PostBuild.bat @@ -1,7 +1,3 @@ -cd.. -Build\Prebuild /target nant /file prebuild.xml -NAnt.exe - rem Copying files to output directory xcopy Source\OpenGL\Bind\bin\Release\*.exe Binaries\Release\Exe\*.* /Q /Y @@ -14,6 +10,7 @@ xcopy Source\Platform\X11\bin\Release\*.dll Binaries\Release\Libraries\*.* /Q /Y xcopy Source\Framework\bin\Release\*.dll Binaries\Release\Libraries\*.* /Q /Y xcopy Source\Examples\OpenGL\Basic\Lesson01\bin\Release\*.exe Binaries\Release\Examples\*.* /Q /Y +xcopy Source\Examples\OpenGL\Basic\DisplayLists\bin\Release\*.exe Binaries\Release\Examples\*.* /Q /Y xcopy Source\Examples\OpenGL\Basic\NoFramework\bin\Release\*.exe Binaries\Release\Examples\*.* /Q /Y xcopy Source\Examples\OpenGL\Basic\QueryDisplayModes\bin\Release\*.exe Binaries\Release\Examples\*.* /Q /Y xcopy Source\Examples\OpenGL\GLSL\Lesson01\bin\Release\*.exe Binaries\Release\Examples\*.* /Q /Y diff --git a/Release.txt b/Release.txt index fda68b7f..eb768d66 100644 --- a/Release.txt +++ b/Release.txt @@ -1,14 +1,15 @@ ================================================================================ -OpenTK 0.3.5 alpha Release notes +OpenTK 0.3.6 WIP alpha Release notes IMPORTANT: This release is not only intended for testing and experimentation, NOT for development. Use at your own risk! (see below for the reasons) -------------------------------------------------------------------------------- -This release introduces Linux support. Thanks to Erik's code you can now write a project under Linux/Mono and run it under Windows/.Net without changing a single line of code! +This is the first release to implement High-level OpenGL bindings. Highlights: -Moreover, the structure of the OpenTK.OpenGL.GL class has been changed. Only the OpenGL core functions (versions 1.0-2.1) are directly exposed now in the GL class - the extension functions will reside in new structures named after the extension categories (for example GL.Arb, GL.Ext, GL.NV, GL.Ati etc). This change will make extension functions more discoverable. Extensions are currently disabled, until some internal changes are complete in OpenTK.OpenGL.Bind to allow for this change. +OpenTK.OpenGL (High level): DisplayList. +OpenTK.Examples: OpenGL.Basic.DisplayLists -------------------------------------------------------------------------------- @@ -23,25 +24,25 @@ For the bleeding edge code, do a svn checkout at https://svn.sourceforge.net/svn The version number for this release is Major: 0 Minor: 3 -Release: 5 -Revision: 0 +Release: 6 +Revision: 1 The odd minor version number denotes that this is a WIP (Work In Progress). This means that the source and the public API (APplication Interface) changes rapidly from release to release. This is an alpha release. This means it is not feature complete - more features are planned or are in currently in development. When all planned features are ready for testing, this package will move to the beta phase, were the focus will change to testing and bug-fixing. -Missing features include Linux support and more fine-grained window and context management. Also expect the naming scheme to change over the next few versions. +Missing features include more fine-grained window and context management, several High-level OpenGL bindings and several other things. Also expect the naming scheme to change over the next few versions. ================================================================================ This package contains the source for: -OpenTK.OpenGL (0.3.5) +OpenTK.OpenGL (0.3.6.1) OpenTK.OpenGL.Bind (0.7.7.0) -OpenTK.Framework (0.3.2.0) +OpenTK.Framework (0.3.3.1) OpenTK.Platform.Windows (0.1.1.0) OpenTK.Platform.X11 (0.1.1.0) -OpenTK.OpenGL.Examples.Basic (Lesson01, NoFramework, QueryDisplayModes) +OpenTK.OpenGL.Examples.Basic (Lesson01, DisplayLists, NoFramework, QueryDisplayModes) OpenTK.OpenGL.Examples.GLSL (Lesson01) ================================================================================ \ No newline at end of file diff --git a/Source/Examples/OpenGL/Basic/DisplayLists/DisplayLists.cs b/Source/Examples/OpenGL/Basic/DisplayLists/DisplayLists.cs new file mode 100644 index 00000000..116f1ab0 --- /dev/null +++ b/Source/Examples/OpenGL/Basic/DisplayLists/DisplayLists.cs @@ -0,0 +1,168 @@ +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos. + */ +#endregion + +#region --- Using Directives --- + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using OpenTK.OpenGL; + +#endregion --- Using Directives --- + +namespace OpenTK.Examples.OpenGL.Basic.DisplayLists +{ + public partial class DisplayLists : Framework + { + #region --- Variables --- + + List lists = new List(); + + #endregion --- Variables --- + + #region --- Methods --- + + [STAThread] + public static void Main() + { + new DisplayLists().Run(); + } + + #endregion --- Methods --- + + #region --- Event Handlers --- + + #region OnLoad + + protected override void OnLoad(object sender, EventArgs e) + { + base.OnLoad(sender, e); + + Text = + "DisplayLists example (" + + GL.GetString(Enums.StringName.RENDERER) + " " + + GL.GetString(Enums.StringName.VERSION) + + ")"; + + GL.ClearColor(0.1f, 0.1f, 0.5f, 0.0f); + GL.Enable(Enums.EnableCap.DEPTH_TEST); + + // Build some display lists. + float c = 0; + const int numDisplayLists = 9; + for (int i = numDisplayLists; i > 0; i--) + { + DisplayList d = new DisplayList(); + + d.Begin(); + + GL.Color3d( + 1.0, + c, + 1 - c + ); + + GL.Begin(Enums.BeginMode.QUADS); + + GL.Vertex3f(-1.0f, -1.0f, 1.0f); + GL.Vertex3f( 1.0f, -1.0f, 1.0f); + GL.Vertex3f( 1.0f, 1.0f, 1.0f); + GL.Vertex3f(-1.0f, 1.0f, 1.0f); + + GL.End(); + + d.End(); + + lists.Add(d); + + c += 1 / (float)numDisplayLists; + } + + OnResize(this, null); + } + + #endregion + + #region OnResize + + protected override void OnResize(object sender, EventArgs e) + { + base.OnResize(sender, e); + + if (ClientSize.Height == 0) + ClientSize = new System.Drawing.Size(ClientSize.Width, 1); + + GL.Viewport(0, 0, ClientSize.Width, ClientSize.Height); + + double ratio = 0.0; + ratio = ClientSize.Width / (double)ClientSize.Height; + + GL.MatrixMode(Enums.MatrixMode.PROJECTION); + GL.LoadIdentity(); + Glu.Perspective(45.0, ratio, 1.0, 64.0); + Glu.LookAt( + 0.0, 0.0, 16.0, + 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0 + ); + } + + #endregion + + #region OnPaint + + protected override void OnPaint() + { + GL.MatrixMode(Enums.MatrixMode.MODELVIEW); + GL.LoadIdentity(); + + GL.Clear(Enums.ClearBufferMask.COLOR_BUFFER_BIT | Enums.ClearBufferMask.DEPTH_BUFFER_BIT); + + double angle = 0.0; + foreach (DisplayList d in lists) + { + GL.LoadIdentity(); + GL.Rotated(angle, 0.0, 0.0, 1.0); + GL.Translated(5.0, 0.0, 0.0); + + d.Render(); + angle += 360 / lists.Count; + } + + + ActiveContext.SwapBuffers(); + } + + #endregion + + #region OnKeyDown + + protected override void OnKeyDown(object sender, KeyEventArgs e) + { + base.OnKeyDown(sender, e); + + switch (e.KeyData) + { + case Keys.Escape: + Application.Exit(); + break; + + case Keys.F1: + this.SetResolution(this.Width, this.Height, this.ColorDepth, !this.IsFullscreen); + break; + } + } + + #endregion + + #endregion --- Event Handlers --- + } +} \ No newline at end of file diff --git a/Source/Examples/OpenGL/Basic/Lesson01/Basic01.cs b/Source/Examples/OpenGL/Basic/Lesson01/Basic01.cs index 11d98973..f28f5b58 100644 --- a/Source/Examples/OpenGL/Basic/Lesson01/Basic01.cs +++ b/Source/Examples/OpenGL/Basic/Lesson01/Basic01.cs @@ -1,3 +1,9 @@ +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Erik Ylvisaker and Stephen Apostolopoulos. + */ +#endregion + using System; using System.Collections.Generic; using System.Windows.Forms; @@ -5,11 +11,25 @@ using OpenTK.OpenGL; namespace Lesson01 { - - public class Cube : OpenTK.Frameworks.Framework + public class Cube : OpenTK.Framework { static float angle; + #region Entry point + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + new Cube().Run(); + } + + #endregion + #region Load event handler protected override void OnLoad(object sender, EventArgs e) { @@ -134,24 +154,11 @@ namespace Lesson01 GL.Color3f(0, 1, 1); GL.Vertex3f(1.0f, -1.0f, -1.0f); GL.Vertex3f(1.0f, 1.0f, -1.0f); - GL.Vertex3f(1.0f, 1.0f, 1.0f); + GL.Vertex3f(1.0f, 1.0f, 1.0f); GL.Vertex3f(1.0f, -1.0f, 1.0f); GL.End(); } #endregion - - #region Entry point - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - new Cube().Run(); - } - #endregion } } \ No newline at end of file diff --git a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs b/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs index e3c1241a..a7e41343 100644 --- a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs +++ b/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs @@ -1,9 +1,11 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos. */ #endregion +#region --- Using Directives --- + using System; using System.Collections.Generic; using System.ComponentModel; @@ -11,13 +13,17 @@ using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; -using OpenTK; + using OpenTK.OpenGL; +#endregion --- Using Directives --- + namespace OpenTK.Examples.OpenGL.GLSL { - public class Cube : OpenTK.Frameworks.Framework + public class Cube : Framework { + #region --- Variables --- + #region Shaders string[] vertex_shader_source = @@ -37,7 +43,73 @@ namespace OpenTK.Examples.OpenGL.GLSL static float angle; - #region Load event handler + #endregion --- Variables --- + + #region --- Methods --- + + #region Entry point + + [STAThread] + static void Main() + { + new Cube().Run(); + } + + #endregion + + #region DrawCube + + public void DrawCube() + { + GL.Begin(Enums.BeginMode.QUADS); + + GL.Color3f(1, 0, 0); + GL.Vertex3f(-1.0f, -1.0f, -1.0f); + GL.Vertex3f(-1.0f, 1.0f, -1.0f); + GL.Vertex3f(1.0f, 1.0f, -1.0f); + GL.Vertex3f(1.0f, -1.0f, -1.0f); + + GL.Color3f(1, 1, 0); + GL.Vertex3f(-1.0f, -1.0f, -1.0f); + GL.Vertex3f(1.0f, -1.0f, -1.0f); + GL.Vertex3f(1.0f, -1.0f, 1.0f); + GL.Vertex3f(-1.0f, -1.0f, 1.0f); + + GL.Color3f(1, 0, 1); + GL.Vertex3f(-1.0f, -1.0f, -1.0f); + GL.Vertex3f(-1.0f, -1.0f, 1.0f); + GL.Vertex3f(-1.0f, 1.0f, 1.0f); + GL.Vertex3f(-1.0f, 1.0f, -1.0f); + + GL.Color3f(0, 1, 0); + GL.Vertex3f(-1.0f, -1.0f, 1.0f); + GL.Vertex3f(1.0f, -1.0f, 1.0f); + GL.Vertex3f(1.0f, 1.0f, 1.0f); + GL.Vertex3f(-1.0f, 1.0f, 1.0f); + + GL.Color3f(0, 0, 1); + GL.Vertex3f(-1.0f, 1.0f, -1.0f); + GL.Vertex3f(-1.0f, 1.0f, 1.0f); + GL.Vertex3f(1.0f, 1.0f, 1.0f); + GL.Vertex3f(1.0f, 1.0f, -1.0f); + + GL.Color3f(0, 1, 1); + GL.Vertex3f(1.0f, -1.0f, -1.0f); + GL.Vertex3f(1.0f, 1.0f, -1.0f); + GL.Vertex3f(1.0f, 1.0f, 1.0f); + GL.Vertex3f(1.0f, -1.0f, 1.0f); + + GL.End(); + } + + #endregion + + #endregion --- Methods --- + + #region --- Event Handlers --- + + #region OnLoad + protected override void OnLoad(object sender, EventArgs e) { base.OnLoad(sender, e); @@ -88,16 +160,15 @@ namespace OpenTK.Examples.OpenGL.GLSL OnResize(sender, e); } + #endregion - #region Resize event handler + #region OnResize + protected override void OnResize(object sender, EventArgs e) { base.OnResize(sender, e); -// if (this.Context == null) -// return; - if (ClientSize.Height == 0) ClientSize = new System.Drawing.Size(ClientSize.Width, 1); @@ -105,18 +176,15 @@ namespace OpenTK.Examples.OpenGL.GLSL double ratio = 0.0; ratio = ClientSize.Width / (double)ClientSize.Height; - //if (ClientSize.Width > ClientSize.Height) - // ratio = ClientSize.Width / (double)ClientSize.Height; - //else - // ratio = ClientSize.Height / (double)ClientSize.Width; GL.MatrixMode(Enums.MatrixMode.PROJECTION); GL.LoadIdentity(); Glu.Perspective(45.0, ratio, 1.0, 64.0); } + #endregion - #region Paint event handler + #region OnPaint protected override void OnPaint() { @@ -141,7 +209,7 @@ namespace OpenTK.Examples.OpenGL.GLSL #endregion - #region KeyDown event handler + #region OnKeyDown protected override void OnKeyDown(object sender, KeyEventArgs e) { @@ -161,62 +229,6 @@ namespace OpenTK.Examples.OpenGL.GLSL #endregion - #region DrawCube - public void DrawCube() - { - GL.Begin(Enums.BeginMode.QUADS); - - GL.Color3f(1, 0, 0); - GL.Vertex3f(-1.0f, -1.0f, -1.0f); - GL.Vertex3f(-1.0f, 1.0f, -1.0f); - GL.Vertex3f(1.0f, 1.0f, -1.0f); - GL.Vertex3f(1.0f, -1.0f, -1.0f); - - GL.Color3f(1, 1, 0); - GL.Vertex3f(-1.0f, -1.0f, -1.0f); - GL.Vertex3f(1.0f, -1.0f, -1.0f); - GL.Vertex3f(1.0f, -1.0f, 1.0f); - GL.Vertex3f(-1.0f, -1.0f, 1.0f); - - GL.Color3f(1, 0, 1); - GL.Vertex3f(-1.0f, -1.0f, -1.0f); - GL.Vertex3f(-1.0f, -1.0f, 1.0f); - GL.Vertex3f(-1.0f, 1.0f, 1.0f); - GL.Vertex3f(-1.0f, 1.0f, -1.0f); - - GL.Color3f(0, 1, 0); - GL.Vertex3f(-1.0f, -1.0f, 1.0f); - GL.Vertex3f(1.0f, -1.0f, 1.0f); - GL.Vertex3f(1.0f, 1.0f, 1.0f); - GL.Vertex3f(-1.0f, 1.0f, 1.0f); - - GL.Color3f(0, 0, 1); - GL.Vertex3f(-1.0f, 1.0f, -1.0f); - GL.Vertex3f(-1.0f, 1.0f, 1.0f); - GL.Vertex3f(1.0f, 1.0f, 1.0f); - GL.Vertex3f(1.0f, 1.0f, -1.0f); - - GL.Color3f(0, 1, 1); - GL.Vertex3f(1.0f, -1.0f, -1.0f); - GL.Vertex3f(1.0f, 1.0f, -1.0f); - GL.Vertex3f(1.0f, 1.0f, 1.0f); - GL.Vertex3f(1.0f, -1.0f, 1.0f); - - GL.End(); - } - #endregion - - #region Entry point - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - new Cube().Run(); - } - #endregion + #endregion --- Event Handlers --- } } diff --git a/Source/Framework/Framework.cs b/Source/Framework/Framework.cs index 3e369cd6..6a9f8404 100644 --- a/Source/Framework/Framework.cs +++ b/Source/Framework/Framework.cs @@ -1,7 +1,6 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * Contributions from Erik Ylvisaker - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos and Erik Ylvisaker. */ #endregion @@ -13,22 +12,29 @@ using System.Drawing; using System.Threading; using OpenTK.Platform.Windows; using System.Runtime.InteropServices; + using OpenTK.OpenGL.Platform; using OpenTK.OpenGL; -namespace OpenTK.Frameworks +namespace OpenTK { public class Framework : IDisposable { + #region --- Private variables --- + private Form activeForm; private GLContext activeContext; private PlatformSpecific platform; - private OpenGL.ColorDepth _color_depth; - private int _z_depth; - private int _stencil_depth; + private OpenGL.ColorDepth colorDepth; + private int zDepth; + private int stencilDepth; - private string text = "OpenTK Windows application"; + private string text = "OpenTK application"; + + #endregion + + Application.MessageLoopCallback MessageLoop; #region --- Public Properties --- @@ -37,11 +43,13 @@ namespace OpenTK.Frameworks get { return activeForm; } } + public GLContext ActiveContext { get { return activeContext; } private set { activeContext = value; } } + public string Text { get { return text; } @@ -53,21 +61,25 @@ namespace OpenTK.Frameworks activeForm.Text = value; } } + public Size ClientSize { get { return ActiveForm.ClientSize; } set { activeForm.ClientSize = value; } } + public int Width { get { return ClientSize.Width; } set { ClientSize = new Size(value, ClientSize.Height); } } + public int Height { get { return ClientSize.Height; } set { ClientSize = new Size(ClientSize.Width, value); } } + public bool IsFullscreen { get @@ -78,18 +90,20 @@ namespace OpenTK.Frameworks public OpenGL.ColorDepth ColorDepth { - get { return _color_depth; } - private set { _color_depth = value; } + get { return colorDepth; } + private set { colorDepth = value; } } + public int ZDepth { - get { return _z_depth; } - set { _z_depth = value; } + get { return zDepth; } + set { zDepth = value; } } + public int StencilDepth { - get { return _stencil_depth; } - set { _stencil_depth = value; } + get { return stencilDepth; } + set { stencilDepth = value; } } #endregion @@ -97,11 +111,22 @@ namespace OpenTK.Frameworks #region --- Creation and Destruction --- /// - /// Constructs a Framework object. + /// Constructs a Framework object with default (safe) parameters. /// public Framework() - : this(null, 800, 600, new OpenTK.OpenGL.ColorDepth(8, 8, 8, 8), 16, 0, false) + : this(null, 640, 480, new OpenTK.OpenGL.ColorDepth(8, 8, 8, 8), 16, 0, false) { } + + /// + /// Construcs a Framework object with the given parameters. + /// + /// The Title of the Form. + /// The Width of the Form. + /// The Height of the Form. + /// The ColorDepth of the OpenGL Context. + /// The ZDepth of the OpenGL Context. + /// The StencilDepth of the OpenGL Context. + /// The Fullscreen property of the Form. public Framework(string title, int width, int height, OpenTK.OpenGL.ColorDepth color, int depth, int stencil, bool fullscreen) { @@ -132,6 +157,7 @@ namespace OpenTK.Frameworks activeContext.Dispose(); activeContext = null; } + if (activeForm != null) { activeForm.Dispose(); @@ -161,6 +187,10 @@ namespace OpenTK.Frameworks else CreateWindowedDisplay(width, height); + //Application.Idle += this.OnIdle; + + //MessageLoop = new Application.MessageLoopCallback(MainLoop); + //Application.RegisterMessageLoop(MessageLoop); System.Console.WriteLine("Done Initializing."); } @@ -177,9 +207,12 @@ namespace OpenTK.Frameworks AttachEvents(activeForm); - activeForm.Show(); - activeForm.ClientSize = new Size(width, height); + + activeForm.TopMost = true; + activeForm.Enabled = true; + + activeForm.Show(); } private void CreateFullScreenDisplay(int width, int height) @@ -194,93 +227,119 @@ namespace OpenTK.Frameworks AttachEvents(activeForm); - activeForm.Show(); - + activeForm.FormBorderStyle = FormBorderStyle.None; activeForm.ClientSize = new Size(width, height); activeForm.Location = Point.Empty; - activeContext.SetFullScreen(width, height, ColorDepth); + activeForm.TopMost = true; + activeForm.Enabled = true; - + activeForm.Show(); + + activeContext.SetFullScreen(width, height, ColorDepth); } private void AttachEvents(Form frm) { - frm.Load += new EventHandler(OnLoad); - frm.Resize += new EventHandler(OnResize); - frm.Paint += new PaintEventHandler(OnPaint); - frm.KeyDown += new KeyEventHandler(OnKeyDown); - frm.KeyUp += new KeyEventHandler(OnKeyUp); - frm.KeyPress += new KeyPressEventHandler(OnKeyPress); - frm.Click += new EventHandler(OnClick); - frm.MouseDown += new MouseEventHandler(OnMouseDown); - frm.MouseEnter += new EventHandler(OnMouseEnter); - frm.MouseHover += new EventHandler(OnMouseHover); - frm.MouseLeave += new EventHandler(OnMouseLeave); - frm.MouseMove += new MouseEventHandler(OnMouseMove); - frm.MouseUp += new MouseEventHandler(OnMouseUp); - frm.MouseWheel += new MouseEventHandler(OnMouseWheel); + frm.Load += this.OnLoad; + frm.Resize += this.OnResize; + frm.Paint += this.OnPaint; + frm.KeyDown += this.OnKeyDown; + frm.KeyUp += this.OnKeyUp; + frm.KeyPress += this.OnKeyPress; + frm.Click += this.OnClick; + frm.MouseDown += this.OnMouseDown; + frm.MouseEnter += this.OnMouseEnter; + frm.MouseHover += this.OnMouseHover; + frm.MouseLeave += this.OnMouseLeave; + frm.MouseMove += this.OnMouseMove; + frm.MouseUp += this.OnMouseUp; + frm.MouseWheel += this.OnMouseWheel; } #endregion - #region Events - + #region --- Events --- + + virtual protected void OnIdle(object sender, EventArgs e) + { + while (ActiveForm != null && platform.IsIdle()) + { + if (!ActiveForm.Focused) + { + Thread.Sleep(100); + } + + this.OnPaint(); + } + } + virtual protected void OnMouseWheel(object sender, MouseEventArgs e) { if (MouseWheel != null) MouseWheel(sender, e); } + virtual protected void OnMouseUp(object sender, MouseEventArgs e) { if (MouseUp != null) MouseUp(sender, e); } + virtual protected void OnMouseMove(object sender, MouseEventArgs e) { if (MouseMove != null) MouseMove(sender, e); } + virtual protected void OnMouseLeave(object sender, EventArgs e) { if (MouseLeave != null) MouseLeave(sender, e); } + virtual protected void OnMouseHover(object sender, EventArgs e) { if (MouseHover != null) MouseHover(sender, e); } + virtual protected void OnMouseEnter(object sender, EventArgs e) { if (MouseEnter != null) MouseEnter(sender, e); } + virtual protected void OnMouseDown(object sender, MouseEventArgs e) { if (MouseDown != null) MouseDown(sender, e); } + virtual protected void OnClick(object sender, EventArgs e) { if (Click != null) Click(sender, e); } + virtual protected void OnKeyPress(object sender, KeyPressEventArgs e) { if (KeyPress != null) KeyPress(sender, e); } + virtual protected void OnKeyUp(object sender, KeyEventArgs e) { if (KeyUp != null) KeyUp(sender, e); } + virtual protected void OnKeyDown(object sender, KeyEventArgs e) { if (KeyDown != null) KeyDown(sender, e); } + private void OnPaint(object sender, PaintEventArgs e) { OnPaint(); @@ -288,6 +347,7 @@ namespace OpenTK.Frameworks if (Paint != null) Paint(sender, e); } + virtual protected void OnPaint() { } @@ -297,6 +357,7 @@ namespace OpenTK.Frameworks if (Resize != null) Resize(sender, e); } + virtual protected void OnLoad(object sender, EventArgs e) { if (Load != null) @@ -322,7 +383,7 @@ namespace OpenTK.Frameworks #endregion - #region Window Management + #region --- Window Management --- private void DisposeForm() { @@ -330,7 +391,7 @@ namespace OpenTK.Frameworks activeContext.Dispose(); if (activeForm != null) activeForm.Dispose(); - + activeContext = null; activeForm = null; } @@ -356,22 +417,29 @@ namespace OpenTK.Frameworks #endregion - #region Render Loop + #region --- Main Loop --- + /// + /// Enters the Framework's main loop, updating state and rendering. + /// public void Run() { + // TODO: Find a better main loop. This is evil! (Probably a custom main loop or something based on the Idle event). while (ActiveForm != null && ActiveForm.IsDisposed == false) { OnPaint(this, null); - + if (platform.IsIdle() == false) Application.DoEvents(); } } - + #endregion } + + #region Old Code + /* public partial class Framework : Form, IDisposable { @@ -621,4 +689,6 @@ namespace OpenTK.Frameworks #endregion } * */ + + #endregion } diff --git a/Source/Framework/FrameworkImplementation.cs b/Source/Framework/FrameworkImplementation.cs deleted file mode 100644 index 67ecbbd1..00000000 --- a/Source/Framework/FrameworkImplementation.cs +++ /dev/null @@ -1,22 +0,0 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * See license.txt for license info - */ -#endregion - -using System; -using System.Collections.Generic; -using System.Text; -using System.Drawing; - -namespace OpenTK.Frameworks -{ - internal abstract class FrameworkImplementation - { - public abstract void OnHandleCreated(object sender, EventArgs args); - public abstract bool IsIdle(); - public abstract void Setup(); - //abstract public void CloseWindow(); - public abstract void SetResolution(int width, int height, OpenTK.OpenGL.ColorDepth color, bool fullscreen); - } -} \ No newline at end of file diff --git a/Source/Framework/FullScreenForm.Designer.cs b/Source/Framework/FullScreenForm.Designer.cs deleted file mode 100644 index baf8f640..00000000 --- a/Source/Framework/FullScreenForm.Designer.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace OpenTK -{ - partial class FullScreenForm - { - /// - /// 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 Windows Form 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(); - // - // FullScreenForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(292, 266); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.KeyPreview = true; - this.Name = "FullScreenForm"; - this.Text = "FullScreenForm"; - this.ResumeLayout(false); - - } - - #endregion - } -} \ No newline at end of file diff --git a/Source/Framework/FullScreenForm.cs b/Source/Framework/FullScreenForm.cs index 13cb470a..5338313b 100644 --- a/Source/Framework/FullScreenForm.cs +++ b/Source/Framework/FullScreenForm.cs @@ -17,8 +17,6 @@ namespace OpenTK //this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // Buffer Control //this.SetStyle(ControlStyles.ResizeRedraw, true); // Redraw On Resize this.SetStyle(ControlStyles.UserPaint, true); // We'll Handle Painting Ourselves - - InitializeComponent(); } } } \ No newline at end of file diff --git a/Source/Framework/FullScreenForm.resx b/Source/Framework/FullScreenForm.resx deleted file mode 100644 index ff31a6db..00000000 --- a/Source/Framework/FullScreenForm.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 diff --git a/Source/Framework/Platform.cs b/Source/Framework/Platform.cs index b0d82cd3..f1d50aa0 100644 --- a/Source/Framework/Platform.cs +++ b/Source/Framework/Platform.cs @@ -35,5 +35,10 @@ namespace OpenTK { return false; } + + public virtual bool ProcessEvents() + { + return false; + } } } diff --git a/Source/Framework/WindowedForm.Designer.cs b/Source/Framework/WindowedForm.Designer.cs deleted file mode 100644 index affe60c7..00000000 --- a/Source/Framework/WindowedForm.Designer.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace OpenTK -{ - partial class WindowedForm - { - /// - /// 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 Windows Form 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(); - // - // WindowedForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(292, 266); - this.KeyPreview = true; - this.Name = "WindowedForm"; - this.Text = "Form1"; - this.ResumeLayout(false); - - } - - #endregion - } -} \ No newline at end of file diff --git a/Source/Framework/WindowedForm.cs b/Source/Framework/WindowedForm.cs index 4dc46707..0542e315 100644 --- a/Source/Framework/WindowedForm.cs +++ b/Source/Framework/WindowedForm.cs @@ -17,8 +17,6 @@ namespace OpenTK //this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // Buffer Control //this.SetStyle(ControlStyles.ResizeRedraw, true); // Redraw On Resize this.SetStyle(ControlStyles.UserPaint, true); // We'll Handle Painting Ourselves - - InitializeComponent(); } } } \ No newline at end of file diff --git a/Source/Framework/WindowedForm.resx b/Source/Framework/WindowedForm.resx deleted file mode 100644 index ff31a6db..00000000 --- a/Source/Framework/WindowedForm.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 diff --git a/Source/Framework/WindowsPlatform.cs b/Source/Framework/WindowsPlatform.cs index e257ebad..8c77d042 100644 --- a/Source/Framework/WindowsPlatform.cs +++ b/Source/Framework/WindowsPlatform.cs @@ -13,5 +13,12 @@ namespace OpenTK WinApi.Message msg; return !WinApi.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0); } + + public override bool ProcessEvents() + { + + + return base.ProcessEvents(); + } } } diff --git a/Source/OpenGL/OpenGL/ColorDepth.cs b/Source/OpenGL/OpenGL/ColorDepth.cs index ba324ca2..e370147a 100644 --- a/Source/OpenGL/OpenGL/ColorDepth.cs +++ b/Source/OpenGL/OpenGL/ColorDepth.cs @@ -1,9 +1,8 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos. */ #endregion - using System; using System.Drawing; using System.Globalization; diff --git a/Source/OpenGL/OpenGL/Contexts/GLContext.cs b/Source/OpenGL/OpenGL/Contexts/GLContext.cs index cdaba70e..94a82dff 100644 --- a/Source/OpenGL/OpenGL/Contexts/GLContext.cs +++ b/Source/OpenGL/OpenGL/Contexts/GLContext.cs @@ -1,7 +1,6 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * Contributions from Erik Ylvisaker - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos and Erik Ylvisaker. */ #endregion diff --git a/Source/OpenGL/OpenGL/Contexts/WindowsContext.cs b/Source/OpenGL/OpenGL/Contexts/WindowsContext.cs index 04b5c2e1..05186bdb 100644 --- a/Source/OpenGL/OpenGL/Contexts/WindowsContext.cs +++ b/Source/OpenGL/OpenGL/Contexts/WindowsContext.cs @@ -1,7 +1,6 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * Contributions from Erik Ylvisaker - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos and Erik Ylvisaker. */ #endregion diff --git a/Source/OpenGL/OpenGL/Contexts/X11Context.cs b/Source/OpenGL/OpenGL/Contexts/X11Context.cs index 4dedb381..f0ceb51f 100644 --- a/Source/OpenGL/OpenGL/Contexts/X11Context.cs +++ b/Source/OpenGL/OpenGL/Contexts/X11Context.cs @@ -1,7 +1,6 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * Contributions from Erik Ylvisaker - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos and Erik Ylvisaker. */ #endregion diff --git a/Source/OpenGL/OpenGL/DisplayMode.cs b/Source/OpenGL/OpenGL/DisplayMode.cs index 569c3d21..9a6d9789 100644 --- a/Source/OpenGL/OpenGL/DisplayMode.cs +++ b/Source/OpenGL/OpenGL/DisplayMode.cs @@ -1,6 +1,6 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos. */ #endregion @@ -78,6 +78,5 @@ namespace OpenTK.OpenGL } #endregion - } } diff --git a/Source/OpenGL/OpenGL/GL.cs b/Source/OpenGL/OpenGL/GL.cs index c42fc627..5b47010f 100644 --- a/Source/OpenGL/OpenGL/GL.cs +++ b/Source/OpenGL/OpenGL/GL.cs @@ -1,3 +1,9 @@ +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos. + */ +#endregion + using System; using System.Collections.Generic; using System.Text; @@ -27,7 +33,7 @@ namespace OpenTK.OpenGL private static Delegate MacOSGetAddress(string function_string, Type function_type) { - throw new NotImplementedException("THis platform is not supported yet. Sorry for the inconvenience."); + throw new NotImplementedException("This platform is not supported yet. Sorry for the inconvenience."); } } } diff --git a/Source/OpenGL/OpenGL/Glu.cs b/Source/OpenGL/OpenGL/Glu.cs index c8b48015..1c2f7500 100644 --- a/Source/OpenGL/OpenGL/Glu.cs +++ b/Source/OpenGL/OpenGL/Glu.cs @@ -1,6 +1,8 @@ -/* Copyright (c) 2006 Stephen Apostolopoulos - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos. */ +#endregion using System; using System.Collections.Generic; diff --git a/Source/OpenGL/OpenGL/Glx.cs b/Source/OpenGL/OpenGL/Glx.cs index 262a8d1b..88dc97c8 100644 --- a/Source/OpenGL/OpenGL/Glx.cs +++ b/Source/OpenGL/OpenGL/Glx.cs @@ -1,7 +1,6 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * Contributions from Erik Ylvisaker - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos and Erik Ylvisaker. */ #endregion diff --git a/Source/OpenGL/OpenGL/OpenTK.OpenGL.dll.config b/Source/OpenGL/OpenGL/OpenTK.OpenGL.dll.config index e4155d9a..8f8d39bf 100644 --- a/Source/OpenGL/OpenGL/OpenTK.OpenGL.dll.config +++ b/Source/OpenGL/OpenGL/OpenTK.OpenGL.dll.config @@ -1,4 +1,4 @@ - - + + \ No newline at end of file diff --git a/Source/OpenGL/OpenGL/Properties/AssemblyInfo.cs b/Source/OpenGL/OpenGL/Properties/AssemblyInfo.cs index 3d9c64a0..8b3f54cc 100644 --- a/Source/OpenGL/OpenGL/Properties/AssemblyInfo.cs +++ b/Source/OpenGL/OpenGL/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.3.4.0")] -[assembly: AssemblyFileVersion("0.3.4.0")] +[assembly: AssemblyVersion("0.3.4.1")] +[assembly: AssemblyFileVersion("0.3.4.1")] diff --git a/Source/OpenGL/OpenGL/Wgl.cs b/Source/OpenGL/OpenGL/Wgl.cs index 6349edc0..d4f12261 100644 --- a/Source/OpenGL/OpenGL/Wgl.cs +++ b/Source/OpenGL/OpenGL/Wgl.cs @@ -1,6 +1,6 @@ -#region License -/* Copyright (c) 2006 Stephen Apostolopoulos - * See license.txt for license info +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos. */ #endregion diff --git a/Todo.txt b/Todo.txt index 24b95794..8dc01673 100644 --- a/Todo.txt +++ b/Todo.txt @@ -1,16 +1,44 @@ -Todo: -+ + + [In progress] Restore the Extensions. -+ + + Fully implement Framework class. -+ + + [In progress] Correct the Dispose methods to correctly clean resources (they should also call GC.SupressFinalize(true)) -+ + + Add the CLS compliant attribute to the GL class. -+ + Document projects (source and manuals). -+ + [In progress] Add more constructors to the Context classes. -+ [In progress] Add more examples. -+ Find out what is needed for the MacOS platform (how to do function loading and window management without X11). -+ Add full bindings for glu, wgl, glx and agl (probably generated automatically). -+ Add the Math module. -+ Research and add the Input module. -+ Review and add the Timer module. -+ Review and add the OpenAL module. -+ [In progress] Clean up the code. -+ Add more platform bindings. \ No newline at end of file +Generic Todos: + ++ Check if resources are correctly cleaned. + + +OpenTK.OpenGL todos: + +(High level) ++ VertexBufferObject class. ++ Error class. ++ Device class. ++ OpenGL function overloads. + +(Low level) ++ Restore the Extensions. ++ Mark the GL class as CLS compliant. ++ Inline XML documentation. ++ Add support for the MacOS X platform. ++ Add complete Wgl, Glx, Agl and Glu bindings. + +Context class: ++ Add more constructors. ++ Add support for the MacOS X platform. + +Examples: ++ Homogenize the example layout. ++ Add comments were needed. + + +OpenTK.Math todos: ++ Start implementing the Math module. + + +OpenTK.Input todos: ++ Start researching the Input module. + + +OpenTK.Timer todos: ++ Start researching the Timer module. + + +OpenTK.OpenAL todos: ++ Start researching the OpenAL module. ++ Take a look at the OpenALDotNet wrapper. \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index 15e1c898..ef652289 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +OpenTK 0.3.5 -> 0.3.6 ++ OpenTK.OpenGL (High level) + + Added the DisplayList class. ++ OpenTK.Examples.OpenGL + + Added the Basic.DisplayLists example. + + OpenTK 0.3.4 -> 0.3.5 + Thanks to Erik Ylvisaker's hard work, OpenTK now works under both Windows and X11. + The GLContext class now contains all needed code for mode switching. diff --git a/prebuild.xml b/prebuild.xml index 6dfa3bea..15e666c1 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -164,6 +164,34 @@ + + + + + + + + + + + + + ..\..\..\..\..\Binaries\Debug\Examples + + + + + + ..\..\..\..\..\Binaries\Release\Examples + + + + + + + + + @@ -190,6 +218,7 @@ + @@ -216,6 +245,7 @@ + @@ -242,6 +272,7 @@ +