Added GLForm.cs (base class for cross-platform windowing control)

Temporarily removed all examples apart from GLSL.Lesson01 which has been updated to use the GLForm class.
Minor updates to OpenTK.OpenGL.Bind
This commit is contained in:
the_fiddler 2006-10-08 21:22:50 +00:00
parent fdb625da0f
commit d9b0ac6e5c
13 changed files with 115 additions and 221 deletions

View file

@ -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}

View file

@ -1,47 +0,0 @@
namespace OpenTK.Examples.OpenGL.GLSL
{
partial class Cube
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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
}
}

View file

@ -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
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -189,5 +191,6 @@ namespace OpenTK.Examples.OpenGL.GLSL
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Cube());
}
#endregion
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -39,14 +39,7 @@
<Compile Include="Cube.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Cube.Designer.cs">
<DependentUpon>Cube.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Cube.resx">
<SubType>Designer</SubType>
<DependentUpon>Cube.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

View file

@ -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("")]

View file

@ -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;

View file

@ -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;

View file

@ -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.");
}

View file

@ -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")]

View file

@ -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
/// <summary>
@ -362,6 +379,17 @@ namespace OpenTK.Platform.Windows
#endregion
#region int ChangeDisplaySettings(ref Gdi.DEVMODE devMode, int flags)
/// <summary>
///
/// </summary>
/// <param name="device_mode"></param>
/// <param name="flags"></param>
/// <returns></returns>
[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
/// <summary>
/// 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

View file

@ -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.

View file

@ -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.
+ + + Add the CLS compliant attribute to the GL class.
+ Add more platform bindings.