diff --git a/OpenTK.sln b/OpenTK.sln index 462156bc..7af77bcf 100644 --- a/OpenTK.sln +++ b/OpenTK.sln @@ -5,11 +5,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentat ProjectSection(SolutionItems) = preProject changelog.txt = changelog.txt license.txt = license.txt - Todo.txt = Todo.txt + todo.txt = todo.txt EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{84C34705-D460-4028-AE58-C32CF210F9BF}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Specifications", "Specifications", "{B23A6DCD-9FE9-4523-95FB-01C8D4631555}" ProjectSection(SolutionItems) = preProject Specifications\cs_types.txt = Specifications\cs_types.txt @@ -75,7 +73,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {84C34705-D460-4028-AE58-C32CF210F9BF} = {80BD2C66-A90B-42E7-BED8-CBF7BB8C2E3F} {7E640424-E2CD-4DD5-9392-7A706D73930E} = {E9FF51BB-295E-4891-AA30-D1374F26DCE0} {C6E60A87-12B4-444A-BE03-7E980EAC0172} = {E9FF51BB-295E-4891-AA30-D1374F26DCE0} {50DCE788-72FC-47E0-A6BD-50BCCE3FCE5B} = {7E640424-E2CD-4DD5-9392-7A706D73930E} diff --git a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.Designer.cs b/Source/Examples/OpenGL/GLSL/Lesson01/Cube.Designer.cs deleted file mode 100644 index b55c3f25..00000000 --- a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.Designer.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace OpenTK.Examples.OpenGL.GLSL -{ - partial class Cube - { - /// - /// 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(); - // - // Cube - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(632, 446); - this.Name = "Cube"; - this.Text = "GLSL.Lesson01"; - this.ResumeLayout(false); - - } - - #endregion - } -} - diff --git a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs b/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs index 06ffe4d5..37033091 100644 --- a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs +++ b/Source/Examples/OpenGL/GLSL/Lesson01/Cube.cs @@ -27,13 +27,11 @@ namespace OpenTK.Examples.OpenGL.GLSL }; #endregion - GLContext context; static float angle; #region Constructor public Cube() { - InitializeComponent(); } #endregion @@ -42,8 +40,6 @@ namespace OpenTK.Examples.OpenGL.GLSL { base.OnLoad(e); - context = GLContext.Create(this, 8, 8, 8, 8, 16, 0, false); - Text = GL.GetString(Enums.StringName.VENDOR) + " " + GL.GetString(Enums.StringName.RENDERER) + " " + @@ -78,7 +74,7 @@ namespace OpenTK.Examples.OpenGL.GLSL GL.LinkProgram(shader_program); GL.UseProgram(shader_program); - OnResize(e); + //OnResize(e); } #endregion @@ -89,15 +85,13 @@ namespace OpenTK.Examples.OpenGL.GLSL if (ClientSize.Height == 0) ClientSize = new System.Drawing.Size(ClientSize.Width, 1); - - if (context == null) - return; GL.Viewport(0, 0, ClientSize.Width, ClientSize.Height); double ratio = 0.0; - if (ClientSize.Width > ClientSize.Height) - ratio = ClientSize.Width / (double)ClientSize.Height; + ratio = ClientSize.Width / (double)ClientSize.Height; + //if (ClientSize.Width > ClientSize.Height) + // ratio = ClientSize.Width / (double)ClientSize.Height; //else // ratio = ClientSize.Height / (double)ClientSize.Width; @@ -127,10 +121,17 @@ namespace OpenTK.Examples.OpenGL.GLSL DrawCube(); - context.SwapBuffers(); + Context.SwapBuffers(); + } + #endregion - //Thread.Sleep(1); - //this.Invalidate(); + #region KeyDown event handler + protected override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + + if (e.KeyData == Keys.Escape) + Application.Exit(); } #endregion @@ -179,6 +180,7 @@ namespace OpenTK.Examples.OpenGL.GLSL } #endregion + #region Entry point /// /// The main entry point for the application. /// @@ -189,5 +191,6 @@ namespace OpenTK.Examples.OpenGL.GLSL Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Cube()); } + #endregion } } \ No newline at end of file diff --git a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.resx b/Source/Examples/OpenGL/GLSL/Lesson01/Cube.resx deleted file mode 100644 index ff31a6db..00000000 --- a/Source/Examples/OpenGL/GLSL/Lesson01/Cube.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/Examples/OpenGL/GLSL/Lesson01/GLSL.Lesson01.csproj b/Source/Examples/OpenGL/GLSL/Lesson01/GLSL.Lesson01.csproj index 7c7237cd..40f3478c 100644 --- a/Source/Examples/OpenGL/GLSL/Lesson01/GLSL.Lesson01.csproj +++ b/Source/Examples/OpenGL/GLSL/Lesson01/GLSL.Lesson01.csproj @@ -39,14 +39,7 @@ Form - - Cube.cs - - - Designer - Cube.cs - ResXFileCodeGenerator Resources.Designer.cs diff --git a/Source/Examples/OpenGL/GLSL/Lesson01/Properties/AssemblyInfo.cs b/Source/Examples/OpenGL/GLSL/Lesson01/Properties/AssemblyInfo.cs index f19eea84..131fc5c6 100644 --- a/Source/Examples/OpenGL/GLSL/Lesson01/Properties/AssemblyInfo.cs +++ b/Source/Examples/OpenGL/GLSL/Lesson01/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ 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("Lesson01")] +[assembly: AssemblyTitle("GLSL.Lesson01")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Lesson01")] -[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyProduct("GLSL.Lesson01")] +[assembly: AssemblyCopyright("Copyright © 2006 Stephen Apostolopoulos")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Source/OpenGL/OpenGL/Contexts/WindowsContext.cs b/Source/OpenGL/OpenGL/Contexts/WindowsContext.cs index d536fd63..d2532fe1 100644 --- a/Source/OpenGL/OpenGL/Contexts/WindowsContext.cs +++ b/Source/OpenGL/OpenGL/Contexts/WindowsContext.cs @@ -1,6 +1,8 @@ +#region License /* Copyright (c) 2006 Stephen Apostolopoulos * See license.txt for license info */ +#endregion using System; using System.Collections.Generic; @@ -19,7 +21,7 @@ namespace OpenTK.OpenGL.Platform int _render_context; IntPtr _window_handle; - public WindowsContext(Control c, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen) + public WindowsContext(Control c, int red, int green, int blue, int alpha, int depth, int stencil) { bool load_extensions = false; int error_code = 0; diff --git a/Source/OpenGL/OpenGL/Contexts/WindowsVistaContext.cs b/Source/OpenGL/OpenGL/Contexts/WindowsVistaContext.cs index 55118912..b070d449 100644 --- a/Source/OpenGL/OpenGL/Contexts/WindowsVistaContext.cs +++ b/Source/OpenGL/OpenGL/Contexts/WindowsVistaContext.cs @@ -19,7 +19,7 @@ namespace OpenTK.OpenGL.Platform int _render_context; IntPtr _window_handle; - public WindowsVistaContext(Control c, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen) + public WindowsVistaContext(Control c, int red, int green, int blue, int alpha, int depth, int stencil) { bool load_extensions = false; int error_code = 0; diff --git a/Source/OpenGL/OpenGL/Contexts/X11Context.cs b/Source/OpenGL/OpenGL/Contexts/X11Context.cs index dfddb665..ea932d82 100644 --- a/Source/OpenGL/OpenGL/Contexts/X11Context.cs +++ b/Source/OpenGL/OpenGL/Contexts/X11Context.cs @@ -11,7 +11,7 @@ namespace OpenTK.OpenGL.Platform { public partial class X11Context : OpenTK.OpenGL.GLContext { - public X11Context(Control c, int red, int green, int blue, int alpha, int depth, int stencil, bool fullscreen) + public X11Context(Control c, int red, int green, int blue, int alpha, int depth, int stencil) { throw new Exception("The method or operation is not implemented."); } diff --git a/Source/OpenGL/OpenGL/Properties/AssemblyInfo.cs b/Source/OpenGL/OpenGL/Properties/AssemblyInfo.cs index 8bb62ddb..2eee53f1 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.2.0")] -[assembly: AssemblyFileVersion("0.3.2.0")] +[assembly: AssemblyVersion("0.3.3.0")] +[assembly: AssemblyFileVersion("0.3.3.0")] diff --git a/Source/Platform/Windows/WinAPI.cs b/Source/Platform/Windows/WinAPI.cs index 4b3c5a12..a4f8287d 100644 --- a/Source/Platform/Windows/WinAPI.cs +++ b/Source/Platform/Windows/WinAPI.cs @@ -18,7 +18,6 @@ namespace OpenTK.Platform.Windows public static class Api { #region Constants - public struct Constants { // Keyboard events (found in WinUSER.h) @@ -37,12 +36,30 @@ namespace OpenTK.Platform.Windows public const sbyte PFD_MAIN_PLANE = 0; public const sbyte PFD_OVERLAY_PLANE = 1; public const sbyte PFD_UNDERLAY_PLANE = -1; - } + // Device mode types (found in WinGDI.h) + public const int DM_BITSPERPEL = 0x00040000; + public const int DM_PELSWIDTH = 0x00080000; + public const int DM_PELSHEIGHT = 0x00100000; + public const int DM_DISPLAYFLAGS = 0x00200000; + public const int DM_DISPLAYFREQUENCY = 0x00400000; + + // ChangeDisplaySettings types (found in WinUSER.h) + public const int CDS_UPDATEREGISTRY = 0x00000001; + public const int CDS_TEST = 0x00000002; + public const int CDS_FULLSCREEN = 0x00000004; + + // ChangeDisplaySettings results (found in WinUSER.h) + public const int DISP_CHANGE_SUCCESSFUL = 0; + public const int DISP_CHANGE_RESTART = 1; + public const int DISP_CHANGE_FAILED = -1; + + // (found in WinUSER.h) + public const int ENUM_CURRENT_SETTINGS = -1; + } #endregion #region WINAPI methods - #region PeekMessage /// @@ -362,6 +379,17 @@ namespace OpenTK.Platform.Windows #endregion + #region int ChangeDisplaySettings(ref Gdi.DEVMODE devMode, int flags) + /// + /// + /// + /// + /// + /// + [DllImport("user32.dll", SetLastError = true)] + public static extern int ChangeDisplaySettings(ref DeviceMode device_mode, int flags); + #endregion int ChangeDisplaySettings(ref Gdi.DEVMODE devMode, int flags) + // *********** Never use GetLastError! ************ @@ -384,13 +412,11 @@ namespace OpenTK.Platform.Windows //#endregion // ************************************************ - #endregion #region WINAPI structs - #region PixelFormatDescriptor - + #region PixelFormatDescriptor struct /// /// Describes a pixel format. It is used when interfacing with the WINAPI to create a new Context. /// Found in WinGDI.h @@ -428,7 +454,9 @@ namespace OpenTK.Platform.Windows public uint VisibleMask = 0; public uint DamageMask = 0; } + #endregion + #region PixelFormatDescriptorFlags enum [Flags] public enum PixelFormatDescriptorFlags : uint { @@ -453,11 +481,9 @@ namespace OpenTK.Platform.Windows DOUBLEBUFFER_DONTCARE = 0x40000000, STEREO_DONTCARE = 0x80000000 } - #endregion - #region SetWindowPosFlags - + #region SetWindowPosFlags enum [Flags] public enum SetWindowPosFlags { @@ -482,10 +508,9 @@ namespace OpenTK.Platform.Windows //public const int SWP_ASYNCWINDOWPOS = 0x4000; //#endif } - #endregion - #region WindowPlacementOptions + #region WindowPlacementOptions enum public enum WindowPlacementOptions { @@ -498,7 +523,6 @@ namespace OpenTK.Platform.Windows #endregion #region WindowClass - [StructLayout(LayoutKind.Sequential)] public class WindowClass { @@ -517,11 +541,9 @@ namespace OpenTK.Platform.Windows //[MarshalAs(UnmanagedType.LPStr)] public IntPtr ClassName; } - #endregion - #region Class styles - + #region WindowClassStyle enum public enum WindowClassStyle { VRedraw = 0x0001, @@ -542,7 +564,49 @@ namespace OpenTK.Platform.Windows DropShadow = 0x00020000 // #endif /* _WIN32_WINNT >= 0x0501 */ } + #endregion + #region DeviceMode struct + [StructLayout(LayoutKind.Sequential)] + public struct DeviceMode + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] + public string DeviceName; + public short SpecVersion; + public short DriverVersion; + public short Size; + public short DriverExtra; + public int Fields; + public short Orientation; + public short PaperSize; + public short PaperLength; + public short PaperWidth; + public short Scale; + public short Copies; + public short DefaultSource; + public short PrintQuality; + public short Color; + public short Duplex; + public short YResolution; + public short TTOption; + public short Collate; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] + public string FormName; + public short LogPixels; + public int BitsPerPel; + public int PelsWidth; + public int PelsHeight; + public int DisplayFlags; + public int DisplayFrequency; + public int ICMMethod; + public int ICMIntent; + public int MediaType; + public int DitherType; + public int Reserved1; + public int Reserved2; + public int PanningWidth; + public int PanningHeight; + } #endregion #endregion diff --git a/changelog.txt b/changelog.txt index 23b6c161..1892d7d2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,8 @@ OpenTK 0.3.2 -> 0.3.3 + OpenTK.OpenGL.Bind 0.7.5 -> 0.7.5.1 (see Bind changelog for more information) -+ Added the GLForm class. -+ Added the GLForm.Lesson01 example. ++ Added the GLForm class which sets the base for cross-platform screen, context and keyboard handling. ++ Can now change between fullscreen and windowed modes. ++ Temporarily removed all examples except for GLSL.Lesson01, which has been updated to use the new GLForm class. OpenTK 0.3.1 -> 0.3.2 + OpenTK.OpenGL.Glu: Eliminated the temporary IntPtr variable in the GetString and ErrorString functions. diff --git a/todo.txt b/todo.txt index 9a153787..4502f210 100644 --- a/todo.txt +++ b/todo.txt @@ -1,9 +1,11 @@ Todo: -+ Find out why many examples crash when compiled in release mode, but only when run outside the editor. -+ Add more examples (e.g. the GLSL example I wrote, some of kanato's examples etc). ++ + + Find out why many examples crash when compiled in release mode, but only when run outside the editor. ++ + Add cross-platform way for overriding the Application.Idle handler. ++ Add more examples. + + Change the hierarchy of the WindowsContext and WindowsVistaContext classes. The should have a common ancestor who manages the windows creation (it should be the same for both). + + Add more constructors to the WindowsContext classes. This probably needs updating of the WinAPI assembly. + + Add X11Context constructors. ++ + Add more GLForm constructors. + Find out what is needed for the MacOS platform (how to do function loading and window management without X11). + Add full bindings to Glu, Wgl, Glx and Agl. + Add the Math module. @@ -14,6 +16,5 @@ Todo: + See if using Nant for building is a good idea. + + Clean up the code. + + Add comments and documentation (faqs, pitfalls, best practices). -+ + + Add the CLS compliant attribute to the Gl class. -+ Add more platform bindings. -+ Add cross-platform way of overriding the Application.Idle handler. \ No newline at end of file ++ + + Add the CLS compliant attribute to the GL class. ++ Add more platform bindings. \ No newline at end of file