'Merged' windowing branch. Ugly, but it seems to have worked.

This commit is contained in:
the_fiddler 2007-07-23 00:15:18 +00:00
parent 8cecdb3fa8
commit 3d23105b0d
91 changed files with 108772 additions and 0 deletions

BIN
Build/Build.exe Normal file

Binary file not shown.

22
Build/Instructions.txt Normal file
View file

@ -0,0 +1,22 @@
How to build OpenTK:
1) Install nant from (http://nant.sourceforge.net/)
2) Navigate to the Build folder and execute Build.exe:
2a) Under Linux/Mac OS X, type 'mono Build.exe mono' or 'mono Build.exe mono debug' for the release/debug versions of the library.
2b) Under Windows type 'build net' (or 'build net debug').
3) The binaries (library, examples) are placed in the Binaries/Release folder.
There are other parameters you can pass to Build.exe. A brief list:
net - build using the .Net framework.
mono - build using Mono.
debug - build the debug version (e.g. 'build net debug').
clean - delete intermediate object files and projects (reclaim some space, the binaries are not touched).
distclean - delete intermediate and final object files (reclaim all space used during compilation).
svnclean - delete '.svn' folders. Useful if you checked out from svn, useless if you downloaded a file release.
vs2005 - create project files for Visual Studio 2005.
monodev - create project files for MonoDevelop.
sharpdev - as above, for SharpDevelop.

BIN
Build/Prebuild.exe Normal file

Binary file not shown.

133
Build/Prebuild.xml Normal file
View file

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8" ?>
<Prebuild xmlns="http://dnpb.sourceforge.net/schemas/prebuild-1.7.xsd">
<Solution name="OpenTK">
<Configuration name="Debug">
<Options>
<CompilerDefines>DEBUG;TRACE;</CompilerDefines>
<OptimizeCode>false</OptimizeCode>
<!--<OutputPath>../../Binaries/Debug/Libraries</OutputPath>-->
<DebugInformation>true</DebugInformation>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<CompilerDefines>TRACE;</CompilerDefines>
<OptimizeCode>true</OptimizeCode>
<!--<OutputPath>../../Binaries/Release/Libraries</OutputPath>-->
<DebugInformation>false</DebugInformation>
</Options>
</Configuration>
<Files>
<File>../Documentation/Todo.txt</File>
<File>../Documentation/Release.txt</File>
<File>../Documentation/Changelog.txt</File>
<File>../Documentation/License.txt</File>
<File>./Instructions.txt</File>
<File>Prebuild.xml</File>
</Files>
<Project name="Build" path="../Source/Build" language="C#" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../Binaries/Debug/Exe</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../Binaries/Release/Exe</OutputPath>
</Options>
</Configuration>
<Reference name="System"/>
<Files>
<Match path="." pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project name="Bind" path="../Source/Bind" language="C#" type="Exe">
<Configuration name="Debug">
<Options>
<OutputPath>../../Binaries/Debug/Exe</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../Binaries/Release/Exe</OutputPath>
</Options>
</Configuration>
<Reference name="System"/>
<Files>
<Match path="." pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project name="OpenTK" path="../Source/OpenTK" language="C#" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../Binaries/Debug/Libraries</OutputPath>
<!--<AllowUnsafe>true</AllowUnsafe>-->
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../Binaries/Release/Libraries</OutputPath>
<!--<AllowUnsafe>true</AllowUnsafe>-->
</Options>
</Configuration>
<Reference name="System"/>
<Reference name="System.Drawing"/>
<Reference name="System.Windows.Forms"/>
<Reference name="System.Data"/>
<Files>
<Match path="." pattern="*.cs" recurse="true"/>
<!--<Match path="." pattern="*.dll.config" recurse="true"/>-->
</Files>
</Project>
<Project name="Examples" path="../Source/Examples" language="C#" type="WinExe">
<Configuration name="Debug">
<Options>
<OutputPath>../../Binaries/Debug/Examples</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../Binaries/Release/Examples</OutputPath>
</Options>
</Configuration>
<Reference name="OpenTK"/>
<Reference name="System"/>
<Reference name="System.Drawing"/>
<Reference name="System.Windows.Forms"/>
<Reference name="System.Data"/>
<Files>
<Match path="." pattern="*.cs" recurse="true"/>
</Files>
</Project>
</Solution>
</Prebuild>

125
Documentation/Changelog.txt Normal file
View file

@ -0,0 +1,125 @@
OpenTK 0.3.7 -> 0.3.8
+ OpenTK.Build
+ Improved console output.
+ Added support for debug target.
+ Better handling of wrong targets.
- Removed OpenTK.Framework
+ OpenTK.GameWindow (new)
+ Creates render window through system calls.
+ Interface suited for games.
+ Resize event support.
+ Error handling.
- No keyboard input yet.
+ OpenTK.Platform
+ Numerous additions, bugfixes in OpenTK.Platform.Windows, OpenTK.Platform.X11.
+ Changed the class and namespace names.
+ Added IGLContext, IGLControl, IGameWindow, INativeWindow, IResizable interfaces.
+ Added class GLContext : IGLContext. Platform specific implementations in WinGLContext and X11GLContext.
+ Added class GLControl : IGLControl. Platform specific implementations in WinGLControl and X11GLControl.
+ Added classes WinGLNative, X11GLNative : INativeWindow.
+ Added visual studio design support for GLControl.
OpenTK 0.3.6 -> 0.3.7
+ OpenTK.Build
+ Added new, (more) cross-platform build system, written on C#. This takes the place of the scripts and batch files used to compile OpenTK up till now.
+ Removed all build scripts.
+ OpenTK.Framework
+ Now builds under Linux.
+ OpenTK.OpenGL.Bind
+ Synced with Tao.GlBindGen beta 2.1.3.6
+ Enabled ref/out overloads.
+ Added GLenum, which contains all opengl enumerants (useful for 'polymorphic' opengl functions).
+ OpenTK.OpenGL
+ ref/out overloads and GLenum (see above).
+ Fixed extension loading under Mac OS X.
+ Improved compatibility with 64bit platforms.
OpenTK 0.3.5 -> 0.3.6
+ OpenTK.OpenGL.Bind
+ Synced with Tao.GlBindGen codebase.
+ Uses CodeDOM internally for code generation.
+ Updated to latest specs (which include shader model 4).
+ OpenTK.OpenGL (Low level)
+ All OpenGL extensions are now generated (up to shader model 4).
+ Decorated imports and delegates with the SuppressUnmanagedCodeSecurity attribute. Major speed improvements in CPU-bound applications.
+ More robust and faster static initialisation for the GL class.
+ Updated GLHelper.cs, with methods to obtain or reload OpenGL entry points, as well as query for supported extensions.
+ Got rid of "object" overloads for typed arrays.
+ All known bugs are now fixed.
+ 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.
+ The Framework class structure has been updated. Less code is duplicated between GLContext and Framework now.
+ Three new examples have been added: OpenGL.Basic.Lesson01 (equivalent to OpenGL.GLSL.Lesson01 without the shaders), OpenGL.Basic.QueryDisplayModes which shows a list of all available display modes, and OpenGL.Basic.NoFramework which shows how to use OpenGL Contexts directly (without relying on the framework).
+ New bindings for X and the XF86 extension.
+ New build system based on Prebuild and NAnt (similar to the one used in Tao or Mono.XNA).
+ Updates to the OpenTK.OpenGL.DisplayMode and ColorDepth classes.
+ More XML documentation blocks added to functions and classes.
+ Major update to OpenTK.OpenGL.Bind (see that changelog for more info).
+ Revamped GL class (it is self contained now).
+ Revamped GLContext class (it is no longer bound to the GL class initialisation).
+ Cleaner code, new functions, comments and many new wrappers.
+ Updated the spec files for opengl 2.1.
+ Added the new 64 bit types to the typemaps (gl.tm and csharp.tm)
+ The bugs in the specs are still there:
+ SGIX_icc_texture is still commented out, while enums use it.
+ LightProperty is still used by constants (the correct enum is LightParameter).
+ I think I should contact someone at the Khronos group about these. For the time being I worked around them, by adding a special case for LightProperty in the translator, and adding the SGIX enum to the missing parameters.
+ See also: http://www.haskell.org/HOpenGL/spec_bugs.html (lots of useful information on that site).
+ Directory structure updates.
+ Now every project has its own documentation.
+ The spec files for OpenGL now reside in the Source/OpenTK/OpenGL directory.
+ Minor updates to the wgl bindings (int -> IntPtr).
+ Tested the binding generator with the glx specs (the reader and the enum writer work ok, the trnaslator and the other writers will need updating).
+ Renamed the GLForm to Framework.
+ The Framework now resides in its own project directory.
OpenTK 0.3.3 -> 0.3.4
+ Corrected the crash error in Release mode (it was caused by trying to Marshal the System.Windows.Forms.Message struct to PeekMessage - adding my own Message struct corrected the issue).
+ Corrected the call to glShaderSource GLSL.Lesson01. Now the correct number is passed to the count parameter, while the null parameter was changed to IntPtr.Zero (Mono now no longers fails in this call).
+ Updated the GLSL.Lesson01 example to use GetShaderInfoLog on compilation failure.
+ OpenTK.OpenGL.Bind 0.7.5.1 -> 0.7.5.2 (see Bind changelog for more information)
+ Full Mono support under windows.
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 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.
+ Specifications.cs_types.txt: Changed types in order to be CLS compliant.
+ OpenTK.OpenGL.Bind 0.7.4 -> 0.7.5
+ Added the GLSL.Lesson01 example.
OpenTK 0.3.0 -> 0.3.1
+ Updated the binding generator to version 0.7.4, based on the work done for Tao.
+ Updated the Context load functions. Now Context loads all functions are extensions, and the derived classes override this behavior as needed.
+ Changed the uint array used in the DisplayLists example to an int array.
+ Added the changelog! :)

View file

@ -0,0 +1,9 @@
The MIT License
Copyright (c) 2006, 2007 Stefanos Apostolopoulos
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.

24
Documentation/Release.txt Normal file
View file

@ -0,0 +1,24 @@
================================================================================
OpenTK 0.3.8 WIP alpha Release notes
IMPORTANT: This release is intended for testing and experimentation only. Use at your own risk!
--------------------------------------------------------------------------------
Highlights:
* Improved interface for GLContext, GLControl. Unfortunately, projects using 0.3.7 (or previous version of OpenTK) will not compile without changes.
* GLControls can be added in the VS designer.
* GameWindow class, a simple, no-nonsense windowing toolkit for games (incomplete).
* Numerous bugfixes and additions in OpenTK.Platform.Windows and OpenTK.Platform.X11
--------------------------------------------------------------------------------
For support, bug reports, feature requests and flames, visit the OpenTK site: http://opentk.sourceforge.net/
The latest version is always available at http://sourceforge.net/projects/opentk
Living on the edge? 'svn co https://opentk.svn.sourceforge.net/svnroot/opentk/trunk opentk'
================================================================================

46
Documentation/Todo.txt Normal file
View file

@ -0,0 +1,46 @@
Generic Todos:
+ Correctly implement disposable pattern in all relevant classes (WIP as of 0.3.8).
+ Investigate startup lag.
OpenTK.OpenGL todos:
* Change the GCHandle method of pinning to 'fixed'. The behaviour is different: fixed guarantees pinning of the whole object.
* Different classes for each extension category (ARB.Foo, instead of FooARB).
+ Inline XML documentation.
+ Add complete Wgl, Glx, Agl and Glu bindings.
+ Get rid of the "object" overloads in favour of generics.
OpenTK.Platform:
* GLContext class:
+ Add more constructors.
+ Add native support for the MacOS X platform (now goes through X).
* GLControl class:
+ Improve the interface. Add more constructors.
* GameWindow class:
+ Add input support.
OpenTK.Input todos:
* Make Key class non-static. Static means all GameWindows share the same input!
* Complete the Key class.
* Implement mouse input.
+ Implement other input devices.
OpenTK.Timing todos:
+ Start implementing the Timer module.
Examples:
+ Add comments were needed.
+ Add more Tutorials and WinForms examples.
OpenTK.Math todos:
+ Start implementing the Math module.
OpenTK.OpenAL todos:
+ Start researching the OpenAL module.
+ Take a look at the OpenALDotNet wrapper.

View file

@ -0,0 +1,53 @@
OpenTK.OpenGL.Bind 0.9.3
0.7.7 -> 0.9.3
+ Synced code with Tao.GlBindGen
+ Re-enabled extensions
+ Updated specs
+ Now uses CodeDOM for code generation
+ Imports and delegates are decorated with the SupressUnmanagedCodeSecurity attribute for call overhead reduction
+ Several bugs have been fixed
0.7.6 -> 0.7.7
+ Several bugfixes regarding bugs from the latest (0.7.6) code synchronisation between Tao.GlBindGen and OpenTK.OpenGL.Bind
+ Split the Enums, Core OpenGL and Extension OpenGL functions into different files. This speeds up the Visual Studio IDE a lot.
+ The Extension functions have been removed from the OpenTK.OpenGL.GL class. They will be added back on a later version, probably as OpenTK.OpenGL.GL.Extensions. No need to clatter up the code API with thousands of mostly useless extensions.
+ Applications load much faster now.
+ Killed the Context class generation. It added a lot of complexity for little gain (what, cleaner OOP internal structure? Oh, please!) This move frees up the Context classes which can now be updated without dragging around several thousand function initialisations.
+ OpenTK.OpenGL.GL is self-contained now. Delegates are initialised statically, calling the platform specific *GetAddress functions where needed (they are contained in the GL class, too - but not auto-generated).
+ Revamped the WriteSpecs class. Its methods are now completely modular (enum, core and extension writers have been split).
+ This still needs some refactoring to reduce code copy-paste and allow for future wgl / glx binding generation.
0.7.5.2 -> 0.7.6
+ Added NeedWrapper and WrapperType properties to each parameter (needed for more fine grained control on wrapper generation).
+ Added Function, Parameter, ParameterCollection (deep) copy constructors. This allows simpler code in many places (since we can now create new Functions without fear of affecting the old ones, for example).
+ Merged the ParameterCollection.cs with Parameter.cs
+ Added the FunctionBody class which contains the contents of a function as a list of strings. It is mainly intended for wrappers (allows cleaner code, too).
+ The wrapper generation now happens in TranlateSpecs.cs instead of WriteSpecs.cs. (Translations and generations should only happen during the translation phase, not while reading or writing. Allow for cleaner code).
+ Revamped the wrapper generator code. Now it handles correctly the cases where a function has more than one parameter that needs wrapping (i.e. it generates all permutations correctly). This is handled by recursively generating the needed permutations (it was a hell to implement).
+ Added some comments (many more to follow).
+ Removed some commented-out regions and some obsolete functions.
0.7.5.1 -> 0.7.5.2
+ Added translation for out char[] parameters (they are treated as StringBuilders, as specified in MSDN).
+ Added System.Text using directive.
0.7.5 -> 0.7.5.1
+ Added license information to the generated bindings.
+ Changed the name of the main Context class to GLContext (Context is used in the BCL).
0.7.4 -> 0.7.5
+ Added wrappers for all functions that accept arrays. Permitted parameters for these are: an array of the original type (e.g. float[]), an IntPtr (if you manage memory yourself), or any blittable type (e.g. float[,,]). No type checking is done in the last case, so be careful!
+ Updated the wrappers for all functions that accept or return void pointers. Permitted parameters for these are: an IntPtr or any blittable type (type checking is turned off, so be extra careful!)
+ Aliased the GLbool type to int. It is hacky, but the examples bundled with Tao rely on this...
+ Added a wrapper for glLineStipple. Now you can pass an int to it, but only the last 16 bits will be used for the stipple (as per the function specification). This was the only way to avoid aliasing the parameter to ushort (non-CLS compatible) or having the user write unchecked((short)0x....) every time he used the function.
+ Added the WrapperType enum. Every function has a Property that indicates the wrapper it will need. This cleans up the WriteWrappers function somewhat.
+ Added the PreviousType property to the Function class. This is used when generating wrappers for functions with type-checked arrays (e.g. float[] arrays etc).
+ Corrected some type aliases in cs_types.txt
+ Added the missing wrappers for glReadPixels! (this falls in the out void array).
+ A missing enum now defaults to Enum.[Function category] (a new property was added to the Function class and the SpecReader.ReadFunctions function was modified). I should test this to see if it works ok.

View file

@ -0,0 +1,11 @@
OpenTK.OpenGL.Bind 0.9.4 todos:
Major:
+ Change the output of extensions from GL.BlahARB to GL.ARB.Blah
+ Use generics instead of object overloads.
+ Add ref overloads for arrays
Minor:
+ Clean up the reader.
+ Add more settings to Settings.cs (the name of the files to read).
+ Comment the code.

128
Source/Bind/Main.cs Normal file
View file

@ -0,0 +1,128 @@
#region License
/*
MIT License
Copyright ©2003-2006 Tao Framework Team
http://www.taoframework.com
All rights reserved.
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 License
using System;
using System.Text;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Collections.Generic;
using System.CodeDom;
namespace OpenTK.OpenGL.Bind
{
static class MainClass
{
static void Main(string[] arguments)
{
Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
//Console.WriteLine(" - the OpenTK team ;-)");
Console.WriteLine();
#region Handle Arguments
try
{
foreach (string a in arguments)
{
if (a.StartsWith("--") || a.StartsWith("-") || a.StartsWith("/"))
{
string[] b = a.Split(new char[] { '-', '/', ':', '=' }, StringSplitOptions.RemoveEmptyEntries);
switch (b[0])
{
case "?":
case "help":
Console.WriteLine("Help not implemented yet.");
return;
case "in":
case "input":
Settings.InputPath = b[1];
break;
case "out":
case "Properties.Bind.Default.OutputPath":
Settings.OutputPath = b[1];
break;
case "class":
Settings.GLClass = b[1];
break;
default:
throw new ArgumentException("Argument " + a + " not recognized. Use the '/?' switch for help.");
}
}
}
}
catch (NullReferenceException e)
{
Console.WriteLine("Argument error ({0}). Please use the '/?' switch for help.", e.ToString());
return;
}
catch (ArgumentException e)
{
Console.WriteLine("Argument error ({0}). Please use the '/?' switch for help.", e.ToString());
return;
}
#endregion
try
{
long ticks = System.DateTime.Now.Ticks;
List<CodeMemberMethod> functions;
List<CodeTypeDelegate> delegates;
CodeTypeDeclarationCollection enums;
CodeTypeDeclarationCollection enums2;
delegates = SpecReader.ReadFunctionSpecs("gl.spec");
SpecReader.ReadEnumSpecs("enum.spec", out enums);
SpecReader.ReadEnumSpecs("enumext.spec", out enums2);
enums = SpecTranslator.Merge(enums, enums2);
enums = SpecTranslator.TranslateEnums(enums);
functions = SpecTranslator.TranslateDelegates(delegates, enums);
// Generate the code
SpecWriter.Generate(delegates, functions, enums);
ticks = System.DateTime.Now.Ticks - ticks;
Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
Console.WriteLine();
Console.WriteLine("Press enter to continue...");
Console.ReadLine();
}
catch (SecurityException e)
{
Console.WriteLine("Security violation \"{0}\" in method \"{1}\".", e.Message, e.Method);
Console.WriteLine("This application does not have permission to take the requested actions.");
}
}
}
}

View file

@ -0,0 +1,33 @@
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("OpenGL binding generator")]
[assembly: AssemblyDescription("Generates OpenGL bindings for C# from the C OpenGL headers")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenTK.OpenGL.Bind")]
[assembly: AssemblyCopyright("Copyright © 2006-2007 Stefanos Apostolopoulos")]
[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("0d681958-ca78-4a67-b71c-ff8755488e23")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.9.1.0")]
[assembly: AssemblyFileVersion("0.9.1.0")]

View file

@ -0,0 +1,30 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="OpenTK.OpenGL.Bind.Properties" GeneratedClassName="Bind">
<Profiles />
<Settings>
<Setting Name="OutputGLClass" Type="System.String" Scope="User">
<Value Profile="(Default)">GL</Value>
</Setting>
<Setting Name="OutputNamespace" Type="System.String" Scope="User">
<Value Profile="(Default)">OpenTK.OpenGL</Value>
</Setting>
<Setting Name="OutputPath" Type="System.String" Scope="User">
<Value Profile="(Default)">..\..\Source\OpenGL\OpenGL\Bindings</Value>
</Setting>
<Setting Name="InputPath" Type="System.String" Scope="User">
<Value Profile="(Default)">..\..\Specifications</Value>
</Setting>
<Setting Name="OutputPlatformNamespace" Type="System.String" Scope="User">
<Value Profile="(Default)">Platform</Value>
</Setting>
<Setting Name="WriteInternalImportsClass" Type="System.String" Scope="User">
<Value Profile="(Default)">Imports</Value>
</Setting>
<Setting Name="OutputEnumsClass" Type="System.String" Scope="User">
<Value Profile="(Default)">Enums</Value>
</Setting>
<Setting Name="OutputContextClass" Type="System.String" Scope="User">
<Value Profile="(Default)">Context</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="OpenTK.OpenGL.Bind.Properties.Bind" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Bind.Properties.Bind" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="OpenTK.Bind.Properties.Bind" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<OpenTK.OpenGL.Bind.Properties.Bind>
<setting name="OutputGLClass" serializeAs="String">
<value>GL</value>
</setting>
<setting name="OutputNamespace" serializeAs="String">
<value>OpenTK.OpenGL</value>
</setting>
<setting name="OutputPath" serializeAs="String">
<value>..\..\Source\OpenGL\OpenGL\Bindings</value>
</setting>
<setting name="InputPath" serializeAs="String">
<value>..\..\Specifications</value>
</setting>
<setting name="OutputPlatformNamespace" serializeAs="String">
<value>Platform</value>
</setting>
<setting name="WriteInternalImportsClass" serializeAs="String">
<value>Imports</value>
</setting>
<setting name="OutputEnumsClass" serializeAs="String">
<value>Enums</value>
</setting>
<setting name="OutputContextClass" serializeAs="String">
<value>Context</value>
</setting>
</OpenTK.OpenGL.Bind.Properties.Bind>
<Bind.Properties.Bind>
<setting name="OutputGLClass" serializeAs="String">
<value>GL</value>
</setting>
<setting name="OutputNamespace" serializeAs="String">
<value>OpenTK.OpenGL</value>
</setting>
<setting name="OutputPath" serializeAs="String">
<value>..\..\Source\OpenTK\OpenGL\Bindings</value>
</setting>
<setting name="InputPath" serializeAs="String">
<value>..\..\..\Input</value>
</setting>
<setting name="OutputPlatformNamespace" serializeAs="String">
<value>Platform</value>
</setting>
<setting name="WriteInternalImportsClass" serializeAs="String">
<value>Imports</value>
</setting>
<setting name="InputSpecFilesPath" serializeAs="String">
<value>..\..\Specifications</value>
</setting>
<setting name="OutputEnumsClass" serializeAs="String">
<value>Enums</value>
</setting>
<setting name="OutputContextClass" serializeAs="String">
<value>Context</value>
</setting>
</Bind.Properties.Bind>
<OpenTK.Bind.Properties.Bind>
<setting name="OutputGLClass" serializeAs="String">
<value>GL</value>
</setting>
<setting name="OutputNamespace" serializeAs="String">
<value>OpenTK.OpenGL</value>
</setting>
<setting name="OutputPath" serializeAs="String">
<value>..\..\Source\OpenTK\OpenGL\Bindings</value>
</setting>
<setting name="InputPath" serializeAs="String">
<value>..\..\..\Input</value>
</setting>
<setting name="OutputPlatformNamespace" serializeAs="String">
<value>Platform</value>
</setting>
<setting name="WriteInternalImportsClass" serializeAs="String">
<value>Imports</value>
</setting>
<setting name="InputSpecFilesPath" serializeAs="String">
<value>..\..\Specifications</value>
</setting>
<setting name="OutputEnumsClass" serializeAs="String">
<value>Enums</value>
</setting>
<setting name="OutputContextClass" serializeAs="String">
<value>Context</value>
</setting>
</OpenTK.Bind.Properties.Bind>
</userSettings>
</configuration>

24
Source/Bind/Settings.cs Normal file
View file

@ -0,0 +1,24 @@
#region License
//Copyright (c) 2006 Stefanos Apostolopoulos
//See license.txt for license info
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.OpenGL.Bind
{
static class Settings
{
public static string InputPath = "..\\..\\..\\Source\\OpenGL\\Specifications";
public static string OutputPath = "..\\..\\..\\Source\\OpenGL\\OpenGL\\Bindings";
public static string OutputNamespace = "OpenTK.OpenGL";
public static string GLClass = "GL";
public static string WglClass = "Wgl";
public static string GlxClass = "Glx";
public static string GluClass = "Glu";
public static string GLFunctionPrepend = String.Empty;
}
}

433
Source/Bind/SpecReader.cs Normal file
View file

@ -0,0 +1,433 @@
#region --- License ---
/*
MIT License
Copyright ©2006-2007 Tao Framework Team
http://www.taoframework.com
Copyright ©2005-2007 OpenTK
http://sourceforge.net/projects/opentk
All rights reserved.
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 License
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.CodeDom;
#endregion
namespace OpenTK.OpenGL.Bind
{
static class SpecReader
{
#region internal static string FilePath
internal static string FilePath
{
get
{
string filePath = Path.Combine("..", "..");
string fileDirectory = Settings.InputPath;
string fileName = "gl.spec";
if (File.Exists(fileName))
{
filePath = "";
fileDirectory = "";
}
else if (File.Exists(Path.Combine(fileDirectory, fileName)))
{
filePath = "";
}
return Path.Combine(filePath, fileDirectory);
}
}
#endregion
#region private static StreamReader OpenSpecFile(string file)
private static StreamReader OpenSpecFile(string file)
{
string path = Path.Combine(FilePath, file);
StreamReader sr;
try
{
sr = new StreamReader(path);
}
catch (Exception e)
{
Console.WriteLine("Error opening spec file: {0}", path);
Console.WriteLine("Error: {0}", e.Message);
throw e;
}
return sr;
}
#endregion
#region private static bool IsExtension(string function_name)
private static bool IsExtension(string function_name)
{
return (function_name.EndsWith("ARB") ||
function_name.EndsWith("EXT") ||
function_name.EndsWith("ATI") ||
function_name.EndsWith("NV") ||
function_name.EndsWith("SUN") ||
function_name.EndsWith("SUNX") ||
function_name.EndsWith("SGI") ||
function_name.EndsWith("SGIS") ||
function_name.EndsWith("SGIX") ||
function_name.EndsWith("MESA") ||
function_name.EndsWith("3DFX") ||
function_name.EndsWith("IBM") ||
function_name.EndsWith("GREMEDY") ||
function_name.EndsWith("HP") ||
function_name.EndsWith("INTEL") ||
function_name.EndsWith("PGI") ||
function_name.EndsWith("INGR") ||
function_name.EndsWith("APPLE") ||
function_name.EndsWith("OML") ||
function_name.EndsWith("I3D"));
}
#endregion
#region private static string NextValidLine(StreamReader sr)
private static string NextValidLine(StreamReader sr)
{
string line;
do
{
if (sr.EndOfStream)
return null;
line = sr.ReadLine().Trim();
if (String.IsNullOrEmpty(line) ||
line.StartsWith("#") || // Disregard comments.
line.StartsWith("passthru") || // Disregard passthru statements.
line.StartsWith("required-props:") ||
line.StartsWith("param:") ||
line.StartsWith("dlflags:") ||
line.StartsWith("glxflags:") ||
line.StartsWith("vectorequiv:") ||
//line.StartsWith("category:") ||
line.StartsWith("version:") ||
line.StartsWith("glxsingle:") ||
line.StartsWith("glxropcode:") ||
line.StartsWith("glxvendorpriv:") ||
line.StartsWith("glsflags:") ||
line.StartsWith("glsopcode:") ||
line.StartsWith("glsalias:") ||
line.StartsWith("wglflags:") ||
line.StartsWith("extension:") ||
line.StartsWith("alias:") ||
line.StartsWith("offset:"))
continue;
return line;
}
while (true);
}
#endregion
#region public static void ReadFunctionSpecs(string file, out List<CodeTypeDelegate> delegates, out List<CodeMemberMethod> functions)
public static List<CodeTypeDelegate> ReadFunctionSpecs(string file)
{
StreamReader sr = OpenSpecFile(file);
Console.WriteLine("Reading function specs from file: {0}", file);
List<CodeTypeDelegate> delegates = new List<CodeTypeDelegate>();
do
{
string line = NextValidLine(sr);
if (String.IsNullOrEmpty(line))
break;
// Get next OpenGL function
while (line.Contains("(") && !sr.EndOfStream)
{
CodeTypeDelegate d = new CodeTypeDelegate();
d.Attributes = MemberAttributes.Static;
d.CustomAttributes.Add(new CodeAttributeDeclaration("System.Security.SuppressUnmanagedCodeSecurity"));
// Get function name:
d.Name = line.Split(SpecTranslator.Separators, StringSplitOptions.RemoveEmptyEntries)[0];
if (IsExtension(d.Name))
{
d.UserData.Add("Extension", true);
}
else
{
d.UserData.Add("Extension", false);
}
//d.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, d.Name));
//d.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, d.Name));
// Get function parameters and return value:
do
{
line = sr.ReadLine();
List<string> words = new List<string>(
line.Replace('\t', ' ').Split(SpecTranslator.Separators, StringSplitOptions.RemoveEmptyEntries));
if (words.Count == 0)
break;
// Identify line:
switch (words[0])
{
case "return": // Line denotes return value
CodeTypeReference tr = new CodeTypeReference(
words[1]
);
//if (tr.BaseType == "GLvoid")
// tr.BaseType = "System.Void";
d.ReturnType = tr;
break;
case "param": // Line denotes parameter
CodeParameterDeclarationExpression p =
new CodeParameterDeclarationExpression();
p.Name = words[1];
p.Type = new CodeTypeReference(words[2]);
p.Direction = words[3] == "in" ? FieldDirection.In : FieldDirection.Out;
if (words[3] != "in")
p.CustomAttributes.Add(new CodeAttributeDeclaration("In, Out"));
p.Type.ArrayRank = words[4] == "array" ? 1 : 0;
d.Parameters.Add(p);
break;
/* version directive is not used. GetTexParameterIivEXT and GetTexParameterIuivEXT define two(!) versions (why?)
case "version": // Line denotes function version (i.e. 1.0, 1.2, 1.5)
d.UserData.Add("version", words[1]);
break;
*/
case "category":
d.UserData.Add("Category", words[1]);
break;
}
}
while (!sr.EndOfStream);
delegates.Add(d);
}
}
while (!sr.EndOfStream);
return delegates;
}
#endregion
#region public static void ReadEnumSpecs(string file, out List<CodeMemberField> enums)
public static void ReadEnumSpecs(string file, out CodeTypeDeclarationCollection enums)
{
enums = new CodeTypeDeclarationCollection();
// comple_enum contains all opengl enumerants.
CodeTypeDeclaration complete_enum = new CodeTypeDeclaration();
complete_enum.IsEnum = true;
complete_enum.Name = "GLenum";
StreamReader sr = OpenSpecFile(file);
Console.WriteLine("Reading constant specs from file: {0}", file);
do
{
string line = NextValidLine(sr);
if (String.IsNullOrEmpty(line))
break;
line = line.Replace('\t', ' ');
// We just encountered the start of a new enumerant:
while (!String.IsNullOrEmpty(line) && line.Contains("enum"))
{
string[] words = line.Split(SpecTranslator.Separators, StringSplitOptions.RemoveEmptyEntries);
if (words.Length == 0)
continue;
// Declare a new enumerant
CodeTypeDeclaration e = new CodeTypeDeclaration();
e.IsEnum = true;
e.Name = SpecTranslator.GetTranslatedEnum(words[0]);
//d.Attributes = MemberAttributes.Const | MemberAttributes.Public;
// And fill in the values for this enumerant
do
{
line = NextValidLine(sr);
if (String.IsNullOrEmpty(line) || line.StartsWith("#"))
continue;
if (line.Contains("enum:") || sr.EndOfStream)
break;
line = line.Replace('\t', ' ');
words = line.Split(SpecTranslator.Separators, StringSplitOptions.RemoveEmptyEntries);
if (words.Length == 0)
continue;
// If we reach this point, we have found a new value for the current enumerant
CodeMemberField c = new CodeMemberField();
if (line.Contains("="))
{
c.Name = SpecTranslator.GetTranslatedEnum(words[0]);
uint number;
if (UInt32.TryParse(words[2].Replace("0x", String.Empty), System.Globalization.NumberStyles.AllowHexSpecifier, null, out number))
{
if (number > 0x7FFFFFFF)
{
words[2] = "unchecked((Int32)" + words[2] + ")";
}
}
else if (words[2].StartsWith("GL_"))
{
words[2] = words[2].Substring(3);
}
//c.InitExpression = new CodeFieldReferenceExpression(null, words[2]);
//c.UserData.Add("InitExpression", " = " + words[2]);
c.UserData.Add("ObjectReference", null);
c.UserData.Add("FieldReference", words[2]);
}
else if (words[0] == "use")
{
c.Name = SpecTranslator.GetTranslatedEnum(words[2]);
//c.InitExpression = new CodeFieldReferenceExpression(new CodeSnippetExpression(words[1]), SpecTranslator.GetTranslatedEnum(words[2]));
//c.UserData.Add("InitExpression", " = " + words[1] + "." + SpecTranslator.GetTranslatedEnum(words[2]));
c.UserData.Add("ObjectReference", words[1]);
c.UserData.Add("FieldReference", words[2]);
}
//if (!String.IsNullOrEmpty(c.Name) && !e.Members.Contains.Contains(c))
SpecTranslator.Merge(e.Members, c);
// Insert the current constant in the list of all constants.
SpecTranslator.Merge(complete_enum.Members, c);
}
while (!sr.EndOfStream);
// At this point, the complete value list for the current enumerant has been read, so add this
// enumerant to the list.
e.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "public enum " + e.Name));
e.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "public enum " + e.Name));
// (disabled) Hack - discard Boolean enum, it fsucks up the fragile translation code ahead.
//if (!e.Name.Contains("Bool"))
SpecTranslator.Merge(enums, e);
}
SpecTranslator.Merge(enums, complete_enum);
}
while (!sr.EndOfStream);
}
#endregion
#region public static bool ListContainsConstant(List<CodeMemberField> enums, CodeMemberField c)
public static bool ListContainsConstant(List<CodeMemberField> constants, CodeMemberField c)
{
foreach (CodeMemberField d in constants)
if (d.Name == c.Name)
return true;
return false;
}
#endregion
#region public static Dictionary<string, CodeTypeReference> ReadTypeMap(string file)
public static Dictionary<string, CodeTypeReference> ReadTypeMap(string file)
{
Dictionary<string, CodeTypeReference> map =
new Dictionary<string, CodeTypeReference>();
string path = Path.Combine(FilePath, file);
StreamReader sr;
try
{
sr = new StreamReader(path);
}
catch (Exception)
{
Console.WriteLine("Error opening typemap file: {0}", path);
return null;
}
Console.WriteLine("Reading typemaps from file: {0}", file);
do
{
string line = sr.ReadLine();
if (String.IsNullOrEmpty(line) || line.StartsWith("#"))
continue;
string[] words = line.Split(new char[] { ' ', ',', '*', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (words[0] == "void")
{
// Special case for "void" -> ""
map.Add(words[0], new CodeTypeReference(String.Empty));
}
else if (words[0] == "VoidPointer")
{ // Special case for "VoidPointer" -> "GLvoid*"
map.Add(words[0], new CodeTypeReference("System.Object"));
}
else if (words[0] == "CharPointer" || words[0] == "charPointerARB")
{
map.Add(words[0], new CodeTypeReference("System.String"));
}
else if (words[0].Contains("Pointer"))
{
map.Add(words[0], new CodeTypeReference(words[1], 1));
}
//else if (words[1].Contains("Boolean"))
//{
// // Do not add this to the typemap!
//}
/*else if (words[1] == "GLenum")
{
// Do not throw away the type to generic GLenum. We want type checking!
}*/
else
{
map.Add(words[0], new CodeTypeReference(words[1]));
}
}
while (!sr.EndOfStream);
return map;
}
#endregion
}
}

View file

@ -0,0 +1,937 @@
#region --- License ---
/*
MIT License
Copyright ©2006-2007 Tao Framework Team
http://www.taoframework.com
Copyright ©2005-2007 OpenTK
http://sourceforge.net/projects/opentk
All rights reserved.
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 License
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.CodeDom;
#endregion
namespace OpenTK.OpenGL.Bind
{
#region WrapperTypes enum
public enum WrapperTypes
{
/// <summary>
/// No wrapper needed.
/// </summary>
None,
/// <summary>
/// Function takes bool parameter - C uses Int for bools, so we have to marshal.
/// </summary>
BoolParameter,
/// <summary>
/// Function takes generic parameters - add ref/out generic and generic overloads.
/// </summary>
GenericParameter,
/// <summary>
/// Function takes arrays as parameters - add ref/out and ([Out]) array overloads.
/// </summary>
ArrayParameter,
/// <summary>
/// Function with bitmask parameters. Bitmask parameters map to UInt, but since we can only use signed
/// types (for CLS compliance), we must add the unchecked keyword.
/// Usually found in bitmasks
/// </summary>
UncheckedParameter,
/// <summary>
/// Function that takes (in/ref/out) a naked pointer as a parameter - we pass an IntPtr.
/// </summary>
PointerParameter,
/// <summary>
/// Function returns string - needs manual marshalling through IntPtr to prevent the managed GC
/// from freeing memory allocated on the unmanaged side (e.g. glGetString).
/// </summary>
StringReturnValue,
/// <summary>
/// Function returns a void pointer - maps to IntPtr, and the user has to manually marshal the type.
/// </summary>
GenericReturnValue,
/// <summary>
/// Function returns a typed pointer - we have to copy the data to an array to protect it from the GC.
/// </summary>
ArrayReturnValue
}
#endregion
static class SpecTranslator
{
#region static SpecTranslator()
// Do not remove! - forces BeforeFieldInit to false.
static SpecTranslator()
{
}
#endregion
#region Fields and Properties
public static char[] Separators = { ' ', '\n', ',', '(', ')', ';', '#' };
#region GL types dictionary
private static Dictionary<string, CodeTypeReference> _gl_types = SpecReader.ReadTypeMap("gl.tm");
public static Dictionary<string, CodeTypeReference> GLTypes
{
get { return SpecTranslator._gl_types; }
set { SpecTranslator._gl_types = value; }
}
#endregion
#region CS types dictionary
private static Dictionary<string, CodeTypeReference> _cs_types = SpecReader.ReadTypeMap("csharp.tm");
public static Dictionary<string, CodeTypeReference> CSTypes
{
get { return SpecTranslator._cs_types; }
set { SpecTranslator._cs_types = value; }
}
#endregion
#region GLX types dictionary
private static Dictionary<string, string> _glx_types;
public static Dictionary<string, string> GLXTypes
{
get { return _glx_types; }
set { _glx_types = value; }
}
#endregion
#region WGL types dictionary
private static Dictionary<string, string> _wgl_types;
public static Dictionary<string, string> WGLTypes
{
get { return _wgl_types; }
set { _wgl_types = value; }
}
#endregion
#endregion
#region public static List<CodeMemberMethod> TranslateDelegates(List<CodeTypeDelegate> delegates, CodeTypeDeclarationCollection enums)
public static List<CodeMemberMethod> TranslateDelegates(List<CodeTypeDelegate> delegates, CodeTypeDeclarationCollection enums)
{
List<CodeMemberMethod> functions = new List<CodeMemberMethod>();
foreach (CodeTypeDelegate d in delegates)
{
TranslateReturnValue(d);
TranslateParameters(d, enums);
functions.AddRange(CreateWrappers(d));
}
return functions;
}
#endregion
#region private static void TranslateReturnValue(CodeTypeDelegate d)
private static void TranslateReturnValue(CodeTypeDelegate d)
{
CodeTypeReference s;
if (d.ReturnType.BaseType == "void")
d.ReturnType.BaseType = "System.Void";
if (GLTypes.TryGetValue(d.ReturnType.BaseType, out s))
d.ReturnType = s;
if (d.ReturnType.BaseType == "GLstring")
{
d.ReturnType = new CodeTypeReference("IntPtr");
d.ReturnType.UserData.Add("Wrapper", WrapperTypes.StringReturnValue);
}
if (d.ReturnType.BaseType.ToLower().Contains("object"))
{
d.ReturnType.BaseType = "IntPtr";
d.ReturnType.UserData.Add("Wrapper", WrapperTypes.GenericReturnValue);
d.ReturnType.ArrayRank = 0;
}
if (d.ReturnType.BaseType == "GLenum")
{
d.ReturnType.BaseType = "Enums.GLenum";
}
if (d.ReturnType.UserData.Contains("Wrapper"))
{
d.UserData.Add("Wrapper", null);
}
}
#endregion
#region private static void TranslateParameters(CodeTypeDelegate d)
private static void TranslateParameters(CodeTypeDelegate d, CodeTypeDeclarationCollection enums)
{
CodeTypeReference s;
if (d.Name == "CreateShader")
{
}
// Translate each parameter of the function while checking for needed wrappers:
foreach (CodeParameterDeclarationExpression p in d.Parameters)
{
if (Search(enums, p.Type.BaseType) && p.Type.BaseType != "GLenum")
{
// If there is a specific enumerant entry for this parameter, then take this.
p.Type.BaseType = "Enums." + p.Type.BaseType;
}
else if (GLTypes.TryGetValue(p.Type.BaseType, out s))
{
if (s.BaseType == "GLenum" && d.UserData.Contains("Category"))
{
// If there isn't, try to see if any of the generic enumerants
// (category: VERSION_1_1 etc) match the needed name.
bool found = false;
foreach (CodeTypeDeclaration enumerant in enums)
{
if (enumerant.Name == (string)d.UserData["Category"])
{
p.Type.BaseType = "Enums." + (string)d.UserData["Category"];
found = true;
break;
}
}
// If none match, then fall back to the global enum list.
if (!found)
{
p.Type.BaseType = "Enums.GLenum";
}
}
else
{
p.Type.BaseType = s.BaseType;
}
}
if (p.Type.ArrayRank == 0 && p.Type.BaseType.ToLower().Contains("enums."))
{
// Do nothing
}
else if (p.Type.ArrayRank > 0 && p.Type.BaseType.Contains("char") ||
p.Type.ArrayRank == 0 && p.Type.BaseType.ToLower().Contains("string"))
{
// GLchar[] parameters should become (in) string or (out) StringBuilder
if (p.Direction == FieldDirection.Out || p.Direction == FieldDirection.Ref)
p.Type = new CodeTypeReference("System.Text.StringBuilder");
else
p.Type = new CodeTypeReference("System.String");
}
else if (p.Type.ArrayRank > 0 && p.Type.BaseType.ToLower().Contains("string"))
{
// string parameters do not need special wrappers. We add this here
// to simplify the next if-statements.
// p.Type.ArrayRank = 0;
}
else if (p.Type.ArrayRank > 0)
{
// All other array parameters need wrappers (around IntPtr).
if (p.Type.BaseType.Contains("void") || p.Type.BaseType.Contains("Void"))
{
p.UserData.Add("Wrapper", WrapperTypes.GenericParameter);
}
else if (p.Type.BaseType.Contains("IntPtr"))
{
//p.UserData.Add("Wrapper", WrapperTypes.PointerParameter);
}
else
{
p.UserData.Add("Wrapper", WrapperTypes.ArrayParameter);
p.UserData.Add("OriginalType", new string(p.Type.BaseType.ToCharArray()));
}
// We do not want an array of IntPtrs (IntPtr[]) - it is the IntPtr that points to the array.
p.Type = new CodeTypeReference();
p.Type.BaseType = "System.IntPtr";
p.Type.ArrayRank = 0;
p.UserData.Add("Flow", p.Direction);
// The same wrapper works for either in or out parameters.
//p.CustomAttributes.Add(new CodeAttributeDeclaration("In, Out"));
}
else if (p.Type.BaseType.Contains("ushort") && d.Name.Contains("LineStipple"))
{
// glLineStipple needs wrapper to allow large unsigned mask values.
p.UserData.Add("Wrapper", WrapperTypes.UncheckedParameter);
}
if (p.Type.BaseType.ToLower().Contains("boolean"))
{
p.Type.BaseType = "System.Boolean";
//p.UserData.Add("Wrapper", WrapperTypes.BoolParameter);
p.CustomAttributes.Add(
new CodeAttributeDeclaration(
"MarshalAs",
new CodeAttributeArgument(new CodeSnippetExpression("UnmanagedType.Bool"))
)
);
}
if (p.UserData.Contains("Wrapper") && !d.UserData.Contains("Wrapper"))
{
// If there is at least 1 parameter that needs wrappers, mark the funcction for wrapping.
d.UserData.Add("Wrapper", null);
}
//p.Direction = FieldDirection.In;
}
}
#endregion
#region private static bool Search(CodeTypeDeclarationCollection enums, string name)
private static bool Search(CodeTypeDeclarationCollection enums, string name)
{
foreach (CodeTypeDeclaration enumerant in enums)
{
if (enumerant.Name == name)
{
return true;
}
}
return false;
}
#endregion
#region private static List<CodeMemberMethod> CreateWrappers(CodeTypeDelegate d)
private static List<CodeMemberMethod> CreateWrappers(CodeTypeDelegate d)
{
List<CodeMemberMethod> wrappers = new List<CodeMemberMethod>();
CodeMemberMethod f = new CodeMemberMethod();
// Check if a wrapper is needed:
if (!d.UserData.Contains("Wrapper"))
{
// If not, add just add a function that calls the delegate.
f = CreatePrototype(d);
if (!f.ReturnType.BaseType.Contains("Void"))
f.Statements.Add(new CodeMethodReturnStatement(GenerateInvokeExpression(f)));
else
f.Statements.Add(GenerateInvokeExpression(f));
wrappers.Add(f);
}
else
{
// We have to add wrappers for all possible WrapperTypes.
// First, check if the return type needs wrapping:
if (d.ReturnType.UserData.Contains("Wrapper"))
{
switch ((WrapperTypes)d.ReturnType.UserData["Wrapper"])
{
// If the function returns a string (glGetString) we must manually marshal it
// using Marshal.PtrToStringXXX. Otherwise, the GC will try to free the memory
// used by the string, resulting in corruption (the memory belongs to the
// unmanaged boundary).
case WrapperTypes.StringReturnValue:
f = CreatePrototype(d);
f.ReturnType = new CodeTypeReference("System.String");
f.Statements.Add(
new CodeMethodReturnStatement(
new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression("Marshal"),
"PtrToStringAnsi",
new CodeExpression[] { GenerateInvokeExpression(f) }
)
)
);
wrappers.Add(f);
break;
// If the function returns a void* (GenericReturnValue), we'll have to return an IntPtr.
// The user will unfortunately need to marshal this IntPtr to a data type manually.
case WrapperTypes.GenericReturnValue:
f = CreatePrototype(d);
if (!f.ReturnType.BaseType.Contains("Void"))
f.Statements.Add(new CodeMethodReturnStatement(GenerateInvokeExpression(f)));
else
f.Statements.Add(GenerateInvokeExpression(f));
wrappers.Add(f);
break;
}
}
if (d.Name.Contains("LineStipple"))
{
// glLineStipple accepts a GLushort bitfield. Since GLushort is mapped to Int16, not UInt16
// (for CLS compliance), we'll have to add the unchecked keyword.
f = CreatePrototype(d);
CodeSnippetExpression e =
new CodeSnippetExpression("Delegates.glLineStipple(factor, unchecked((GLushort)pattern))");
f.Statements.Add(e);
wrappers.Add(f);
}
WrapPointersMonsterFunctionMK2(String.IsNullOrEmpty(f.Name) ? CreatePrototype(d) : f, wrappers);
}
return wrappers;
}
#endregion
#region private static void WrapPointersMonsterFunctionMK2(CodeTypeDelegate d, List<CodeMemberMethod> wrappers)
// This function needs some heavy refactoring. I'm ashamed I ever wrote it, but it works...
// What it does is this: it adds to the wrapper list all possible wrapper permutations
// for functions that have more than one IntPtr parameter. Example:
// "void Delegates.f(IntPtr p, IntPtr q)" where p and q are pointers to void arrays needs the following wrappers:
// "void f(IntPtr p, IntPtr q)"
// "void f(IntPtr p, object q)"
// "void f(object p, IntPtr q)"
// "void f(object p, object q)"
private static int count = 0;
private static void WrapPointersMonsterFunctionMK2(CodeMemberMethod f, List<CodeMemberMethod> wrappers)
{
if (count == 0)
{
bool functionContainsIntPtrParameters = false;
// Check if there are any IntPtr parameters (we may have come here from a ReturnType wrapper
// such as glGetString, which contains no IntPtr parameters)
foreach (CodeParameterDeclarationExpression p in f.Parameters)
{
if (p.Type.BaseType.Contains("IntPtr"))
{
functionContainsIntPtrParameters = true;
break;
}
}
if (functionContainsIntPtrParameters)
{
wrappers.Add(IntPtrToIntPtr(f));
}
else
{
return;
}
}
if (count >= 0 && count < f.Parameters.Count)
{
if (f.Parameters[count].UserData.Contains("Wrapper"))
{
//++count;
//WrapPointersMonsterFunctionMK2(d, wrappers);
//--count;
if ((WrapperTypes)f.Parameters[count].UserData["Wrapper"] == WrapperTypes.ArrayParameter)
{
++count;
WrapPointersMonsterFunctionMK2(f, wrappers);
--count;
CodeMemberMethod w = IntPtrToArray(f, count);
wrappers.Add(w);
++count;
WrapPointersMonsterFunctionMK2(w, wrappers);
--count;
w = IntPtrToReference(f, count);
wrappers.Add(w);
++count;
WrapPointersMonsterFunctionMK2(w, wrappers);
--count;
}
else if ((WrapperTypes)f.Parameters[count].UserData["Wrapper"] == WrapperTypes.GenericParameter)
{
++count;
WrapPointersMonsterFunctionMK2(f, wrappers);
--count;
CodeMemberMethod w = IntPtrToObject(f, count);
wrappers.Add(w);
++count;
WrapPointersMonsterFunctionMK2(w, wrappers);
--count;
}
}
else
{
++count;
WrapPointersMonsterFunctionMK2(f, wrappers);
--count;
}
}
}
#endregion
#region private static CodeMemberMethod IntPtrToIntPtr(CodeMemberMethod f)
private static CodeMemberMethod IntPtrToIntPtr(CodeMemberMethod f)
{
CodeMemberMethod w = CreatePrototype(f);
if (!w.ReturnType.BaseType.Contains("Void"))
{
w.Statements.Add(new CodeMethodReturnStatement(GenerateInvokeExpression(w)));
}
else
{
w.Statements.Add(GenerateInvokeExpression(w));
}
return w;
}
#endregion
#region private static CodeMemberMethod IntPtrToObject(CodeMemberMethod f, int index)
private static CodeMemberMethod IntPtrToObject(CodeMemberMethod f, int index)
{
CodeMemberMethod w = CreatePrototype(f);
CodeParameterDeclarationExpression newp = new CodeParameterDeclarationExpression();
newp.Name = f.Parameters[index].Name;
newp.Type = new CodeTypeReference("System.Object");
//if (newp.Flow == Parameter.FlowDirection.Out)
// newp.Flow = Parameter.FlowDirection.Undefined;
w.Parameters[index] = newp;
// In the function body we should pin all objects in memory before calling the
// low-level function.
w.Statements.AddRange(GenerateInvokeExpressionWithPins(w));
return w;
}
#endregion
#region private static CodeMemberMethod IntPtrToArray(CodeMemberMethod f, int index)
// IntPtr -> GL[...] wrapper.
private static CodeMemberMethod IntPtrToArray(CodeMemberMethod f, int index)
{
CodeMemberMethod w = CreatePrototype(f);
// Search and replace IntPtr parameters with the known parameter types:
CodeParameterDeclarationExpression newp = new CodeParameterDeclarationExpression();
newp.Name = f.Parameters[index].Name;
newp.Type.BaseType = (string)f.Parameters[index].UserData["OriginalType"];
newp.Type.ArrayRank = 1;
w.Parameters[index] = newp;
// In the function body we should pin all objects in memory before calling the
// low-level function.
w.Statements.AddRange(GenerateInvokeExpressionWithPins(w));
return w;
}
#endregion
#region private static CodeMemberMethod IntPtrToReference(CodeMemberMethod f, int index)
/// <summary>
/// Obtain an IntPtr to the reference passed by the user.
/// </summary>
/// <param name="f"></param>
/// <param name="index"></param>
/// <returns></returns>
private static CodeMemberMethod IntPtrToReference(CodeMemberMethod f, int index)
{
CodeMemberMethod w = CreatePrototype(f);
// Search and replace IntPtr parameters with the known parameter types:
CodeParameterDeclarationExpression newp = new CodeParameterDeclarationExpression();
newp.Name = f.Parameters[index].Name;
newp.Type.BaseType = (string)f.Parameters[index].UserData["OriginalType"];
if (f.Parameters[index].UserData.Contains("Flow") &&
(FieldDirection)f.Parameters[index].UserData["Flow"] == FieldDirection.Out)
newp.Direction = FieldDirection.Out;
else
newp.Direction = FieldDirection.Ref;
w.Parameters[index] = newp;
// In the function body we should pin all objects in memory before calling the
// low-level function.
w.Statements.AddRange(GenerateInvokeExpressionWithPins(w));
return w;
}
#endregion
#region private static CodeMemberMethod CreatePrototype(CodeTypeDelegate d)
private static CodeMemberMethod CreatePrototype(CodeTypeDelegate d)
{
CodeMemberMethod f = new CodeMemberMethod();
f.Name = Settings.GLFunctionPrepend + d.Name;
f.Parameters.AddRange(d.Parameters);
f.ReturnType = d.ReturnType;
f.Attributes = MemberAttributes.Static | MemberAttributes.Public;
//f.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, f.Name));
//f.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, f.Name));
/*f.Comments.Add(new CodeCommentStatement("<summary>", true));
f.Comments.Add(new CodeCommentStatement(" ", true));
f.Comments.Add(new CodeCommentStatement("</summary>", true));*/
return f;
}
#endregion
#region private static CodeMemberMethod CreatePrototype(CodeMemberMethod d)
private static CodeMemberMethod CreatePrototype(CodeMemberMethod d)
{
CodeMemberMethod f = new CodeMemberMethod();
f.Name = d.Name;
f.Parameters.AddRange(d.Parameters);
f.ReturnType = d.ReturnType;
f.Attributes = MemberAttributes.Static | MemberAttributes.Public;
//f.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, f.Name));
//f.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, f.Name));
foreach (object key in d.UserData.Keys)
{
f.UserData.Add(key, d.UserData[key]);
}
/*f.Comments.Add(new CodeCommentStatement("<summary>", true));
f.Comments.Add(new CodeCommentStatement(" ", true));
f.Comments.Add(new CodeCommentStatement("</summary>", true));*/
return f;
}
#endregion
#region private static CodeExpression GenerateInvokeExpression(CodeMemberMethod f)
private static CodeExpression GenerateInvokeExpression(CodeMemberMethod f)
{
CodeVariableReferenceExpression[] parameters = new CodeVariableReferenceExpression[f.Parameters.Count];
int i = 0;
foreach (CodeParameterDeclarationExpression p in f.Parameters)
{
parameters[i++] = new CodeVariableReferenceExpression(p.Name);
}
return new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression("Delegates"),
"gl" + f.Name,
parameters
);
}
#endregion
#region private static CodeStatementCollection GenerateInvokeExpressionWithPins(CodeMemberMethod f)
private static CodeStatementCollection GenerateInvokeExpressionWithPins(CodeMemberMethod f)
{
CodeVariableReferenceExpression[] parameters = new CodeVariableReferenceExpression[f.Parameters.Count];
CodeTryCatchFinallyStatement m = new CodeTryCatchFinallyStatement();
CodeStatementCollection statements = new CodeStatementCollection();
int h = 0;
int i = 0;
foreach (CodeParameterDeclarationExpression p in f.Parameters)
{
// Do manual marshalling for objects and arrays, but not strings.
if (p.Type.BaseType == "object" || p.Type.BaseType == "System.Object" ||
(p.Type.ArrayRank > 0 && !p.Type.BaseType.ToLower().Contains("string")) ||
((p.Direction == FieldDirection.Ref || p.Direction == FieldDirection.Out) &&
!p.Type.BaseType.ToLower().Contains("string")))
{
if (p.Direction == FieldDirection.Out)
{
statements.Add(
new CodeAssignStatement(
new CodeVariableReferenceExpression(p.Name),
new CodeSnippetExpression("default(" + p.Type.BaseType + ")")
)
);
}
// Pin the object and store the resulting GCHandle to h0, h1, ...
CodeVariableDeclarationStatement s = new CodeVariableDeclarationStatement();
s.Type = new CodeTypeReference("GCHandle");
s.Name = "h" + h;
s.InitExpression =
new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression("GCHandle"),
"Alloc",
new CodeTypeReferenceExpression[] {
new CodeTypeReferenceExpression(p.Name),
new CodeTypeReferenceExpression("GCHandleType.Pinned")
}
);
statements.Add(s);
// Free the object using the h0, h1, ... variables
m.FinallyStatements.Add(
new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression("h" + h),
"Free"
)
);
// Add the h(n) variable to the list of parameters
parameters[i] = new CodeVariableReferenceExpression("h" + h + ".AddrOfPinnedObject()");
// Add an assignment statement: "variable_name = (variable_type)h(n).Target" for out parameters.
if (p.Direction == FieldDirection.Out)
{
m.TryStatements.Add(
new CodeAssignStatement(
new CodeVariableReferenceExpression(p.Name),
new CodeSnippetExpression("(" + p.Type.BaseType + ")h" + h + ".Target")
)
);
}
h++;
}
else
{
// Add the normal paramater to the parameter list
parameters[i] = new CodeVariableReferenceExpression(p.Name);
}
i++;
}
if (f.ReturnType.BaseType.Contains("Void"))
{
m.TryStatements.Insert(0,
new CodeExpressionStatement(
new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression("Delegates"),
"gl" + f.Name,
parameters
)
)
);
}
else
{
m.TryStatements.Insert(0, new CodeVariableDeclarationStatement(f.ReturnType, "retval"));
m.TryStatements.Insert(1,
new CodeAssignStatement(
new CodeVariableReferenceExpression("retval"),
new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression("Delegates"),
"gl" + f.Name,
parameters
)
)
);
m.TryStatements.Add(
new CodeMethodReturnStatement(new CodeVariableReferenceExpression("retval"))
);
}
statements.Add(m);
return statements;
}
#endregion
#region public static CodeTypeDeclarationCollection Merge(CodeTypeDeclarationCollection list1, CodeTypeDeclarationCollection list2)
public static CodeTypeDeclarationCollection Merge(CodeTypeDeclarationCollection list1, CodeTypeDeclarationCollection list2)
{
foreach (CodeTypeDeclaration d in list2)
{
Merge(list1, d);
}
return list1;
}
#endregion
#region public static CodeTypeDeclarationCollection Merge(CodeTypeDeclarationCollection list, CodeTypeDeclaration item)
public static CodeTypeDeclarationCollection Merge(CodeTypeDeclarationCollection list, CodeTypeDeclaration item)
{
bool t_exists = false;
foreach (CodeTypeDeclaration d in list)
{
if (d.Name == item.Name)
{
t_exists = true;
foreach (CodeTypeMember m in item.Members)
{
Merge(d.Members, m);
}
}
}
if (!t_exists)
{
list.Add(item);
}
return list;
}
#endregion
#region public static CodeTypeMemberCollection Merge(CodeTypeMemberCollection list, CodeTypeMember item)
public static CodeTypeMemberCollection Merge(CodeTypeMemberCollection list, CodeTypeMember item)
{
bool t_exists = false;
foreach (CodeTypeMember d in list)
{
if (d.Name == item.Name)
{
t_exists = true;
}
}
if (!t_exists)
{
list.Add(item);
}
return list;
}
#endregion
#region public static CodeTypeDeclarationCollection TranslateEnums(CodeTypeDeclarationCollection enums)
public static CodeTypeDeclarationCollection TranslateEnums(CodeTypeDeclarationCollection enums)
{
// Add missing enums.
{
CodeTypeDeclaration e = new CodeTypeDeclaration("SGIX_icc_texture");
e.IsEnum = true;
CodeMemberField c;
c = new CodeMemberField(); c.Name = "RGB_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8460"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "RGBA_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8461"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "ALPHA_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8462"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "LUMINANCE_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8463"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "INTENSITY_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8464"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "LUMINANCE_ALPHA_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8465"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "R5_G6_B5_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8466"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "R5_G6_B5_A8_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8467"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "ALPHA16_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8468"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "LUMINANCE16_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x8469"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "INTENSITY16_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x846A"); e.Members.Add(c);
c = new CodeMemberField(); c.Name = "LUMINANCE16_ALPHA8_ICC_SGIX"; c.InitExpression = new CodeFieldReferenceExpression(null, "0x846B"); e.Members.Add(c);
enums.Add(e);
}
// Translate enums.
foreach (CodeTypeDeclaration e in enums)
{
if (Char.IsDigit(e.Name[0]))
e.Name = e.Name.Insert(0, "_");
if (e.Name == "Boolean")
continue;
foreach (CodeMemberField c in e.Members)
{
// Prepend an '_' if the first letter is a number (e.g. 4_BYTES -> _4_BYTES)
if (Char.IsDigit(c.Name[0]))
c.Name = c.Name.Insert(0, "_");
if (c.UserData["FieldReference"] == null)
continue;
c.UserData["ObjectReference"] = GetTranslatedEnum((string)c.UserData["ObjectReference"]);
c.UserData["FieldReference"] = GetTranslatedEnum((string)c.UserData["FieldReference"]);
// There are cases when a value is not a number but an aliased constant, with no enum specified.
// In this case try searching all enums for the correct constant to alias (stupid opengl specs).
if (c.UserData["ObjectReference"] == null &&
!((string)c.UserData["FieldReference"]).StartsWith("0x") &&
!Char.IsDigit(((string)c.UserData["FieldReference"])[0]))
{
if (((string)c.UserData["FieldReference"]).StartsWith("GL_"))
c.UserData["FieldReference"] = ((string)c.UserData["FieldReference"]).Substring(3);
foreach (CodeTypeDeclaration enumerant in enums)
{
foreach (CodeTypeMember member in enumerant.Members)
{
if (member.Name == (string)c.UserData["FieldReference"] ||
member.Name == ((string)c.UserData["FieldReference"]).TrimStart('_'))
{
c.UserData["ObjectReference"] = enumerant.Name;
}
}
}
}
c.InitExpression =
new CodeFieldReferenceExpression(
c.UserData["ObjectReference"] == null ? null : new CodeSnippetExpression((string)c.UserData["ObjectReference"]),
(string)c.UserData["FieldReference"]
);
}
}
return enums;
}
#endregion
#region public static string GetTranslatedEnum(string name)
public static string GetTranslatedEnum(string name)
{
int useless;
if (String.IsNullOrEmpty(name))
return null;
// Check if the name starts with a number, and prepend a "_" if yes.
if (!name.StartsWith("0x") &&
!Int32.TryParse(name, out useless) &&
Char.IsDigit(name[0]))
{
return name.Insert(0, "_");
}
if (name == "LightProperty")
{
return "LightParameter";
}
return name;
}
#endregion
}
}

350
Source/Bind/SpecWriter.cs Normal file
View file

@ -0,0 +1,350 @@
#region --- License ---
/*
MIT License
Copyright ©2006-2007 Tao Framework Team
http://www.taoframework.com
Copyright ©2005-2007 OpenTK
http://sourceforge.net/projects/opentk
All rights reserved.
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 License
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using System.CodeDom;
#endregion
namespace OpenTK.OpenGL.Bind
{
static class SpecWriter
{
#region internal class CodeTypeNameComparer<T> : Comparer<T> where T : CodeTypeMember
internal class CodeTypeNameComparer<T> : Comparer<T> where T : CodeTypeMember
{
public override int Compare(T x, T y)
{
return x.Name.CompareTo(y.Name);
}
}
#endregion
#region Generate
public static void Generate(
List<CodeTypeDelegate> delegates,
List<CodeMemberMethod> functions,
CodeTypeDeclarationCollection enums
)
{
if (!Directory.Exists(Settings.OutputPath))
Directory.CreateDirectory(Settings.OutputPath);
CodeNamespace ns = new CodeNamespace(Settings.OutputNamespace);
ns.Imports.Add(new CodeNamespaceImport("System"));
ns.Imports.Add(new CodeNamespaceImport("System.Runtime.InteropServices"));
ns.Imports.Add(new CodeNamespaceImport("System.Text"));
//ns.Imports.Add(new CodeNamespaceImport(Settings.OutputNamespace + ".Enums"));
foreach (string key in SpecTranslator.CSTypes.Keys)
{
ns.Imports.Add(new CodeNamespaceImport(key + " = System." + SpecTranslator.CSTypes[key].BaseType));
}
functions.Sort(new CodeTypeNameComparer<CodeMemberMethod>());
delegates.Sort(new CodeTypeNameComparer<CodeTypeDelegate>());
ns.Types.Add(GenerateGLClass(functions));
ns.Types.Add(GenerateDelegatesClass(delegates));
ns.Types.Add(GenerateImportsClass(delegates));
CodeCompileUnit cu = new CodeCompileUnit();
cu.StartDirectives.Add(new CodeDirective());
cu.Namespaces.Add(ns);
using (StreamWriter sw = new StreamWriter(Path.Combine(Settings.OutputPath, Settings.GLClass + ".cs"), false))
{
Console.WriteLine("Writing {0} class", Settings.OutputNamespace + "." + Settings.GLClass);
Microsoft.CSharp.CSharpCodeProvider cs = new Microsoft.CSharp.CSharpCodeProvider();
System.CodeDom.Compiler.CodeGeneratorOptions options = new System.CodeDom.Compiler.CodeGeneratorOptions();
options.BracingStyle = "C";
options.BlankLinesBetweenMembers = false;
options.VerbatimOrder = true;
cs.GenerateCodeFromCompileUnit(cu, sw, options);
sw.Flush();
}
ns.Name = Settings.OutputNamespace + ".Enums";
ns.Imports.Clear();
ns.Imports.Add(new CodeNamespaceImport("System"));
ns.Types.Clear();
//enums.Sort(new CodeTypeNameComparer<CodeTypeDeclaration>());
//CodeTypeDeclaration d = new CodeTypeDeclaration("Enums");
//d.IsStruct = true;
//d.Members.AddRange(enums);
//ns.Types.Add(d);
ns.Types.AddRange(enums);
using (StreamWriter sw = new StreamWriter(Path.Combine(Settings.OutputPath, Settings.GLClass + "enums.cs"), false))
{
Console.WriteLine("Writing {0} enums", Settings.OutputNamespace + "." + Settings.GLClass);
Microsoft.CSharp.CSharpCodeProvider cs = new Microsoft.CSharp.CSharpCodeProvider();
System.CodeDom.Compiler.CodeGeneratorOptions options = new System.CodeDom.Compiler.CodeGeneratorOptions();
options.BracingStyle = "C";
options.BlankLinesBetweenMembers = false;
options.VerbatimOrder = true;
cs.GenerateCodeFromCompileUnit(cu, sw, options);
sw.Flush();
}
}
#endregion
#region private static CodeTypeDeclaration GenerateGLClass(List<CodeMemberMethod> functions, List<CodeMemberField> enums)
private static CodeTypeDeclaration GenerateGLClass(List<CodeMemberMethod> functions)
{
CodeTypeDeclaration gl_class = new CodeTypeDeclaration(Settings.GLClass);
gl_class.IsClass = true;
gl_class.IsPartial = true;
gl_class.TypeAttributes = System.Reflection.TypeAttributes.Public;
gl_class.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "GL class"));
gl_class.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "GL class"));
gl_class.Members.Add(new CodeSnippetTypeMember(" #pragma warning disable 1591"));
gl_class.Members.Add(new CodeSnippetTypeMember(
@"
#region Private Constants
#region string GL_NATIVE_LIBRARY
/// <summary>
/// Specifies OpenGl's native library archive.
/// </summary>
/// <remarks>
/// Specifies opengl32.dll everywhere; will be mapped via .config for mono.
/// </remarks>
internal const string GL_NATIVE_LIBRARY = ""opengl32.dll"";
#endregion string GL_NATIVE_LIBRARY
#endregion Private Constants
"));
/*
if (constants.Count > 0)
{
constants[0].StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "OpenGL constants"));
constants[constants.Count - 1].EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "OpenGL constants"));
}
gl_class.Members.AddRange(constants.ToArray());
*/
if (functions.Count > 0)
{
functions[0].StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, "OpenGL functions"));
functions[functions.Count - 1].EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, "OpenGL functions"));
}
gl_class.Members.AddRange(functions.ToArray());
return gl_class;
}
#endregion
#region private static CodeTypeDeclaration GenerateDelegatesClass(List<CodeTypeDelegate> delegates)
private static CodeTypeDeclaration GenerateDelegatesClass(List<CodeTypeDelegate> delegates)
{
CodeTypeDeclaration delegate_class = new CodeTypeDeclaration("Delegates");
delegate_class.TypeAttributes = System.Reflection.TypeAttributes.NotPublic;
CodeStatementCollection statements = new CodeStatementCollection();
foreach (CodeTypeDelegate d in delegates)
{
// Hack - turn FieldDirection.Out parameters to FieldDirection.In. The parameter flow
// is handle by the [In, Out()] parameter attribute.
foreach (CodeParameterDeclarationExpression p in d.Parameters)
{
p.Direction = FieldDirection.In;
}
delegate_class.Members.Add(d);
CodeMemberField m = new CodeMemberField();
m.Name = "gl" + d.Name;
m.Type = new CodeTypeReference(d.Name);
m.Attributes = MemberAttributes.Public | MemberAttributes.Static;
//m.InitExpression =
//new CodeCastExpression(
// "Delegates." + d.Name,
// new CodeMethodInvokeExpression(
// new CodeMethodReferenceExpression(
// new CodeTypeReferenceExpression(Properties.Bind.Default.OutputClass),
// "GetDelegateForExtensionMethod"
// ),
// new CodeExpression[] {
// new CodeSnippetExpression("\"gl" + d.Name + "\""),
// new CodeTypeOfExpression("Delegates." + d.Name)
// }
// )
//);
// Hack - generate inline initialisers in the form:
// public static Accum glAccum = GetDelegate[...] ?? new Accum(Imports.Accum);
CodeSnippetExpression expr = new CodeSnippetExpression();
//expr.Value = "public static " + d.Name + " gl" + d.Name + " = ";
expr.Value +=
"((" + d.Name + ")(" + Settings.GLClass +".GetDelegateForExtensionMethod(\"" + "gl" + d.Name + "\", typeof(" + d.Name + "))))";
if (d.UserData.Contains("Extension") && !(bool)d.UserData["Extension"])
{
expr.Value += " ?? ";
expr.Value += "new " + d.Name + "(Imports." + d.Name + ")";
}
m.InitExpression = expr;
delegate_class.Members.Add(m);
/*
if (!(bool)d.UserData["Extension"])
{
statements.Add(
new CodeSnippetExpression(
"Delegates.gl" + d.Name + " = Delegates.gl" + d.Name + " ?? new Delegates." + d.Name + "(Imports." + d.Name + ")"
)
);
}
*/
}
// Disable BeforeFieldInit attribute and initialize OpenGL core.
CodeTypeConstructor con = new CodeTypeConstructor();
//con.Statements.AddRange(statements);
delegate_class.Members.Add(con);
delegate_class.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, delegate_class.Name));
delegate_class.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, delegate_class.Name));
return delegate_class;
}
#endregion
#region private static CodeTypeDeclaration GenerateImportsClass(List<CodeTypeDelegate> delegates)
private static CodeTypeDeclaration GenerateImportsClass(List<CodeTypeDelegate> delegates)
{
CodeTypeDeclaration import_class = new CodeTypeDeclaration("Imports");
import_class.TypeAttributes = System.Reflection.TypeAttributes.NotPublic;
import_class.Members.Add(new CodeTypeConstructor());
foreach (CodeTypeDelegate d in delegates)
{
if (!(bool)d.UserData["Extension"])
{
CodeMemberMethodImport m = new CodeMemberMethodImport();
m.Name = d.Name;
m.CustomAttributes.Add(new CodeAttributeDeclaration("System.Security.SuppressUnmanagedCodeSecurity()"));
m.CustomAttributes.Add(
new CodeAttributeDeclaration(
"DllImport(" + Settings.GLClass + ".GL_NATIVE_LIBRARY, EntryPoint = \"" + "gl" + m.Name + "\", ExactSpelling = true)"
)
);
m.Parameters.AddRange(d.Parameters);
m.ReturnType = d.ReturnType;
import_class.Members.Add(new CodeSnippetTypeMember(m.Text));
}
}
import_class.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, import_class.Name));
import_class.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, import_class.Name));
return import_class;
}
#endregion
}
#region class CodeMemberMethodImport : CodeMemberMethod
/// <summary>
/// A hack to create the C# code for a DllImported function;
/// CodeDom does not directly support static extern methods.
/// </summary>
class CodeMemberMethodImport : CodeMemberMethod
{
public string Text
{
get
{
string s;
//m.Attributes = MemberAttributes.Static | MemberAttributes.Public;
s = " #region " + this.Name + Environment.NewLine;
s += " [System.Security.SuppressUnmanagedCodeSecurity()]" + Environment.NewLine;
s += " [DllImport(" + Settings.GLClass + ".GL_NATIVE_LIBRARY, EntryPoint = \"" + "gl" + this.Name + "\", ExactSpelling = true)]" + Environment.NewLine;
s += " public extern static ";
if (this.ReturnType.BaseType == "System.Void")
{
s += "void";
}
else
{
s += this.ReturnType.BaseType;
}
s += " " + this.Name + "(";
foreach (CodeParameterDeclarationExpression p in this.Parameters)
{
s += p.Type.BaseType;
if (p.Type.ArrayRank > 0)
s += "[]";
s += " ";
if (p.Name == "base")
s += "@base";
else if (p.Name == "params")
s += "@params";
else if (p.Name == "string")
s += "@string";
else if (p.Name == "ref")
s += "@ref";
else
s += p.Name;
s += ", ";
}
s = s.TrimEnd(',', ' ') + ");" + Environment.NewLine;
s += " #endregion" + Environment.NewLine;
return s;
}
}
}
#endregion
}

View file

@ -0,0 +1,35 @@
# Normal types.
GLsizei, Int32
GLsizeiptr, IntPtr
GLintptr, IntPtr
# GLenum, Int32
GLboolean, Boolean #Int32 #Boolean
GLbitfield, Int32 #UInt32
# GLvoid*, IntPtr
GLvoid, Object
GLchar, Char
GLbyte, Byte #SByte
GLubyte, Byte
GLshort, Int16
GLushort, Int16 #UInt16
GLint, Int32
GLuint, Int32 #UInt32
GLfloat, Single
GLclampf, Single
GLdouble, Double
GLclampd, Double
GLstring, String
# ARB and NV types.
GLsizeiptrARB, IntPtr
GLintptrARB, IntPtr
GLhandleARB, Int32 #UInt32
GLhalfARB, Int16 #UInt16
GLhalfNV, Int16 #UInt16
GLcharARB, Char
# 64 bit types (introduced in 2.1)
GLint64EXT, Int64
GLuint64EXT, Int64
GLint64, Int64
GLuint64, Int64

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,251 @@
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2002 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
###############################################################################
Extensions define:
EXT_object_space_tess = 1
EXT_nurbs_tessellator = 1
###############################################################################
Boolean enum:
FALSE = 0
TRUE = 1
###############################################################################
Version enum:
VERSION_1_1 = 1
VERSION_1_2 = 1
VERSION_1_3 = 1
###############################################################################
StringName enum:
VERSION = 100800
EXTENSIONS = 100801
###############################################################################
ErrorCode enum:
INVALID_ENUM = 100900
INVALID_VALUE = 100901
OUT_OF_MEMORY = 100902
########INCOMPATIBLE_GL_VERSION = 100903
INVALID_OPERATION = 100904
###############################################################################
Filter4TypeSGIS enum:
LAGRANGIAN_SGI = 100300
MITCHELL_NETRAVALI_SGI = 100301
###############################################################################
NurbsDisplay enum:
use QuadricDrawStyle FILL
OUTLINE_POLYGON = 100240
OUTLINE_PATCH = 100241
NurbsCallback enum:
NURBS_ERROR = 100103
ERROR = 100103
NURBS_BEGIN = 100164
NURBS_BEGIN_EXT = 100164
NURBS_VERTEX = 100165
NURBS_VERTEX_EXT = 100165
NURBS_NORMAL = 100166
NURBS_NORMAL_EXT = 100166
NURBS_COLOR = 100167
NURBS_COLOR_EXT = 100167
NURBS_TEXTURE_COORD = 100168
NURBS_TEXTURE_COORD_EXT = 100168
NURBS_END = 100169
NURBS_END_EXT = 100169
NURBS_BEGIN_DATA = 100170
NURBS_BEGIN_DATA_EXT = 100170
NURBS_VERTEX_DATA = 100171
NURBS_VERTEX_DATA_EXT = 100171
NURBS_NORMAL_DATA = 100172
NURBS_NORMAL_DATA_EXT = 100172
NURBS_COLOR_DATA = 100173
NURBS_COLOR_DATA_EXT = 100173
NURBS_TEXTURE_COORD_DATA = 100174
NURBS_TEXTURE_COORD_DATA_EXT = 100174
NURBS_END_DATA = 100175
NURBS_END_DATA_EXT = 100175
NurbsError enum:
NURBS_ERROR1 = 100251
NURBS_ERROR2 = 100252
NURBS_ERROR3 = 100253
NURBS_ERROR4 = 100254
NURBS_ERROR5 = 100255
NURBS_ERROR6 = 100256
NURBS_ERROR7 = 100257
NURBS_ERROR8 = 100258
NURBS_ERROR9 = 100259
NURBS_ERROR10 = 100260
NURBS_ERROR11 = 100261
NURBS_ERROR12 = 100262
NURBS_ERROR13 = 100263
NURBS_ERROR14 = 100264
NURBS_ERROR15 = 100265
NURBS_ERROR16 = 100266
NURBS_ERROR17 = 100267
NURBS_ERROR18 = 100268
NURBS_ERROR19 = 100269
NURBS_ERROR20 = 100270
NURBS_ERROR21 = 100271
NURBS_ERROR22 = 100272
NURBS_ERROR23 = 100273
NURBS_ERROR24 = 100274
NURBS_ERROR25 = 100275
NURBS_ERROR26 = 100276
NURBS_ERROR27 = 100277
NURBS_ERROR28 = 100278
NURBS_ERROR29 = 100279
NURBS_ERROR30 = 100280
NURBS_ERROR31 = 100281
NURBS_ERROR32 = 100282
NURBS_ERROR33 = 100283
NURBS_ERROR34 = 100284
NURBS_ERROR35 = 100285
NURBS_ERROR36 = 100286
NURBS_ERROR37 = 100287
NurbsProperty enum:
AUTO_LOAD_MATRIX = 100200
CULLING = 100201
SAMPLING_TOLERANCE = 100203
DISPLAY_MODE = 100204
PARAMETRIC_TOLERANCE = 100202
SAMPLING_METHOD = 100205
U_STEP = 100206
V_STEP = 100207
NURBS_MODE = 100160
NURBS_MODE_EXT = 100160
NURBS_TESSELLATOR = 100161
NURBS_TESSELLATOR_EXT = 100161
NURBS_RENDERER = 100162
NURBS_RENDERER_EXT = 100162
NurbsSampling enum:
OBJECT_PARAMETRIC_ERROR = 100208
OBJECT_PARAMETRIC_ERROR_EXT = 100208
OBJECT_PATH_LENGTH = 100209
OBJECT_PATH_LENGTH_EXT = 100209
PATH_LENGTH = 100215
PARAMETRIC_ERROR = 100216
DOMAIN_DISTANCE = 100217
NurbsTrim enum:
MAP1_TRIM_2 = 100210
MAP1_TRIM_3 = 100211
###############################################################################
QuadricDrawStyle enum:
POINT = 100010
LINE = 100011
FILL = 100012
SILHOUETTE = 100013
QuadricCallback enum:
use NurbsCallback ERROR
QuadricNormal enum:
SMOOTH = 100000
FLAT = 100001
NONE = 100002
QuadricOrientation enum:
OUTSIDE = 100020
INSIDE = 100021
###############################################################################
TessCallback enum:
TESS_BEGIN = 100100
BEGIN = 100100
TESS_VERTEX = 100101
VERTEX = 100101
TESS_END = 100102
END = 100102
TESS_ERROR = 100103
ERROR = 100103
TESS_EDGE_FLAG = 100104
EDGE_FLAG = 100104
TESS_COMBINE = 100105
TESS_BEGIN_DATA = 100106
TESS_VERTEX_DATA = 100107
TESS_END_DATA = 100108
TESS_ERROR_DATA = 100109
TESS_EDGE_FLAG_DATA = 100110
TESS_COMBINE_DATA = 100111
TessContour enum:
CW = 100120
CCW = 100121
INTERIOR = 100122
EXTERIOR = 100123
UNKNOWN = 100124
TessProperty enum:
TESS_WINDING_RULE = 100140
TESS_BOUNDARY_ONLY = 100141
TESS_TOLERANCE = 100142
TessError enum:
TESS_ERROR1 = 100151
TESS_ERROR2 = 100152
TESS_ERROR3 = 100153
TESS_ERROR4 = 100154
TESS_ERROR5 = 100155
TESS_ERROR6 = 100156
TESS_ERROR7 = 100157
TESS_ERROR8 = 100158
TESS_MISSING_BEGIN_POLYGON = 100151
TESS_MISSING_BEGIN_CONTOUR = 100152
TESS_MISSING_END_POLYGON = 100153
TESS_MISSING_END_CONTOUR = 100154
TESS_COORD_TOO_LARGE = 100155
TESS_NEED_COMBINE_CALLBACK = 100156
TessWinding enum:
TESS_WINDING_ODD = 100130
TESS_WINDING_NONZERO = 100131
TESS_WINDING_POSITIVE = 100132
TESS_WINDING_NEGATIVE = 100133
TESS_WINDING_ABS_GEQ_TWO = 100134
###############################################################################

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,291 @@
AccumOp,*,*, GLenum,*,*
AlphaFunction,*,*, GLenum,*,*
AttribMask,*,*, GLbitfield,*,*
BeginMode,*,*, GLenum,*,*
BinormalPointerTypeEXT,*,*, GLenum,*,*
BlendEquationMode,*,*, GLenum,*,*
BlendEquationModeEXT,*,*, GLenum,*,*
BlendFuncSeparateParameterEXT,*,*, GLenum,*,*
BlendingFactorDest,*,*, GLenum,*,*
BlendingFactorSrc,*,*, GLenum,*,*
Boolean,*,*, GLboolean,*,*
BooleanPointer,*,*, GLboolean*,*,*
Char,*,*, GLchar,*,*
CharPointer,*,*, GLchar*,*,*
CheckedFloat32,*,*, GLfloat,*,*
CheckedInt32,*,*, GLint,*,*
ClampColorTargetARB,*,*, GLenum,*,*
ClampColorModeARB,*,*, GLenum,*,*
ClampedColorF,*,*, GLclampf,*,*
ClampedFloat32,*,*, GLclampf,*,*
ClampedFloat64,*,*, GLclampd,*,*
ClampedStencilValue,*,*, GLint,*,*
ClearBufferMask,*,*, GLbitfield,*,*
ClientAttribMask,*,*, GLbitfield,*,*
ClipPlaneName,*,*, GLenum,*,*
ColorB,*,*, GLbyte,*,*
ColorD,*,*, GLdouble,*,*
ColorF,*,*, GLfloat,*,*
ColorI,*,*, GLint,*,*
ColorIndexValueD,*,*, GLdouble,*,*
ColorIndexValueF,*,*, GLfloat,*,*
ColorIndexValueI,*,*, GLint,*,*
ColorIndexValueS,*,*, GLshort,*,*
ColorIndexValueUB,*,*, GLubyte,*,*
ColorMaterialParameter,*,*, GLenum,*,*
ColorPointerType,*,*, GLenum,*,*
ColorS,*,*, GLshort,*,*
ColorTableParameterPName,*,*, GLenum,*,*
ColorTableParameterPNameSGI,*,*, GLenum,*,*
ColorTableTarget,*,*, GLenum,*,*
ColorTableTargetSGI,*,*, GLenum,*,*
ColorUB,*,*, GLubyte,*,*
ColorUI,*,*, GLuint,*,*
ColorUS,*,*, GLushort,*,*
CombinerBiasNV,*,*, GLenum,*,*
CombinerComponentUsageNV,*,*, GLenum,*,*
CombinerMappingNV,*,*, GLenum,*,*
CombinerParameterNV,*,*, GLenum,*,*
CombinerPortionNV,*,*, GLenum,*,*
CombinerRegisterNV,*,*, GLenum,*,*
CombinerScaleNV,*,*, GLenum,*,*
CombinerStageNV,*,*, GLenum,*,*
CombinerVariableNV,*,*, GLenum,*,*
CompressedTextureARB,*,*, GLvoid,*,*
ControlPointNV,*,*, GLvoid,*,*
ControlPointTypeNV,*,*, GLenum,*,*
ConvolutionParameter,*,*, GLenum,*,*
ConvolutionParameterEXT,*,*, GLenum,*,*
ConvolutionTarget,*,*, GLenum,*,*
ConvolutionTargetEXT,*,*, GLenum,*,*
CoordD,*,*, GLdouble,*,*
CoordF,*,*, GLfloat,*,*
CoordI,*,*, GLint,*,*
CoordS,*,*, GLshort,*,*
CullFaceMode,*,*, GLenum,*,*
CullParameterEXT,*,*, GLenum,*,*
DepthFunction,*,*, GLenum,*,*
DrawBufferMode,*,*, GLenum,*,*
DrawElementsType,*,*, GLenum,*,*
ElementPointerTypeATI,*,*, GLenum,*,*
EnableCap,*,*, GLenum,*,*
ErrorCode,*,*, GLenum,*,*
EvalMapsModeNV,*,*, GLenum,*,*
EvalTargetNV,*,*, GLenum,*,*
FeedbackElement,*,*, GLfloat,*,*
FeedbackType,*,*, GLenum,*,*
FenceNV,*,*, GLuint,*,*
FenceConditionNV,*,*, GLenum,*,*
FenceParameterNameNV,*,*, GLenum,*,*
FfdMaskSGIX,*,*, GLbitfield,*,*
FfdTargetSGIX,*,*, GLenum,*,*
Float32,*,*, GLfloat,*,*
Float32Pointer,*,*, GLfloat*,*,*
Float64,*,*, GLdouble,*,*
Float64Pointer,*,*, GLdouble*,*,*
FogParameter,*,*, GLenum,*,*
FogPointerTypeEXT,*,*, GLenum,*,*
FogPointerTypeIBM,*,*, GLenum,*,*
FragmentLightModelParameterSGIX,*,*,GLenum,*,*
FragmentLightNameSGIX,*,*, GLenum,*,*
FragmentLightParameterSGIX,*,*, GLenum,*,*
FramebufferAttachment,*,*, GLenum,*,*
FramebufferTarget,*,*, GLenum,*,*
FrontFaceDirection,*,*, GLenum,*,*
FunctionPointer,*,*, _GLfuncptr,*,*
GetColorTableParameterPName,*,*, GLenum,*,*
GetColorTableParameterPNameSGI,*,*, GLenum,*,*
GetConvolutionParameterPName,*,*, GLenum,*,*
GetHistogramParameterPName,*,*, GLenum,*,*
GetHistogramParameterPNameEXT,*,*, GLenum,*,*
GetMapQuery,*,*, GLenum,*,*
GetMinmaxParameterPName,*,*, GLenum,*,*
GetMinmaxParameterPNameEXT,*,*, GLenum,*,*
GetPName,*,*, GLenum,*,*
GetPointervPName,*,*, GLenum,*,*
GetTextureParameter,*,*, GLenum,*,*
HintMode,*,*, GLenum,*,*
HintTarget,*,*, GLenum,*,*
HintTargetPGI,*,*, GLenum,*,*
HistogramTarget,*,*, GLenum,*,*
HistogramTargetEXT,*,*, GLenum,*,*
IglooFunctionSelectSGIX,*,*, GLenum,*,*
IglooParameterSGIX,*,*, GLvoid,*,*
ImageTransformPNameHP,*,*, GLenum,*,*
ImageTransformTargetHP,*,*, GLenum,*,*
IndexFunctionEXT,*,*, GLenum,*,*
IndexMaterialParameterEXT,*,*, GLenum,*,*
IndexPointerType,*,*, GLenum,*,*
Int16,*,*, GLshort,*,*
Int32,*,*, GLint,*,*
Int8,*,*, GLbyte,*,*
InterleavedArrayFormat,*,*, GLenum,*,*
LightEnvParameterSGIX,*,*, GLenum,*,*
LightModelParameter,*,*, GLenum,*,*
LightName,*,*, GLenum,*,*
LightParameter,*,*, GLenum,*,*
LightTextureModeEXT,*,*, GLenum,*,*
LightTexturePNameEXT,*,*, GLenum,*,*
LineStipple,*,*, GLushort,*,*
List,*,*, GLuint,*,*
ListMode,*,*, GLenum,*,*
ListNameType,*,*, GLenum,*,*
ListParameterName,*,*, GLenum,*,*
LogicOp,*,*, GLenum,*,*
MapAttribParameterNV,*,*, GLenum,*,*
MapParameterNV,*,*, GLenum,*,*
MapTarget,*,*, GLenum,*,*
MapTargetNV,*,*, GLenum,*,*
MapTypeNV,*,*, GLenum,*,*
MaskedColorIndexValueF,*,*, GLfloat,*,*
MaskedColorIndexValueI,*,*, GLuint,*,*
MaskedStencilValue,*,*, GLuint,*,*
MaterialFace,*,*, GLenum,*,*
MaterialParameter,*,*, GLenum,*,*
MatrixIndexPointerTypeARB,*,*, GLenum,*,*
MatrixMode,*,*, GLenum,*,*
MatrixTransformNV,*,*, GLenum,*,*
MeshMode1,*,*, GLenum,*,*
MeshMode2,*,*, GLenum,*,*
MinmaxTarget,*,*, GLenum,*,*
MinmaxTargetEXT,*,*, GLenum,*,*
NormalPointerType,*,*, GLenum,*,*
NurbsCallback,*,*, GLenum,*,*
NurbsObj,*,*, GLUnurbs*,*,*
NurbsProperty,*,*, GLenum,*,*
NurbsTrim,*,*, GLenum,*,*
OcclusionQueryParameterNameNV,*,*, GLenum,*,*
PixelCopyType,*,*, GLenum,*,*
PixelFormat,*,*, GLenum,*,*
PixelInternalFormat,*,*, GLenum,*,*
PixelMap,*,*, GLenum,*,*
PixelStoreParameter,*,*, GLenum,*,*
PixelTexGenModeSGIX,*,*, GLenum,*,*
PixelTexGenParameterNameSGIS,*,*, GLenum,*,*
PixelTransferParameter,*,*, GLenum,*,*
PixelTransformPNameEXT,*,*, GLenum,*,*
PixelTransformTargetEXT,*,*, GLenum,*,*
PixelType,*,*, GLenum,*,*
PointParameterNameARB,*,*, GLenum,*,*
PolygonMode,*,*, GLenum,*,*
ProgramNV,*,*, GLuint,*,*
ProgramCharacterNV,*,*, GLubyte,*,*
ProgramParameterNV,*,*, GLenum,*,*
ProgramParameterPName,*,*, GLenum,*,*
QuadricCallback,*,*, GLenum,*,*
QuadricDrawStyle,*,*, GLenum,*,*
QuadricNormal,*,*, GLenum,*,*
QuadricObj,*,*, GLUquadric*,*,*
QuadricOrientation,*,*, GLenum,*,*
ReadBufferMode,*,*, GLenum,*,*
RenderbufferTarget,*,*, GLenum,*,*
RenderingMode,*,*, GLenum,*,*
ReplacementCodeSUN,*,*, GLuint,*,*
ReplacementCodeTypeSUN,*,*, GLenum,*,*
SamplePassARB,*,*, GLenum,*,*
SamplePatternEXT,*,*, GLenum,*,*
SamplePatternSGIS,*,*, GLenum,*,*
SecondaryColorPointerTypeIBM,*,*, GLenum,*,*
SelectName,*,*, GLuint,*,*
SeparableTarget,*,*, GLenum,*,*
SeparableTargetEXT,*,*, GLenum,*,*
ShadingModel,*,*, GLenum,*,*
SizeI,*,*, GLsizei,*,*
SpriteParameterNameSGIX,*,*, GLenum,*,*
StencilFunction,*,*, GLenum,*,*
StencilFaceDirection,*,*, GLenum,*,*
StencilOp,*,*, GLenum,*,*
StencilValue,*,*, GLint,*,*
String,*,*, GLstring,*,*
StringName,*,*, GLenum,*,*
TangentPointerTypeEXT,*,*, GLenum,*,*
TessCallback,*,*, GLenum,*,*
TessContour,*,*, GLenum,*,*
TessProperty,*,*, GLenum,*,*
TesselatorObj,*,*, GLUtesselator*,*,*
TexCoordPointerType,*,*, GLenum,*,*
Texture,*,*, GLuint,*,*
TextureComponentCount,*,*, GLint,*,*
TextureCoordName,*,*, GLenum,*,*
TextureEnvParameter,*,*, GLenum,*,*
TextureEnvTarget,*,*, GLenum,*,*
TextureFilterSGIS,*,*, GLenum,*,*
TextureGenParameter,*,*, GLenum,*,*
TextureNormalModeEXT,*,*, GLenum,*,*
TextureParameterName,*,*, GLenum,*,*
TextureTarget,*,*, GLenum,*,*
TextureUnit,*,*, GLenum,*,*
UInt16,*,*, GLushort,*,*
UInt32,*,*, GLuint,*,*
UInt8,*,*, GLubyte,*,*
VertexAttribEnum,*,*, GLenum,*,*
VertexAttribEnumNV,*,*, GLenum,*,*
VertexAttribPointerTypeNV,*,*, GLenum,*,*
VertexPointerType,*,*, GLenum,*,*
VertexWeightPointerTypeEXT,*,*, GLenum,*,*
Void,*,*, GLvoid,*,*
VoidPointer,*,*, GLvoid*,*,*
ConstVoidPointer,*,*, GLvoid* const,*,*
WeightPointerTypeARB,*,*, GLenum,*,*
WinCoord,*,*, GLint,*,*
void,*,*, *,*,*
ArrayObjectPNameATI,*,*, GLenum,*,*
ArrayObjectUsageATI,*,*, GLenum,*,*,
ConstFloat32,*,*, GLfloat,*,*
ConstInt32,*,*, GLint,*,*
ConstUInt32,*,*, GLuint,*,*
ConstVoid,*,*, GLvoid,*,*
DataTypeEXT,*,*, GLenum,*,*
FragmentOpATI,*,*, GLenum,*,*
GetTexBumpParameterATI,*,*, GLenum,*,*
GetVariantValueEXT,*,*, GLenum,*,*
ParameterRangeEXT,*,*, GLenum,*,*
PreserveModeATI,*,*, GLenum,*,*
ProgramFormatARB,*,*, GLenum,*,*
ProgramTargetARB,*,*, GLenum,*,*
ProgramTarget,*,*, GLenum,*,*
ProgramPropertyARB,*,*, GLenum,*,*
ProgramStringPropertyARB,*,*, GLenum,*,*
ScalarType,*,*, GLenum,*,*
SwizzleOpATI,*,*, GLenum,*,*
TexBumpParameterATI,*,*, GLenum,*,*
VariantCapEXT,*,*, GLenum,*,*
VertexAttribPointerPropertyARB,*,*, GLenum,*,*
VertexAttribPointerTypeARB,*,*, GLenum,*,*
VertexAttribPropertyARB,*,*, GLenum,*,*
VertexShaderCoordOutEXT,*,*, GLenum,*,*
VertexShaderOpEXT,*,*, GLenum,*,*
VertexShaderParameterEXT,*,*, GLenum,*,*
VertexShaderStorageTypeEXT,*,*, GLenum,*,*
VertexShaderTextureUnitParameter,*,*, GLenum,*,*
VertexShaderWriteMaskEXT,*,*, GLenum,*,*
VertexStreamATI,*,*, GLenum,*,*
PNTrianglesPNameATI,*,*, GLenum,*,*
# ARB_vertex_buffer_object types and core equivalents for new types
BufferOffset,*,*, GLintptr,*,*
BufferSize,*,*, GLsizeiptr,*,*
BufferAccessARB,*,*, GLenum,*,*
BufferOffsetARB,*,*, GLintptrARB,*,*
BufferPNameARB,*,*, GLenum,*,*
BufferPointerNameARB,*,*, GLenum,*,*
BufferSizeARB,*,*, GLsizeiptrARB,*,*
BufferTargetARB,*,*, GLenum,*,*
BufferUsageARB,*,*, GLenum,*,*
# APPLE_fence
ObjectTypeAPPLE,*,*, GLenum,*,*
# APPLE_vertex_array_range
VertexArrayPNameAPPLE,*,*, GLenum,*,*
# ATI_draw_buffers
DrawBufferModeATI,*,*, GLenum,*,*
# NV_half
Half16NV,*,*, GLhalfNV,*,*
# NV_pixel_data_range
PixelDataRangeTargetNV,*,*, GLenum,*,*
# Generic types for as-yet-unspecified enums
GLenum,*,*, GLenum,*,*
handleARB,*,*, GLhandleARB,*,*
charARB,*,*, GLcharARB,*,*
charPointerARB,*,*, GLcharARB*,*,*
# EXT_timer_query
Int64EXT,*,*, GLint64EXT,*,*
UInt64EXT,*,*, GLuint64EXT,*,*

View file

@ -0,0 +1,438 @@
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2002 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
param: retval retained
version: 1.0
BeginCurve(nurb)
return void
param nurb NurbsObj in value
BeginPolygon(tess)
return void
param tess TesselatorObj in value
BeginSurface(nurb)
return void
param nurb NurbsObj in value
BeginTrim(nurb)
return void
param nurb NurbsObj in value
Build1DMipmapLevels(target, internalFormat, width, format, type, level, base, max, data);
return Int32
param target TextureTarget in value
param internalFormat Int32 in value
param width SizeI in value
param format PixelFormat in value
param type PixelType in value
param level Int32 in value
param base Int32 in value
param max Int32 in value
param data void in reference
Build1DMipmaps(target, internalFormat, width, format, type, data);
return Int32
param target TextureTarget in value
param internalFormat Int32 in value
param width SizeI in value
param format PixelFormat in value
param type PixelType in value
param data void in reference
Build2DMipmapLevels(target, internalFormat, width, height, format, type, level, base, max, data);
return Int32
param target TextureTarget in value
param internalFormat Int32 in value
param width SizeI in value
param height SizeI in value
param format PixelFormat in value
param type PixelType in value
param level Int32 in value
param base Int32 in value
param max Int32 in value
param data void in reference
Build2DMipmaps(target, internalFormat, width, height, format, type, data);
return Int32
param target TextureTarget in value
param internalFormat Int32 in value
param width SizeI in value
param height SizeI in value
param format PixelFormat in value
param type PixelType in value
param data void in reference
Build3DMipmapLevels(target, internalFormat, width, height, depth, format, type, level, base, max, data);
return Int32
param target TextureTarget in value
param internalFormat Int32 in value
param width SizeI in value
param height SizeI in value
param depth SizeI in value
param format PixelFormat in value
param type PixelType in value
param level Int32 in value
param base Int32 in value
param max Int32 in value
param data void in reference
Build3DMipmaps(target, internalFormat, width, height, depth, format, type, data);
return Int32
param target TextureTarget in value
param internalFormat Int32 in value
param width SizeI in value
param height SizeI in value
param depth SizeI in value
param format PixelFormat in value
param type PixelType in value
param data void in reference
CheckExtension(extName, extString)
return Boolean
param extName UInt8 in array [COMPSIZE()]
param extString UInt8 in array [COMPSIZE()]
Cylinder(quad, base, top, height, slices, stacks);
return void
param quad QuadricObj in value
param base Float64 in value
param top Float64 in value
param height Float64 in value
param slices Int32 in value
param stacks Int32 in value
DeleteNurbsRenderer(nurb)
return void
param nurb NurbsObj in value
DeleteQuadric(quad)
return void
param quad QuadricObj in value
DeleteTess(tess)
return void
param tess TesselatorObj in value
Disk(quad, inner, outer, slices, loops)
return void
param quad QuadricObj in value
param inner Float64 in value
param outer Float64 in value
param slices Int32 in value
param loops Int32 in value
EndCurve(nurb)
return void
param nurb NurbsObj in value
EndPolygon(tess)
return void
param tess TesselatorObj in value
EndSurface(nurb)
return void
param nurb NurbsObj in value
EndTrim(nurb)
return void
param nurb NurbsObj in value
ErrorString(error)
return String
param error ErrorCode in value
GetString(name)
return String
param name StringName in value
GetNurbsProperty(nurb, property, data)
return void
param nurb NurbsObj in value
param property NurbsProperty in value
param data Float32Pointer out value
GetTessProperty(tess, which, data)
return void
param tess TesselatorObj in value
param which TessProperty in value
param data Float64Pointer out value
LoadSamplingMatrices(nurb, model, perspective, view)
return void
param nurb NurbsObj in value
param model Float32 in array [16]
param perspective Float32 in array [16]
param view Int32 in array [4]
LookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)
return void
param eyeX Float64 in value
param eyeY Float64 in value
param eyeZ Float64 in value
param centerX Float64 in value
param centerY Float64 in value
param centerZ Float64 in value
param upX Float64 in value
param upY Float64 in value
param upZ Float64 in value
NewNurbsRenderer()
return NurbsObj
NewQuadric()
return QuadricObj
NewTess()
return TesselatorObj
NextContour(tess, type)
return void
param tess TesselatorObj in value
param type TessContour in value
NurbsCallback(nurb, which, CallBackFunc)
return void
param nurb NurbsObj in value
param which NurbsCallback in value
param CallBackFunc FunctionPointer in value
NurbsCallbackData(nurb, userData)
return void
param nurb NurbsObj in value
param userData VoidPointer in value
NurbsCallbackDataEXT(nurb, userData)
return void
param nurb NurbsObj in value
param userData VoidPointer in value
NurbsCurve(nurb, knotCount, knots, stride, control, order, type)
return void
param nurb NurbsObj in value
param knotCount Int32 in value
param knots Float32 out reference
param stride Int32 in value
param control Float32 out reference
param order Int32 in value
param type MapTarget in value
NurbsProperty(nurb, property, value)
return void
param nurb NurbsObj in value
param property NurbsProperty in value
param value Float32 in value
NurbsSurface(nurb, sKnotCount, sKnots, tKnotCount, tKnots, sStride, tStride, control, sOrder, tOrder, type)
return void
param nurb NurbsObj in value
param sKnotCount Int32 in value
param sKnots Float32Pointer in value
param tKnotCount Int32 in value
param tKnots Float32Pointer in value
param sStride Int32 in value
param tStride Int32 in value
param control Float32Pointer in value
param sOrder Int32 in value
param tOrder Int32 in value
param type MapTarget in value
Ortho2D(left, right, bottom, top)
return void
param left Float64 in value
param right Float64 in value
param bottom Float64 in value
param top Float64 in value
PartialDisk(quad, inner, outer, slices, loops, start, sweep)
return void
param quad QuadricObj in value
param inner Float64 in value
param outer Float64 in value
param slices Int32 in value
param loops Int32 in value
param start Float64 in value
param sweep Float64 in value
Perspective(fovy, aspect, zNear, zFar)
return void
param fovy Float64 in value
param aspect Float64 in value
param zNear Float64 in value
param zFar Float64 in value
PickMatrix(x, y, delX, delY, viewport)
return void
param x Float64 in value
param y Float64 in value
param delX Float64 in value
param delY Float64 in value
param viewport Int32 out array [4]
Project(objX, objY, objZ, model, proj, view, winX, winY, winZ)
return Int32
param objX Float64 in value
param objY Float64 in value
param objZ Float64 in value
param model Float64 in array [16]
param proj Float64 in array [16]
param view Int32 in array [4]
param winX Float64Pointer in value
param winY Float64Pointer in value
param winZ Float64Pointer in value
PwlCurve(nurb, count, data, stride, type)
return void
param nurb NurbsObj in value
param count Int32 in value
param data Float32Pointer in value
param stride Int32 in value
param type NurbsTrim in value
QuadricCallback(quad, which, CallBackFunc)
return void
param quad QuadricObj in value
param which QuadricCallback in value
param CallBackFunc FunctionPointer in value
QuadricDrawStyle(quad, draw)
return void
param quad QuadricObj in value
param draw QuadricDrawStyle in value
QuadricNormals(quad, normal)
return void
param quad QuadricObj in value
param normal QuadricNormal in value
QuadricOrientation(quad, orientation)
return void
param quad QuadricObj in value
param orientation QuadricOrientation in value
QuadricTexture(quad, texture)
return void
param quad QuadricObj in value
param texture Boolean in value
ScaleImage(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut)
return Int32
param format PixelFormat in value
param wIn SizeI in value
param hIn SizeI in value
param typeIn PixelType in value
param dataIn void in reference
param wOut SizeI in value
param hOut SizeI in value
param typeOut PixelType in value
param dataOut VoidPointer out value
Sphere(quad, radius, slices, stacks)
return void
param quad QuadricObj in value
param radius Float64 in value
param slices Int32 in value
param stacks Int32 in value
TessBeginContour(tess)
return void
param tess TesselatorObj in value
TessBeginPolygon(tess, data)
return void
param tess TesselatorObj in value
param data VoidPointer in value
TessCallback(tess, which, CallBackFunc)
return void
param tess TesselatorObj in value
param which TessCallback in value
param CallBackFunc FunctionPointer in value
TessEndContour(tess)
return void
param tess TesselatorObj in value
TessEndPolygon(tess)
return void
param tess TesselatorObj in value
TessNormal(tess, valueX, valueY, valueZ)
return void
param tess TesselatorObj in value
param valueX Float64 in value
param valueY Float64 in value
param valueZ Float64 in value
TessProperty(tess, which, data)
return void
param tess TesselatorObj in value
param which TessProperty in value
param data Float64 in value
TessVertex(tess, location, data)
return void
param tess TesselatorObj in value
param location Float64 out array [3]
param data VoidPointer in value
TexFilterFuncSGI(target, filtertype, parms, n, weights)
return Int32 out value
param target TextureTarget in value
param filtertype Filter4TypeSGIS in value
param parms Float32 in array [2]
param n Int32 in value
param weights Float32Pointer out value
UnProject(winX, winY, winZ, model, proj, view, objX, objY, objZ)
return Int32
param winX Float64 in value
param winY Float64 in value
param winZ Float64 in value
param model Float64 in array [16]
param proj Float64 in array [16]
param view Int32 in array [4]
param objX Float64Pointer in value
param objY Float64Pointer in value
param objZ Float64Pointer in value
UnProject4(winX, winY, winZ, clipW, model, proj, view, near, far, objX, objY, objZ, objW)
return Int32
param winX Float64 in value
param winY Float64 in value
param winZ Float64 in value
param clipW Float64 in value
param model Float64 in array [16]
param proj Float64 in array [16]
param view Int32 in array [4]
param near Float64 in value
param far Float64 in value
param objX Float64Pointer in value
param objY Float64Pointer in value
param objZ Float64Pointer in value
param objW Float64Pointer in value

View file

@ -0,0 +1,621 @@
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2005 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
required-props:
param: retval retained
dlflags: notlistable handcode nop
glxflags: client-handcode server-handcode
glxvendorglx: *
vectorequiv: *
category: pixel-rw bgn-end display-list drawing drawing-control feedback framebuf misc modeling pixel-op pixel-rw state-req xform glx glxopcode
glxopcode: *
###############################################################################
#
# GLX1.0 commands
#
###############################################################################
Render()
return void
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 1
RenderLarge()
return void
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 2
CreateContext(gc_id, screen, visual, share_list)
return void
param gc_id Int32 in value
param screen Int32 in value
param visual Int32 in value
param share_list Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 3
DestroyContext(context)
return void
param context Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 4
MakeCurrent(drawable, context)
return void
param drawable Int32 in value
param context Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 5
IsDirect(dpy, context)
return void
param dpy Int32 in value
param context Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 6
QueryVersion(major, minor)
return void
param major Int32 out reference
param minor Int32 out reference
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 7
WaitGL(context)
return void
param context Int32 in value
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 8
WaitX()
return void
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 9
CopyContext(source, dest, mask)
return void
param source Int32 in value
param dest Int32 in value
param mask Int32 in value
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 10
SwapBuffers(drawable)
return void
param drawable Int32 in value
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 11
UseXFont(font, first, count, list_base)
return void
param font Int32 in value
param first Int32 in value
param count Int32 in value
param list_base Int32 in value
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 12
CreateGLXPixmap(visual, pixmap, glxpixmap)
return void
param visual Int32 in value
param pixmap Int32 in value
param glxpixmap Int32 in value
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 13
GetVisualConfigs()
return void
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 14
DestroyGLXPixmap(pixmap)
return void
param pixmap Int32 in value
glxflags client-handcode
category glx
dlflags notlistable
glxopcode 15
VendorPrivate()
return void
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 16
VendorPrivateWithReply()
return void
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 17
###############################################################################
#
# GLX1.1 commands
#
###############################################################################
QueryExtensionsString(screen)
return void
param screen Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 18
QueryServerString(screen, name)
return void
param screen Int32 in value
param name Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 19
ClientInfo()
return void
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxopcode 20
###############################################################################
#
# GLX1.3 commands
#
###############################################################################
GetFBConfigs()
return void
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxopcode 21
CreatePixmap(config, pixmap, glxpixmap)
return void
param config Int32 in value
param pixmap Int32 in value
param glxpixmap Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 22
DestroyPixmap(glxpixmap)
return void
param glxpixmap Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 23
CreateNewContext(config, render_type, share_list, direct)
return void
param config Int32 in value
param render_type Int32 in value
param share_list Int32 in value
param direct Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 24
QueryContext()
return void
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 25
MakeContextCurrent(drawable, readdrawable, context)
return void
param drawable Int32 in value
param readdrawable Int32 in value
param context Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 26
CreatePbuffer(config, pbuffer)
return void
param config Int32 in value
param pbuffer Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 27
DestroyPbuffer(pbuffer)
return void
param pbuffer Int32 in value
dlflags notlistable
glxflags client-handcode
category glx
glxopcode 28
GetDrawableAttributes(drawable)
return void
param drawable Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 29
ChangeDrawableAttributes(drawable)
return void
param drawable Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 30
CreateWindow(config, window, glxwindow)
return void
param config Int32 in value
param window Int32 in value
param glxwindow Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 31
DestroyWindow(glxwindow)
return void
param glxwindow Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxopcode 32
###############################################################################
#
# IRIX5.3 extension commands
#
###############################################################################
###############################################################################
#
# SGI_swap_control extension commands
#
###############################################################################
SwapIntervalSGI()
return void
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65536
###############################################################################
#
# IRIX5.3-PATCH154 extension commands
#
###############################################################################
###############################################################################
#
# SGI_make_current_read extension commands
#
###############################################################################
MakeCurrentReadSGI(drawable, readdrawable, context)
return void
param drawable Int32 in value
param readdrawable Int32 in value
param context Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65537
###############################################################################
#
# SGIX_video_source extension commands
#
###############################################################################
CreateGLXVideoSourceSGIX(dpy, screen, server, path, class, node)
return void
param dpy Int32 in value
param screen Int32 in value
param server Int32 in value
param path Int32 in value
param class Int32 in value
param node Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65538
DestroyGLXVideoSourceSGIX(dpy, glxvideosource)
return void
param dpy Int32 in value
param glxvideosource Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65539
###############################################################################
#
# IRIX6.2 extension commands
#
###############################################################################
###############################################################################
#
# EXT_import_context extension commands
#
###############################################################################
QueryContextInfoEXT()
return void
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxvendorglx 1024
###############################################################################
#
# SGIX_fbconfig extension commands
#
###############################################################################
GetFBConfigsSGIX()
return void
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxvendorglx 65540
CreateContextWithConfigSGIX(gc_id, screen, config, share_list)
return void
param gc_id Int32 in value
param screen Int32 in value
param config Int32 in value
param share_list Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65541
CreateGLXPixmapWithConfigSGIX(config, pixmap, glxpixmap)
return void
param config Int32 in value
param pixmap Int32 in value
param glxpixmap Int32 in value
category glx
dlflags notlistable
glxflags client-handcode server-handcode
glxvendorglx 65542
###############################################################################
#
# SGIX_pbuffer extension commands
#
###############################################################################
CreateGLXPbufferSGIX(config, pbuffer)
return void
param config Int32 in value
param pbuffer Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxvendorglx 65543
DestroyGLXPbufferSGIX(pbuffer)
return void
param pbuffer Int32 in value
dlflags notlistable
glxflags client-handcode
category glx
glxvendorglx 65544
ChangeDrawableAttributesSGIX(drawable)
return void
param drawable Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxvendorglx 65545
GetDrawableAttributesSGIX(drawable)
return void
param drawable Int32 in value
dlflags notlistable
glxflags client-handcode server-handcode
category glx
glxvendorglx 65546
###############################################################################
#
# SGIX_swap_group extension commands
#
###############################################################################
JoinSwapGroupSGIX(window,group)
return void
param window Int32 in value
param group Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65547
###############################################################################
#
# SGIX_swap_barrier extension commands
#
###############################################################################
BindSwapBarrierSGIX(window,barrier)
return void
param window Int32 in value
param barrier Int32 in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65548
QueryMaxSwapBarriersSGIX()
return void
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65549
###############################################################################
#
# SGIX_hyperpipe extension commands
#
###############################################################################
QueryHyperpipeNetworkSGIX(dpy, npipes)
return GLXHyperpipeNetworkPointer
param dpy Display out reference
param npipes int out reference
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65550
HyperpipeConfigSGIX(dpy, networkId, npipes, cfg, hpId)
return int
param dpy Display out reference
param networkId int in value
param npipes int in value
param cfg GLXHyperpipeConfig in array[npipes]
param hpId int out reference
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65552
QueryHyperpipeConfigSGIX(dpy, hpId, npipes)
return GLXHyperpipeConfigPointer
param dpy Display out reference
param hpId int in value
param npipes int out reference
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65551
DestroyHyperpipeConfigSGIX(dpy, hpId)
return int
param dpy Display out reference
param hpId int in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx 65553
BindHyperpipeSGIX(dpy, hpId)
return int
param dpy Display out reference
param hpId int in value
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx ???
QueryHyperpipeBestAttribSGIX(dpy, timeSlice, attrib, size, attribList, returnAttribList)
return int
param dpy Display out reference
param timeSlice int in value
param attrib int in value
param size int in value
param attribList Void in array[size]
param returnAttribList Void out array[size]
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx ???
HyperpipeAttribSGIX(dpy, timeSlice, attrib, size, attribList)
return int
param dpy Display out reference
param timeSlice int in value
param attrib int in value
param size int in value
param attribList void in array[size]
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx ???
QueryHyperpipeAttribSGIX(dpy, timeSlice, attrib, size, returnAttribList)
return int
param dpy Display out reference
param timeSlice int in value
param attrib int in value
param size int in value
param returnAttribList void in array[size]
glxflags client-handcode server-handcode
category glx
dlflags notlistable
glxvendorglx ???

View file

@ -0,0 +1,43 @@
Bool,*,*, Bool,*,*
Colormap,*,*, Colormap,*,*
DMbuffer,*,*, DMbuffer,*,*
DMparams,*,*, DMparams,*,*
Display,*,*, Display,*,*
DisplayPointer,*,*, Display *,*,*
FunctionPointer,*,*, __GLXextFuncPtr,*,*
GLXContext,*,*, GLXContext,*,*
constGLXContext,*,*, const GLXContext,*,*
GLXContextID,*,*, GLXContextID,*,*
GLXDrawable,*,*, GLXDrawable,*,*
GLXFBConfig,*,*, GLXFBConfig,*,*
GLXFBConfigPointer,*,*, GLXFBConfig *,*,*
GLXFBConfigSGIX,*,*, GLXFBConfigSGIX,*,*
GLXFBConfigSGIXPointer,*,*, GLXFBConfigSGIX *,*,*
GLXHyperpipeNetworkSGIXPointer,*,*, GLXHyperpipeNetworkSGIX *,*,*
GLXHyperpipeConfigSGIX,*,*, GLXHyperpipeConfigSGIX,*,*
GLXHyperpipeConfigSGIXPointer,*,*, GLXHyperpipeConfigSGIX *,*,*
GLXPbuffer,*,*, GLXPbuffer,*,*
GLXPbufferSGIX,*,*, GLXPbufferSGIX,*,*
GLXPixmap,*,*, GLXPixmap,*,*
GLXVideoSourceSGIX,*,*, GLXVideoSourceSGIX,*,*
GLXWindow,*,*, GLXWindow,*,*
GLenum,*,*, GLenum,*,*
GLfunction,*,*, GLfunction,*,*
GLubyte,*,*, GLubyte,*,*
Pixmap,*,*, Pixmap,*,*
Status,*,*, Status,*,*
Uint,*,*, unsigned int,*,*
VLNode,*,*, VLNode,*,*
VLPath,*,*, VLPath,*,*
VLServer,*,*, VLServer,*,*
Window,*,*, Window,*,*
XVisualInfo,*,*, XVisualInfo,*,*
XVisualInfoPointer,*,*, XVisualInfo *,*,*
float,*,*, float,*,*
int,*,*, int,*,*
uint,*,*, unsigned int,*,*
int32_t,*,*, int32_t,*,*
int64_t,*,*, int64_t,*,*
long,*,*, long,*,*
ulong,*,*, unsigned long,*,*
void,*,*, void,*,*

View file

@ -0,0 +1,324 @@
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2005 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
#
# $Date: 2005/01/20 08:44:12 $ $Revision: 1.6 $
# $Header: /oss/CVS/cvs/projects/ogl-sample/main/doc/registry/specs/glxenum.spec,v 1.6 2005/01/20 08:44:12 ljp Exp $
# This is the GLX enumerant registry.
#
# It is an extremely important file. Do not mess with it unless
# you know what you're doing and have permission to do so.
#
# Rules for modification are the same as the rules for the OpenGL
# enumerant registry (gl.spec). Basically, don't modify this
# file unless you're SGI's ARB Representative.
Extensions define:
VERSION_1_1 = 1
VERSION_1_2 = 1
VERSION_1_3 = 1
VERSION_1_4 = 1
SGIS_multisample = 1
EXT_visual_info = 1
SGI_swap_control = 1
SGI_video_sync = 1
SGI_make_current_read = 1
SGIX_video_source = 1
EXT_visual_rating = 1
EXT_import_context = 1
SGIX_fbconfig = 1
SGIX_pbuffer = 1
SGI_cushion = 1
SGIX_video_resize = 1
SGIX_dmbuffer = 1
SGIX_swap_group = 1
SGIX_swap_barrier = 1
SGIS_blended_overlay = 1
SGIS_shared_multisample = 1
SUN_get_transparent_index = 1
3DFX_multisample = 1
MESA_copy_sub_buffer = 1
MESA_pixmap_colormap = 1
MESA_release_buffers = 1
MESA_set_3dfx_mode = 1
SGIX_visual_select_group = 1
SGIX_hyperpipe = 1
GLXStringName enum:
VENDOR = 0x1
VERSION = 0x2
EXTENSIONS = 0x3
GLXErrorCode enum:
BAD_SCREEN = 1
BAD_ATTRIBUTE = 2
NO_EXTENSION = 3
BAD_VISUAL = 4
BAD_CONTEXT = 5
BAD_VALUE = 6
BAD_ENUM = 7
BAD_HYPERPIPE_CONFIG_SGIX = 91 # SGIX_hyperpipe
BAD_HYPERPIPE_SGIX = 92 # "
GLXDrawableTypeMask enum:
WINDOW_BIT = 0x00000001 # DRAWABLE_TYPE value
PIXMAP_BIT = 0x00000002 # "
PBUFFER_BIT = 0x00000004 # "
WINDOW_BIT_SGIX = 0x00000001 # DRAWABLE_TYPE_SGIX value
PIXMAP_BIT_SGIX = 0x00000002 # "
PBUFFER_BIT_SGIX = 0x00000004 # "
GLXRenderTypeMask enum:
RGBA_BIT = 0x00000001 # RENDER_TYPE value
COLOR_INDEX_BIT = 0x00000002 # "
RGBA_BIT_SGIX = 0x00000001 # RENDER_TYPE_SGIX value
COLOR_INDEX_BIT_SGIX = 0x00000002 # "
RGBA_FLOAT_BIT_ARB = 0x00000004 # RENDER_TYPE value (from ARB_fbconfig_float)
GLXSyncType enum:
SYNC_FRAME_SGIX = 0x00000000 # ChannelRectSyncSGIX synctype
SYNC_SWAP_SGIX = 0x00000001 # "
GLXEventMask enum:
PBUFFER_CLOBBER_MASK = 0x08000000 # SelectEvent mask
BUFFER_CLOBBER_MASK_SGIX = 0x08000000 # SelectEventSGIX mask
GLXPbufferClobberMask enum:
FRONT_LEFT_BUFFER_BIT = 0x00000001 # PbufferClobberEvent mask
FRONT_RIGHT_BUFFER_BIT = 0x00000002 # "
BACK_LEFT_BUFFER_BIT = 0x00000004 # "
BACK_RIGHT_BUFFER_BIT = 0x00000008 # "
AUX_BUFFERS_BIT = 0x00000010 # "
DEPTH_BUFFER_BIT = 0x00000020 # "
STENCIL_BUFFER_BIT = 0x00000040 # "
ACCUM_BUFFER_BIT = 0x00000080 # "
FRONT_LEFT_BUFFER_BIT_SGIX = 0x00000001 # BufferClobberEventSGIX mask
FRONT_RIGHT_BUFFER_BIT_SGIX = 0x00000002 # "
BACK_LEFT_BUFFER_BIT_SGIX = 0x00000004 # "
BACK_RIGHT_BUFFER_BIT_SGIX = 0x00000008 # "
AUX_BUFFERS_BIT_SGIX = 0x00000010 # "
DEPTH_BUFFER_BIT_SGIX = 0x00000020 # "
STENCIL_BUFFER_BIT_SGIX = 0x00000040 # "
ACCUM_BUFFER_BIT_SGIX = 0x00000080 # "
SAMPLE_BUFFERS_BIT_SGIX = 0x00000100 # "
GLXHyperpipeTypeMask enum:
HYPERPIPE_DISPLAY_PIPE_SGIX = 0x00000001 # SGIX_hyperpipe
HYPERPIPE_RENDER_PIPE_SGIX = 0x00000002 # "
GLXHyperpipeAttrib enum:
PIPE_RECT_SGIX = 0x00000001 # SGIX_hyperpipe
PIPE_RECT_LIMITS_SGIX = 0x00000002 # "
HYPERPIPE_STEREO_SGIX = 0x00000003 # "
HYPERPIPE_PIXEL_AVERAGE_SGIX = 0x00000004 # "
GLXHyperpipeMisc enum:
HYPERPIPE_PIPE_NAME_LENGTH_SGIX = 80 # SGIX_hyperpipe
GLXAttribute enum:
USE_GL = 1 # Visual attributes
BUFFER_SIZE = 2 # "
LEVEL = 3 # "
RGBA = 4 # "
DOUBLEBUFFER = 5 # "
STEREO = 6 # "
AUX_BUFFERS = 7 # "
RED_SIZE = 8 # "
GREEN_SIZE = 9 # "
BLUE_SIZE = 10 # "
ALPHA_SIZE = 11 # "
DEPTH_SIZE = 12 # "
STENCIL_SIZE = 13 # "
ACCUM_RED_SIZE = 14 # "
ACCUM_GREEN_SIZE = 15 # "
ACCUM_BLUE_SIZE = 16 # "
ACCUM_ALPHA_SIZE = 17 # "
CONFIG_CAVEAT = 0x20 # "
X_VISUAL_TYPE = 0x22 # "
TRANSPARENT_TYPE = 0x23 # "
TRANSPARENT_INDEX_VALUE = 0x24 # "
TRANSPARENT_RED_VALUE = 0x25 # "
TRANSPARENT_GREEN_VALUE = 0x26 # "
TRANSPARENT_BLUE_VALUE = 0x27 # "
TRANSPARENT_ALPHA_VALUE = 0x28 # "
DONT_CARE = 0xFFFFFFFF # may be specified for ChooseFBConfig attributes
NONE = 0x8000 # several attribute values
SLOW_CONFIG = 0x8001 # CONFIG_CAVEAT attribute value
TRUE_COLOR = 0x8002 # X_VISUAL_TYPE attribute value
DIRECT_COLOR = 0x8003 # "
PSEUDO_COLOR = 0x8004 # "
STATIC_COLOR = 0x8005 # "
GRAY_SCALE = 0x8006 # "
STATIC_GRAY = 0x8007 # "
TRANSPARENT_RGB = 0x8008 # TRANSPARENT_TYPE attribute value
TRANSPARENT_INDEX = 0x8009 # "
VISUAL_ID = 0x800B # Context attribute
SCREEN = 0x800C # "
NON_CONFORMANT_CONFIG = 0x800D # CONFIG_CAVEAT attribute value
DRAWABLE_TYPE = 0x8010 # FBConfig attribute
RENDER_TYPE = 0x8011 # "
X_RENDERABLE = 0x8012 # "
FBCONFIG_ID = 0x8013 # "
RGBA_TYPE = 0x8014 # CreateNewContext render_type value
COLOR_INDEX_TYPE = 0x8015 # "
MAX_PBUFFER_WIDTH = 0x8016 # FBConfig attribute
MAX_PBUFFER_HEIGHT = 0x8017 # "
MAX_PBUFFER_PIXELS = 0x8018 # "
PRESERVED_CONTENTS = 0x801B # CreateGLXPbuffer attribute
LARGEST_PBUFFER = 0x801C # "
WIDTH = 0x801D # Drawable attribute
HEIGHT = 0x801E # "
EVENT_MASK = 0x801F # "
DAMAGED = 0x8020 # PbufferClobber event_type value
SAVED = 0x8021 # "
WINDOW = 0x8022 # PbufferClobber draw_type value
PBUFFER = 0x8023 # "
PBUFFER_HEIGHT = 0x8040 # CreateGLXPbuffer attribute
PBUFFER_WIDTH = 0x8041 # "
VISUAL_CAVEAT_EXT = 0x20 # Visual attribute
X_VISUAL_TYPE_EXT = 0x22 # "
TRANSPARENT_TYPE_EXT = 0x23 # "
TRANSPARENT_INDEX_VALUE_EXT = 0x24 # "
TRANSPARENT_RED_VALUE_EXT = 0x25 # "
TRANSPARENT_GREEN_VALUE_EXT = 0x26 # "
TRANSPARENT_BLUE_VALUE_EXT = 0x27 # "
TRANSPARENT_ALPHA_VALUE_EXT = 0x28 # "
NONE_EXT = 0x8000 # several EXT attribute values
SLOW_VISUAL_EXT = 0x8001 # VISUAL_CAVEAT_EXT attribute value
TRUE_COLOR_EXT = 0x8002 # X_VISUAL_TYPE_EXT attribute value
DIRECT_COLOR_EXT = 0x8003 # "
PSEUDO_COLOR_EXT = 0x8004 # "
STATIC_COLOR_EXT = 0x8005 # "
GRAY_SCALE_EXT = 0x8006 # "
STATIC_GRAY_EXT = 0x8007 # "
TRANSPARENT_RGB_EXT = 0x8008 # TRANSPARENT_TYPE_EXT attribute value
TRANSPARENT_INDEX_EXT = 0x8009 # "
SHARE_CONTEXT_EXT = 0x800A # QueryContextInfoEXT attribute
VISUAL_ID_EXT = 0x800B # "
SCREEN_EXT = 0x800C # "
NON_CONFORMANT_VISUAL_EXT = 0x800D # VISUAL_CAVEAT_EXT attribute value
DRAWABLE_TYPE_SGIX = 0x8010 # FBConfigSGIX attribute
RENDER_TYPE_SGIX = 0x8011 # "
X_RENDERABLE_SGIX = 0x8012 # "
FBCONFIG_ID_SGIX = 0x8013 # "
RGBA_TYPE_SGIX = 0x8014 # CreateContextWithConfigSGIX render_type value
COLOR_INDEX_TYPE_SGIX = 0x8015 # "
MAX_PBUFFER_WIDTH_SGIX = 0x8016 # FBConfigSGIX attribute
MAX_PBUFFER_HEIGHT_SGIX = 0x8017 # "
MAX_PBUFFER_PIXELS_SGIX = 0x8018 # "
OPTIMAL_PBUFFER_WIDTH_SGIX = 0x8019 # "
OPTIMAL_PBUFFER_HEIGHT_SGIX = 0x801A # "
PRESERVED_CONTENTS_SGIX = 0x801B # PbufferSGIX attribute
LARGEST_PBUFFER_SGIX = 0x801C # "
WIDTH_SGIX = 0x801D # "
HEIGHT_SGIX = 0x801E # "
EVENT_MASK_SGIX = 0x801F # "
DAMAGED_SGIX = 0x8020 # BufferClobberSGIX event_type value
SAVED_SGIX = 0x8021 # "
WINDOW_SGIX = 0x8022 # BufferClobberSGIX draw_type value
PBUFFER_SGIX = 0x8023 # "
DIGITAL_MEDIA_PBUFFER_SGIX = 0x8024 # PbufferSGIX attribute
BLENDED_RGBA_SGIS = 0x8025 # TRANSPARENT_TYPE_EXT attribute value
MULTISAMPLE_SUB_RECT_WIDTH_SGIS = 0x8026 # Visual attribute (shared_multisample)
MULTISAMPLE_SUB_RECT_HEIGHT_SGIS = 0x8027 # "
VISUAL_SELECT_GROUP_SGIX = 0x8028 # Visual attribute (visual_select_group)
HYPERPIPE_ID_SGIX = 0x8030 # Associated hyperpipe ID (SGIX_hyperpipe)
SAMPLE_BUFFERS_SGIS = 100000 # Visual attribute (SGIS_multisample)
SAMPLES_SGIS = 100001 # "
SAMPLE_BUFFERS_ARB = 100000 # Visual attribute (ARB_multisample - alias of SGIS_multisample)
SAMPLES_ARB = 100001 # "
SAMPLE_BUFFERS = 100000 # Visual attribute (GLX 1.4 core - alias of SGIS_multisample)
SAMPLES = 100001 # "
###############################################################################
# NVIDIA: 0x20A0 - 0x219F
# NV_float_buffer enum:
FLOAT_COMPONENTS_NV = 0x20B0
# NV_future_use: 0x20B1-0x20B8
# ARB_fbconfig_float enum:
RGBA_FLOAT_TYPE_ARB = 0x20B9
# NV_future_use: 0x20BA-0x219F
###############################################################################
# MESA (not in a reserved block)
# MESA_set_3dfx_mode enum:
# 3DFX_WINDOW_MODE_MESA = 0x1
# 3DFX_FULLSCREEN_MODE_MESA = 0x2
###############################################################################
# SGI_future_use: 0x8029-0x802F
# SGIX_hyperpipe adds attribute name HYPERPIPE_ID_SGIX = 0x8030
# SGI_future_use: 0x8031-0x803F
###############################################################################
# ARB_future_use: 0x8042-0x804F
###############################################################################
# 3DFX: 0x8050-0x805F
# 3DFX_multisample enum:
# SAMPLE_BUFFERS_3DFX = 0x8050
# SAMPLES_3DFX = 0x8051
###############################################################################
# OML: 0x8060-0x806F
# OML_swap_method enum:
# SWAP_METHOD_OML = 0x8060
# SWAP_EXCHANGE_OML = 0x8061
# SWAP_COPY_OML = 0x8062
# SWAP_UNDEFINED_OML = 0x8063
# OML_future_use: 0x8064-0x806F
###############################################################################
# NVIDIA: 0x8070 - 0x816F
###############################################################################
# SUN: 0x8170 - 0x817F
###############################################################################
### PLEASE REMEMBER THAT NEW ENUMERANT ALLOCATIONS MUST BE OBTAINED BY
### REQUEST TO SGI'S ARB REPRESENTATIVE (see comments at the top of this file)
###############################################################################
# Any_vendor_future_use: 0x8180-0xFFFF
#
# This range must be the last range in the file. To generate a new
# range, allocate multiples of 16 from the beginning of the
# Any_vendor_future_use range and update glxenum.spec, glxenumext.spec,
# and extensions.reserved.

View file

@ -0,0 +1,412 @@
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2005 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
#
# $Date: 2005/01/20 08:44:12 $ $Revision: 1.6 $
# $Header: /oss/CVS/cvs/projects/ogl-sample/main/doc/registry/specs/glxenumext.spec,v 1.6 2005/01/20 08:44:12 ljp Exp $
# List of GLX enumerants for glxext.h header
#
# This is NOT the master GLX enumerant registry (glxenum.spec).
#
# Unlike glxenum.spec, glxenumext.spec is
# (1) In order by extension number.
# (2) Includes only GLX extensions and GLX 1.3/1.4 core enumerants,
# since it's assumed all <glx.h> today support at least GLX 1.2.
# (3) Has no 'Extensions' section, since enums are always
# conditionally protected against multiple definition
# by glextenum.pl.
# (4) Is processed by glextenum.pl, which has evolved
# from enum.pl - should merge back into one script.
# glxext.h version number - this should be automatically updated,
# when changing either enum or template spec files.
passthru:
passthru: /* Header file version number, required by OpenGL ABI for Linux */
passthru: /* glxext.h last updated 2005/01/20 */
passthru: /* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */
passthru: #define GLX_GLXEXT_VERSION 10
###############################################################################
#
# GLX 1.3 enums
#
###############################################################################
VERSION_1_3 enum:
WINDOW_BIT = 0x00000001 # DRAWABLE_TYPE value
PIXMAP_BIT = 0x00000002 # "
PBUFFER_BIT = 0x00000004 # "
RGBA_BIT = 0x00000001 # RENDER_TYPE value
COLOR_INDEX_BIT = 0x00000002 # "
PBUFFER_CLOBBER_MASK = 0x08000000 # SelectEvent mask
FRONT_LEFT_BUFFER_BIT = 0x00000001 # PbufferClobberEvent mask
FRONT_RIGHT_BUFFER_BIT = 0x00000002 # "
BACK_LEFT_BUFFER_BIT = 0x00000004 # "
BACK_RIGHT_BUFFER_BIT = 0x00000008 # "
AUX_BUFFERS_BIT = 0x00000010 # "
DEPTH_BUFFER_BIT = 0x00000020 # "
STENCIL_BUFFER_BIT = 0x00000040 # "
ACCUM_BUFFER_BIT = 0x00000080 # "
CONFIG_CAVEAT = 0x20 # "
X_VISUAL_TYPE = 0x22 # "
TRANSPARENT_TYPE = 0x23 # "
TRANSPARENT_INDEX_VALUE = 0x24 # "
TRANSPARENT_RED_VALUE = 0x25 # "
TRANSPARENT_GREEN_VALUE = 0x26 # "
TRANSPARENT_BLUE_VALUE = 0x27 # "
TRANSPARENT_ALPHA_VALUE = 0x28 # "
DONT_CARE = 0xFFFFFFFF # may be specified for ChooseFBConfig attributes
NONE = 0x8000 # several attribute values
SLOW_CONFIG = 0x8001 # CONFIG_CAVEAT attribute value
TRUE_COLOR = 0x8002 # X_VISUAL_TYPE attribute value
DIRECT_COLOR = 0x8003 # "
PSEUDO_COLOR = 0x8004 # "
STATIC_COLOR = 0x8005 # "
GRAY_SCALE = 0x8006 # "
STATIC_GRAY = 0x8007 # "
TRANSPARENT_RGB = 0x8008 # TRANSPARENT_TYPE attribute value
TRANSPARENT_INDEX = 0x8009 # "
VISUAL_ID = 0x800B # Context attribute
SCREEN = 0x800C # "
NON_CONFORMANT_CONFIG = 0x800D # CONFIG_CAVEAT attribute value
DRAWABLE_TYPE = 0x8010 # FBConfig attribute
RENDER_TYPE = 0x8011 # "
X_RENDERABLE = 0x8012 # "
FBCONFIG_ID = 0x8013 # "
RGBA_TYPE = 0x8014 # CreateNewContext render_type value
COLOR_INDEX_TYPE = 0x8015 # "
MAX_PBUFFER_WIDTH = 0x8016 # FBConfig attribute
MAX_PBUFFER_HEIGHT = 0x8017 # "
MAX_PBUFFER_PIXELS = 0x8018 # "
PRESERVED_CONTENTS = 0x801B # CreateGLXPbuffer attribute
LARGEST_PBUFFER = 0x801C # "
WIDTH = 0x801D # Drawable attribute
HEIGHT = 0x801E # "
EVENT_MASK = 0x801F # "
DAMAGED = 0x8020 # PbufferClobber event_type value
SAVED = 0x8021 # "
WINDOW = 0x8022 # PbufferClobber draw_type value
PBUFFER = 0x8023 # "
PBUFFER_HEIGHT = 0x8040 # CreateGLXPbuffer attribute
PBUFFER_WIDTH = 0x8041 # "
###############################################################################
#
# GLX 1.4 enums
#
###############################################################################
VERSION_1_4 enum:
SAMPLE_BUFFERS = 100000
SAMPLES = 100001
###############################################################################
#
# ARB GLX extensions, in ARB extension order
#
###############################################################################
###############################################################################
# No new tokens
# ARB Extension #2
ARB_get_proc_address enum:
###############################################################################
# ARB Extension #5
ARB_multisample enum:
SAMPLE_BUFFERS_ARB = 100000
SAMPLES_ARB = 100001
###############################################################################
# ARB Extension #39
ARB_fbconfig_float enum:
RGBA_FLOAT_TYPE_ARB = 0x20B9
RGBA_FLOAT_BIT_ARB = 0x00000004
###############################################################################
#
# non-ARB GLX extensions, in registry order
#
###############################################################################
###############################################################################
# Unfortunately, the SGIS_multisample specification and the IRIX
# implementation are inconsistent; the spec assigns enums as follows.
# ARB_multisample reuses these enums with ARB suffixes, and it can't
# be changed at this point. So in the interest of supporting both
# extensions on non-IRIX platforms, the SGIS enums will be defined
# here as originally specified.
# Extension #25
SGIS_multisample enum:
SAMPLE_BUFFERS_SGIS = 100000
SAMPLES_SGIS = 100001
###############################################################################
# Extension #28
EXT_visual_info enum:
X_VISUAL_TYPE_EXT = 0x22
TRANSPARENT_TYPE_EXT = 0x23
TRANSPARENT_INDEX_VALUE_EXT = 0x24
TRANSPARENT_RED_VALUE_EXT = 0x25
TRANSPARENT_GREEN_VALUE_EXT = 0x26
TRANSPARENT_BLUE_VALUE_EXT = 0x27
TRANSPARENT_ALPHA_VALUE_EXT = 0x28
NONE_EXT = 0x8000
TRUE_COLOR_EXT = 0x8002
DIRECT_COLOR_EXT = 0x8003
PSEUDO_COLOR_EXT = 0x8004
STATIC_COLOR_EXT = 0x8005
GRAY_SCALE_EXT = 0x8006
STATIC_GRAY_EXT = 0x8007
TRANSPARENT_RGB_EXT = 0x8008
TRANSPARENT_INDEX_EXT = 0x8009
###############################################################################
# No new tokens
# Extension #40
SGI_swap_control enum:
###############################################################################
# No new tokens
# Extension #41
SGI_video_sync enum:
###############################################################################
# No new tokens
# Extension #42
SGI_make_current_read enum:
###############################################################################
# No new tokens
# Extension #43
SGIX_video_source enum:
###############################################################################
# Extension #44
EXT_visual_rating enum:
VISUAL_CAVEAT_EXT = 0x20
SLOW_VISUAL_EXT = 0x8001
NON_CONFORMANT_VISUAL_EXT = 0x800D
use EXT_visual_info NONE_EXT
###############################################################################
# Extension #47
EXT_import_context enum:
SHARE_CONTEXT_EXT = 0x800A
VISUAL_ID_EXT = 0x800B
SCREEN_EXT = 0x800C
###############################################################################
# Extension #49
SGIX_fbconfig enum:
WINDOW_BIT_SGIX = 0x00000001
PIXMAP_BIT_SGIX = 0x00000002
RGBA_BIT_SGIX = 0x00000001
COLOR_INDEX_BIT_SGIX = 0x00000002
DRAWABLE_TYPE_SGIX = 0x8010
RENDER_TYPE_SGIX = 0x8011
X_RENDERABLE_SGIX = 0x8012
FBCONFIG_ID_SGIX = 0x8013
RGBA_TYPE_SGIX = 0x8014
COLOR_INDEX_TYPE_SGIX = 0x8015
use EXT_import_context SCREEN_EXT
###############################################################################
# Extension #50
SGIX_pbuffer enum:
PBUFFER_BIT_SGIX = 0x00000004
BUFFER_CLOBBER_MASK_SGIX = 0x08000000
FRONT_LEFT_BUFFER_BIT_SGIX = 0x00000001
FRONT_RIGHT_BUFFER_BIT_SGIX = 0x00000002
BACK_LEFT_BUFFER_BIT_SGIX = 0x00000004
BACK_RIGHT_BUFFER_BIT_SGIX = 0x00000008
AUX_BUFFERS_BIT_SGIX = 0x00000010
DEPTH_BUFFER_BIT_SGIX = 0x00000020
STENCIL_BUFFER_BIT_SGIX = 0x00000040
ACCUM_BUFFER_BIT_SGIX = 0x00000080
SAMPLE_BUFFERS_BIT_SGIX = 0x00000100
MAX_PBUFFER_WIDTH_SGIX = 0x8016
MAX_PBUFFER_HEIGHT_SGIX = 0x8017
MAX_PBUFFER_PIXELS_SGIX = 0x8018
OPTIMAL_PBUFFER_WIDTH_SGIX = 0x8019
OPTIMAL_PBUFFER_HEIGHT_SGIX = 0x801A
PRESERVED_CONTENTS_SGIX = 0x801B
LARGEST_PBUFFER_SGIX = 0x801C
WIDTH_SGIX = 0x801D
HEIGHT_SGIX = 0x801E
EVENT_MASK_SGIX = 0x801F
DAMAGED_SGIX = 0x8020
SAVED_SGIX = 0x8021
WINDOW_SGIX = 0x8022
PBUFFER_SGIX = 0x8023
###############################################################################
# Extension #62
SGI_cushion enum:
# CUSHION_BUFFERS_SGI ????
###############################################################################
# Extension #83
SGIX_video_resize enum:
SYNC_FRAME_SGIX = 0x00000000
SYNC_SWAP_SGIX = 0x00000001
###############################################################################
# Extension #86
SGIX_dmbuffer enum:
DIGITAL_MEDIA_PBUFFER_SGIX = 0x8024
###############################################################################
# No new tokens
# Extension #91
SGIX_swap_group enum:
###############################################################################
# No new tokens
# Extension #92
SGIX_swap_barrier enum:
###############################################################################
# Extension #142
SGIS_blended_overlay enum:
BLENDED_RGBA_SGIS = 0x8025
###############################################################################
# Extension #143
SGIS_shared_multisample enum:
MULTISAMPLE_SUB_RECT_WIDTH_SGIS = 0x8026
MULTISAMPLE_SUB_RECT_HEIGHT_SGIS = 0x8027
###############################################################################
# No new tokens
# Extension #183
SUN_get_transparent_index enum:
###############################################################################
# Extension #207
3DFX_multisample enum:
SAMPLE_BUFFERS_3DFX = 0x8050
SAMPLES_3DFX = 0x8051
###############################################################################
# No new tokens
# Extension #215
MESA_copy_sub_buffer enum:
###############################################################################
# No new tokens
# Extension #216
MESA_pixmap_colormap enum:
###############################################################################
# No new tokens
# Extension #217
MESA_release_buffers enum:
###############################################################################
# Extension #218
MESA_set_3dfx_mode enum:
3DFX_WINDOW_MODE_MESA = 0x1
3DFX_FULLSCREEN_MODE_MESA = 0x2
###############################################################################
# Extension #234
SGIX_visual_select_group enum:
VISUAL_SELECT_GROUP_SGIX = 0x8028
###############################################################################
# Extension #237
OML_swap_method enum:
SWAP_METHOD_OML = 0x8060
SWAP_EXCHANGE_OML = 0x8061
SWAP_COPY_OML = 0x8062
SWAP_UNDEFINED_OML = 0x8063
###############################################################################
# No new tokens
# Extension #238
OML_sync_control enum:
###############################################################################
# Extension #281
NV_float_buffer enum:
FLOAT_COMPONENTS_NV = 0x20B0
###############################################################################
# Extension #307
SGIX_hyperpipe enum:
HYPERPIPE_PIPE_NAME_LENGTH_SGIX = 80
BAD_HYPERPIPE_CONFIG_SGIX = 91
BAD_HYPERPIPE_SGIX = 92
HYPERPIPE_DISPLAY_PIPE_SGIX = 0x00000001
HYPERPIPE_RENDER_PIPE_SGIX = 0x00000002
PIPE_RECT_SGIX = 0x00000001
PIPE_RECT_LIMITS_SGIX = 0x00000002
HYPERPIPE_STEREO_SGIX = 0x00000003
HYPERPIPE_PIXEL_AVERAGE_SGIX = 0x00000004
HYPERPIPE_ID_SGIX = 0x8030
###############################################################################
# No new tokens
# Extension #308
MESA_agp_offset enum:

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,187 @@
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2002 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
required-props:
param: retval retained
dlflags: notlistable handcode nop
wglflags: client-handcode server-handcode non-dispatch
vectorequiv: *
category: wgl
CreateContext( hDc )
return HGLRC
param hDc HDC in value
category wgl
dlflags notlistable handcode
wglflags non-dispatch
DeleteContext( oldContext )
return BOOL
param oldContext HGLRC in value
category wgl
dlflags notlistable handcode
wglflags non-dispatch
GetCurrentContext( )
return HGLRC
category wgl
dlflags notlistable handcode
wglflags non-dispatch
MakeCurrent( hDc, newContext )
return BOOL
param hDc HDC in value
param newContext HGLRC in value
category wgl
dlflags notlistable
wglflags non-dispatch
CopyContext( hglrcSrc, hglrcDst, mask )
return BOOL
param hglrcSrc HGLRC in value
param hglrcDst HGLRC in value
param mask UINT in value
category wgl
dlflags notlistable
wglflags non-dispatch
ChoosePixelFormat( hDc, pPfd )
return int
param hDc HDC in value
param pPfd PIXELFORMATDESCRIPTOR in reference
category wgl
dlflags notlistable
wglflags non-dispatch
DescribePixelFormat( hdc, ipfd, cjpfd, ppfd )
return int
param hdc HDC in value
param ipfd int in value
param cjpfd UINT in value
param ppfd PIXELFORMATDESCRIPTOR in reference
GetCurrentDC( )
return HDC
category wgl
GetDefaultProcAddress( lpszProc)
return PROC
param lpszProc LPCSTR in value
category wgl
GetProcAddress( lpszProc)
return PROC
param lpszProc LPCSTR in value
category wgl
GetPixelFormat( hdc )
return int
param hdc HDC in value
category wgl
SetPixelFormat( hdc, ipfd, ppfd )
return BOOL
param hdc HDC in value
param ipfd int in value
param ppfd PIXELFORMATDESCRIPTOR in reference
category wgl
SwapBuffers( hdc )
return BOOL
param hdc HDC in value
category wgl
ShareLists( hrcSrvShare, hrcSrvSource)
return BOOL
param hrcSrvShare HGLRC in value
param hrcSrvSource HGLRC in value
category wgl
CreateLayerContext( hDc, level )
return HGLRC
param hDc HDC in value
param level int in value
category wgl
DescribeLayerPlane( hDc, pixelFormat, layerPlane, nBytes, plpd )
return BOOL
param hDc HDC in value
param pixelFormat int in value
param layerPlane int in value
param nBytes UINT in value
param plpd LAYERPLANEDESCRIPTOR in reference
category wgl
SetLayerPaletteEntries( hdc, iLayerPlane, iStart, cEntries, pcr )
return int
param hdc HDC in value
param iLayerPlane int in value
param iStart int in value
param cEntries int in value
param pcr COLORREF in reference
category wgl
GetLayerPaletteEntries( hdc, iLayerPlane, iStart, cEntries, pcr )
return int
param hdc HDC in value
param iLayerPlane int in value
param iStart int in value
param cEntries int in value
param pcr COLORREF in reference
category wgl
RealizeLayerPalette( hdc, iLayerPlane, bRealize )
return BOOL
param hdc HDC in value
param iLayerPlane int in value
param bRealize BOOL in value
category wgl
SwapLayerBuffers( hdc, fuFlags )
return BOOL
param hdc HDC in value
param fuFlags UINT in value
category wgl
UseFontBitmapsA( hDC, first, count, listBase )
return BOOL
param hDC HDC in value
param first DWORD in value
param count DWORD in value
param listBase DWORD in value
category wgl
dlflags notlistable
UseFontBitmapsW( hDC, first, count, listBase )
return BOOL
param hDC HDC in value
param first DWORD in value
param count DWORD in value
param listBase DWORD in value
category wgl
dlflags notlistable

View file

@ -0,0 +1,24 @@
BOOL,*,*, BOOL,*,*
DWORD,*,*, DWORD,*,*
FLOAT,*,*, FLOAT,*,*
GLboolean,*,*, GLboolean,*,*
GLfloat,*,*, GLfloat,*,*
GLsizei,*,*, GLsizei,*,*
GLuint,*,*, GLuint,*,*
GLushort,*,*, GLushort,*,*
HANDLE,*,*, HANDLE,*,*
HDC,*,*, HDC,*,*
HGLRC,*,*, HGLRC,*,*
HPBUFFERARB,*,*, HPBUFFERARB,*,*
HPBUFFEREXT,*,*, HPBUFFEREXT,*,*
INT32,*,*, INT32,*,*
INT64,*,*, INT64,*,*
LPVOID,*,*, LPVOID,*,*
String,*,*, const char *,*,*
UINT,*,*, UINT,*,*
USHORT,*,*, USHORT,*,*
VOID,*,*, VOID,*,*
VoidPointer,*,*, void*,*,*
float,*,*, float,*,*
int,*,*, int,*,*
void,*,*, *,*,*

View file

@ -0,0 +1,359 @@
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2005 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
#
# $Date: 2005/01/20 08:44:12 $ $Revision: 1.6 $
# $Header: /oss/CVS/cvs/projects/ogl-sample/main/doc/registry/specs/wglenum.spec,v 1.6 2005/01/20 08:44:12 ljp Exp $
# This is the master WGL enumerant registry.
#
# It is an extremely important file. Do not mess with it unless
# you know what you're doing and have permission to do so.
#
# Rules for modification are similar to the rules for the OpenGL
# enumerant registry (gl.spec). Basically, don't modify this file
# unless you're SGI's ARB Representative. In principle Microsoft
# owns the WGL registry, but they have for practical purposes
# ceded administration of it to SGI.
#
# Finally, note that this registry does not currently include
# any core WGL enumerants - only enumerants defined by WGL
# extensions.
###############################################################################
# Bitmasks - not consumed by the registry
WGL_ARB_buffer_region enum:
WGL_FRONT_COLOR_BUFFER_BIT_ARB = 0x00000001
WGL_BACK_COLOR_BUFFER_BIT_ARB = 0x00000002
WGL_DEPTH_BUFFER_BIT_ARB = 0x00000004
WGL_STENCIL_BUFFER_BIT_ARB = 0x00000008
###############################################################################
# SGI: 0x2000-0x203F
WGL_EXT_pixel_format enum:
WGL_NUMBER_PIXEL_FORMATS_EXT = 0x2000
WGL_DRAW_TO_WINDOW_EXT = 0x2001
WGL_DRAW_TO_BITMAP_EXT = 0x2002
WGL_ACCELERATION_EXT = 0x2003
WGL_NEED_PALETTE_EXT = 0x2004
WGL_NEED_SYSTEM_PALETTE_EXT = 0x2005
WGL_SWAP_LAYER_BUFFERS_EXT = 0x2006
WGL_SWAP_METHOD_EXT = 0x2007
WGL_NUMBER_OVERLAYS_EXT = 0x2008
WGL_NUMBER_UNDERLAYS_EXT = 0x2009
WGL_TRANSPARENT_EXT = 0x200A
WGL_TRANSPARENT_VALUE_EXT = 0x200B
WGL_SHARE_DEPTH_EXT = 0x200C
WGL_SHARE_STENCIL_EXT = 0x200D
WGL_SHARE_ACCUM_EXT = 0x200E
WGL_SUPPORT_GDI_EXT = 0x200F
WGL_SUPPORT_OPENGL_EXT = 0x2010
WGL_DOUBLE_BUFFER_EXT = 0x2011
WGL_STEREO_EXT = 0x2012
WGL_PIXEL_TYPE_EXT = 0x2013
WGL_COLOR_BITS_EXT = 0x2014
WGL_RED_BITS_EXT = 0x2015
WGL_RED_SHIFT_EXT = 0x2016
WGL_GREEN_BITS_EXT = 0x2017
WGL_GREEN_SHIFT_EXT = 0x2018
WGL_BLUE_BITS_EXT = 0x2019
WGL_BLUE_SHIFT_EXT = 0x201A
WGL_ALPHA_BITS_EXT = 0x201B
WGL_ALPHA_SHIFT_EXT = 0x201C
WGL_ACCUM_BITS_EXT = 0x201D
WGL_ACCUM_RED_BITS_EXT = 0x201E
WGL_ACCUM_GREEN_BITS_EXT = 0x201F
WGL_ACCUM_BLUE_BITS_EXT = 0x2020
WGL_ACCUM_ALPHA_BITS_EXT = 0x2021
WGL_DEPTH_BITS_EXT = 0x2022
WGL_STENCIL_BITS_EXT = 0x2023
WGL_AUX_BUFFERS_EXT = 0x2024
WGL_NO_ACCELERATION_EXT = 0x2025
WGL_GENERIC_ACCELERATION_EXT = 0x2026
WGL_FULL_ACCELERATION_EXT = 0x2027
WGL_SWAP_EXCHANGE_EXT = 0x2028
WGL_SWAP_COPY_EXT = 0x2029
WGL_SWAP_UNDEFINED_EXT = 0x202A
WGL_TYPE_RGBA_EXT = 0x202B
WGL_TYPE_COLORINDEX_EXT = 0x202C
WGL_ARB_pixel_format enum:
WGL_NUMBER_PIXEL_FORMATS_ARB = 0x2000
WGL_DRAW_TO_WINDOW_ARB = 0x2001
WGL_DRAW_TO_BITMAP_ARB = 0x2002
WGL_ACCELERATION_ARB = 0x2003
WGL_NEED_PALETTE_ARB = 0x2004
WGL_NEED_SYSTEM_PALETTE_ARB = 0x2005
WGL_SWAP_LAYER_BUFFERS_ARB = 0x2006
WGL_SWAP_METHOD_ARB = 0x2007
WGL_NUMBER_OVERLAYS_ARB = 0x2008
WGL_NUMBER_UNDERLAYS_ARB = 0x2009
WGL_TRANSPARENT_ARB = 0x200A
WGL_SHARE_DEPTH_ARB = 0x200C
WGL_SHARE_STENCIL_ARB = 0x200D
WGL_SHARE_ACCUM_ARB = 0x200E
WGL_SUPPORT_GDI_ARB = 0x200F
WGL_SUPPORT_OPENGL_ARB = 0x2010
WGL_DOUBLE_BUFFER_ARB = 0x2011
WGL_STEREO_ARB = 0x2012
WGL_PIXEL_TYPE_ARB = 0x2013
WGL_COLOR_BITS_ARB = 0x2014
WGL_RED_BITS_ARB = 0x2015
WGL_RED_SHIFT_ARB = 0x2016
WGL_GREEN_BITS_ARB = 0x2017
WGL_GREEN_SHIFT_ARB = 0x2018
WGL_BLUE_BITS_ARB = 0x2019
WGL_BLUE_SHIFT_ARB = 0x201A
WGL_ALPHA_BITS_ARB = 0x201B
WGL_ALPHA_SHIFT_ARB = 0x201C
WGL_ACCUM_BITS_ARB = 0x201D
WGL_ACCUM_RED_BITS_ARB = 0x201E
WGL_ACCUM_GREEN_BITS_ARB = 0x201F
WGL_ACCUM_BLUE_BITS_ARB = 0x2020
WGL_ACCUM_ALPHA_BITS_ARB = 0x2021
WGL_DEPTH_BITS_ARB = 0x2022
WGL_STENCIL_BITS_ARB = 0x2023
WGL_AUX_BUFFERS_ARB = 0x2024
WGL_NO_ACCELERATION_ARB = 0x2025
WGL_GENERIC_ACCELERATION_ARB = 0x2026
WGL_FULL_ACCELERATION_ARB = 0x2027
WGL_SWAP_EXCHANGE_ARB = 0x2028
WGL_SWAP_COPY_ARB = 0x2029
WGL_SWAP_UNDEFINED_ARB = 0x202A
WGL_TYPE_RGBA_ARB = 0x202B
WGL_TYPE_COLORINDEX_ARB = 0x202C
WGL_DRAW_TO_PBUFFER_ARB = 0x202D
WGL_MAX_PBUFFER_PIXELS_ARB = 0x202E
WGL_MAX_PBUFFER_WIDTH_ARB = 0x202F
WGL_MAX_PBUFFER_HEIGHT_ARB = 0x2030
WGL_PBUFFER_LARGEST_ARB = 0x2033
WGL_PBUFFER_WIDTH_ARB = 0x2034
WGL_PBUFFER_HEIGHT_ARB = 0x2035
WGL_TRANSPARENT_RED_VALUE_ARB = 0x2037
WGL_TRANSPARENT_GREEN_VALUE_ARB = 0x2038
WGL_TRANSPARENT_BLUE_VALUE_ARB = 0x2039
WGL_TRANSPARENT_ALPHA_VALUE_ARB = 0x203A
WGL_TRANSPARENT_INDEX_VALUE_ARB = 0x203B
###############################################################################
WGL_EXT_pbuffer enum:
WGL_DRAW_TO_PBUFFER_EXT = 0x202D
WGL_MAX_PBUFFER_PIXELS_EXT = 0x202E
WGL_MAX_PBUFFER_WIDTH_EXT = 0x202F
WGL_MAX_PBUFFER_HEIGHT_EXT = 0x2030
WGL_OPTIMAL_PBUFFER_WIDTH_EXT = 0x2031
WGL_OPTIMAL_PBUFFER_HEIGHT_EXT = 0x2032
WGL_PBUFFER_LARGEST_EXT = 0x2033
WGL_PBUFFER_WIDTH_EXT = 0x2034
WGL_PBUFFER_HEIGHT_EXT = 0x2035
WGL_ARB_pbuffer enum:
WGL_DRAW_TO_PBUFFER_ARB = 0x202D
WGL_MAX_PBUFFER_PIXELS_ARB = 0x202E
WGL_MAX_PBUFFER_WIDTH_ARB = 0x202F
WGL_MAX_PBUFFER_HEIGHT_ARB = 0x2030
WGL_PBUFFER_LARGEST_ARB = 0x2033
WGL_PBUFFER_WIDTH_ARB = 0x2034
WGL_PBUFFER_HEIGHT_ARB = 0x2035
WGL_PBUFFER_LOST_ARB = 0x2036
use WGL_ARB_pixel_format WGL_TRANSPARENT_RED_VALUE_ARB
use WGL_ARB_pixel_format WGL_TRANSPARENT_GREEN_VALUE_ARB
use WGL_ARB_pixel_format WGL_TRANSPARENT_BLUE_VALUE_ARB
use WGL_ARB_pixel_format WGL_TRANSPARENT_ALPHA_VALUE_ARB
use WGL_ARB_pixel_format WGL_TRANSPARENT_INDEX_VALUE_ARB
###############################################################################
# SGI_future_use: 0x203C-0x203F
###############################################################################
# Intense3D: 0x2040-0x205F
WGL_EXT_depth_float enum:
WGL_DEPTH_FLOAT_EXT = 0x2040
###############################################################################
WGL_EXT_multisample enum:
WGL_SAMPLE_BUFFERS_EXT = 0x2041
WGL_SAMPLES_EXT = 0x2042
WGL_ARB_multisample enum:
WGL_SAMPLE_BUFFERS_ARB = 0x2041
WGL_SAMPLES_ARB = 0x2042
###############################################################################
WGL_EXT_make_current_read enum:
ERROR_INVALID_PIXEL_TYPE_EXT = 0x2043
WGL_ARB_make_current_read enum:
ERROR_INVALID_PIXEL_TYPE_ARB = 0x2043
ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB = 0x2054
###############################################################################
WGL_I3D_genlock enum:
WGL_GENLOCK_SOURCE_MULTIVIEW_I3D = 0x2044
WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D = 0x2045
WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D = 0x2046
WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D = 0x2047
WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D = 0x2048
WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D = 0x2049
WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D = 0x204A
WGL_GENLOCK_SOURCE_EDGE_RISING_I3D = 0x204B
WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D = 0x204C
###############################################################################
# Intense3D_future_use: 0x204D
###############################################################################
WGL_I3D_gamma enum:
WGL_GAMMA_TABLE_SIZE_I3D = 0x204E
WGL_GAMMA_EXCLUDE_DESKTOP_I3D = 0x204F
###############################################################################
# Intense3D hasn't spec'ed this extension, but it's in the enum registry
WGL_I3D_digital_video_control enum:
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D = 0x2050
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D = 0x2051
WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D = 0x2052
WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D = 0x2053
###############################################################################
# WGL_ARB_make_current_read (additional; see above): 0x2054
###############################################################################
# Intense3D_future_use: 0x2055-0x205F
###############################################################################
# 3DFX: 0x2060-0x206F
WGL_3DFX_multisample enum:
WGL_SAMPLE_BUFFERS_3DFX = 0x2060
WGL_SAMPLES_3DFX = 0x2061
###############################################################################
# ARB: 0x2070-0x209F
WGL_ARB_render_texture enum:
WGL_BIND_TO_TEXTURE_RGB_ARB = 0x2070
WGL_BIND_TO_TEXTURE_RGBA_ARB = 0x2071
WGL_TEXTURE_FORMAT_ARB = 0x2072
WGL_TEXTURE_TARGET_ARB = 0x2073
WGL_MIPMAP_TEXTURE_ARB = 0x2074
WGL_TEXTURE_RGB_ARB = 0x2075
WGL_TEXTURE_RGBA_ARB = 0x2076
WGL_NO_TEXTURE_ARB = 0x2077
WGL_TEXTURE_CUBE_MAP_ARB = 0x2078
WGL_TEXTURE_1D_ARB = 0x2079
WGL_TEXTURE_2D_ARB = 0x207A
WGL_MIPMAP_LEVEL_ARB = 0x207B
WGL_CUBE_MAP_FACE_ARB = 0x207C
WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = 0x207D
WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = 0x207E
WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = 0x207F
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = 0x2080
WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = 0x2081
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = 0x2082
WGL_FRONT_LEFT_ARB = 0x2083
WGL_FRONT_RIGHT_ARB = 0x2084
WGL_BACK_LEFT_ARB = 0x2085
WGL_BACK_RIGHT_ARB = 0x2086
WGL_AUX0_ARB = 0x2087
WGL_AUX1_ARB = 0x2088
WGL_AUX2_ARB = 0x2089
WGL_AUX3_ARB = 0x208A
WGL_AUX4_ARB = 0x208B
WGL_AUX5_ARB = 0x208C
WGL_AUX6_ARB = 0x208D
WGL_AUX7_ARB = 0x208E
WGL_AUX8_ARB = 0x208F
WGL_AUX9_ARB = 0x2090
# ARB_future_use: 0x2091-0x209F
###############################################################################
# NVIDIA: 0x20A0-0x219F
WGL_NV_render_texture_rectangle enum:
WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV = 0x20A0
WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV = 0x20A1
WGL_TEXTURE_RECTANGLE_NV = 0x20A2
WGL_NV_render_depth_texture enum:
WGL_BIND_TO_TEXTURE_DEPTH_NV = 0x20A3
WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV = 0x20A4
WGL_DEPTH_TEXTURE_FORMAT_NV = 0x20A5
WGL_TEXTURE_DEPTH_COMPONENT_NV = 0x20A6
WGL_DEPTH_COMPONENT_NV = 0x20A7
# NV_future_use: 0x20A8-0x20AF
WGL_NV_float_buffer enum:
WGL_FLOAT_COMPONENTS_NV = 0x20B0
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV = 0x20B1
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV = 0x20B2
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV = 0x20B3
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV = 0x20B4
WGL_TEXTURE_FLOAT_R_NV = 0x20B5
WGL_TEXTURE_FLOAT_RG_NV = 0x20B6
WGL_TEXTURE_FLOAT_RGB_NV = 0x20B7
WGL_TEXTURE_FLOAT_RGBA_NV = 0x20B8
# NV_future_use: 0x20B9-0x219F
###############################################################################
# ATI: 0x21A0-0x21AF
WGL_ARB_pixel_format_float enum:
WGL_TYPE_RGBA_FLOAT_ARB = 0x21A0
WGL_ATI_pixel_format_float enum:
WGL_TYPE_RGBA_FLOAT_ATI = 0x21A0
# ATI_future_use: 0x21A1-0x21AF
###############################################################################
# Matrox: 0x21B0-0x21BF (tentative, RFC sent to ARB 2002/10/3)
###############################################################################
# Any_vendor_future_use: 0x21C0-0xFFFF

View file

@ -0,0 +1,382 @@
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2005 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
#
# $Date: 2005/01/20 08:44:12 $ $Revision: 1.8 $
# $Header: /oss/CVS/cvs/projects/ogl-sample/main/doc/registry/specs/wglenumext.spec,v 1.8 2005/01/20 08:44:12 ljp Exp $
# List of WGL enumerants for wglext.h header
#
# This is NOT the master WGL enumerant registry. Microsoft used
# to maintain that, but given their limited interest in OpenGL,
# SGI now maintains the registry in wglenum.spec.
#
# Unlike wglenum.spec, wglenumext.spec is
# (1) In order by extension number
# (2) Includes only WGL extensions.
# (3) Has no 'Extensions' section, since enums are always
# conditionally protected against multiple definition
# by glextenum.pl.
# (4) Is processed by glextenum.pl, which has evolved
# from enum.pl - should merge back into one script.
# wglext.h version number - this should be automatically updated,
# when changing either enum or template spec files.
passthru:
passthru: /* Header file version number */
passthru: /* wglext.h last updated 2005/01/07 */
passthru: /* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */
passthru: #define WGL_WGLEXT_VERSION 6
###############################################################################
#
# ARB WGL extensions, in ARB extension order
#
###############################################################################
###############################################################################
# ARB Extension #4
WGL_ARB_buffer_region enum:
WGL_FRONT_COLOR_BUFFER_BIT_ARB = 0x00000001
WGL_BACK_COLOR_BUFFER_BIT_ARB = 0x00000002
WGL_DEPTH_BUFFER_BIT_ARB = 0x00000004
WGL_STENCIL_BUFFER_BIT_ARB = 0x00000008
###############################################################################
# ARB Extension #5
WGL_ARB_multisample enum:
WGL_SAMPLE_BUFFERS_ARB = 0x2041
WGL_SAMPLES_ARB = 0x2042
###############################################################################
# No new tokens
# ARB Extension #8
WGL_ARB_extensions_string enum:
###############################################################################
# ARB Extension #9
WGL_ARB_pixel_format enum:
WGL_NUMBER_PIXEL_FORMATS_ARB = 0x2000
WGL_DRAW_TO_WINDOW_ARB = 0x2001
WGL_DRAW_TO_BITMAP_ARB = 0x2002
WGL_ACCELERATION_ARB = 0x2003
WGL_NEED_PALETTE_ARB = 0x2004
WGL_NEED_SYSTEM_PALETTE_ARB = 0x2005
WGL_SWAP_LAYER_BUFFERS_ARB = 0x2006
WGL_SWAP_METHOD_ARB = 0x2007
WGL_NUMBER_OVERLAYS_ARB = 0x2008
WGL_NUMBER_UNDERLAYS_ARB = 0x2009
WGL_TRANSPARENT_ARB = 0x200A
WGL_TRANSPARENT_RED_VALUE_ARB = 0x2037
WGL_TRANSPARENT_GREEN_VALUE_ARB = 0x2038
WGL_TRANSPARENT_BLUE_VALUE_ARB = 0x2039
WGL_TRANSPARENT_ALPHA_VALUE_ARB = 0x203A
WGL_TRANSPARENT_INDEX_VALUE_ARB = 0x203B
WGL_SHARE_DEPTH_ARB = 0x200C
WGL_SHARE_STENCIL_ARB = 0x200D
WGL_SHARE_ACCUM_ARB = 0x200E
WGL_SUPPORT_GDI_ARB = 0x200F
WGL_SUPPORT_OPENGL_ARB = 0x2010
WGL_DOUBLE_BUFFER_ARB = 0x2011
WGL_STEREO_ARB = 0x2012
WGL_PIXEL_TYPE_ARB = 0x2013
WGL_COLOR_BITS_ARB = 0x2014
WGL_RED_BITS_ARB = 0x2015
WGL_RED_SHIFT_ARB = 0x2016
WGL_GREEN_BITS_ARB = 0x2017
WGL_GREEN_SHIFT_ARB = 0x2018
WGL_BLUE_BITS_ARB = 0x2019
WGL_BLUE_SHIFT_ARB = 0x201A
WGL_ALPHA_BITS_ARB = 0x201B
WGL_ALPHA_SHIFT_ARB = 0x201C
WGL_ACCUM_BITS_ARB = 0x201D
WGL_ACCUM_RED_BITS_ARB = 0x201E
WGL_ACCUM_GREEN_BITS_ARB = 0x201F
WGL_ACCUM_BLUE_BITS_ARB = 0x2020
WGL_ACCUM_ALPHA_BITS_ARB = 0x2021
WGL_DEPTH_BITS_ARB = 0x2022
WGL_STENCIL_BITS_ARB = 0x2023
WGL_AUX_BUFFERS_ARB = 0x2024
WGL_NO_ACCELERATION_ARB = 0x2025
WGL_GENERIC_ACCELERATION_ARB = 0x2026
WGL_FULL_ACCELERATION_ARB = 0x2027
WGL_SWAP_EXCHANGE_ARB = 0x2028
WGL_SWAP_COPY_ARB = 0x2029
WGL_SWAP_UNDEFINED_ARB = 0x202A
WGL_TYPE_RGBA_ARB = 0x202B
WGL_TYPE_COLORINDEX_ARB = 0x202C
###############################################################################
# ARB Extension #10
WGL_ARB_make_current_read enum:
ERROR_INVALID_PIXEL_TYPE_ARB = 0x2043
ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB = 0x2054
###############################################################################
# ARB Extension #11
WGL_ARB_pbuffer enum:
WGL_DRAW_TO_PBUFFER_ARB = 0x202D
WGL_MAX_PBUFFER_PIXELS_ARB = 0x202E
WGL_MAX_PBUFFER_WIDTH_ARB = 0x202F
WGL_MAX_PBUFFER_HEIGHT_ARB = 0x2030
WGL_PBUFFER_LARGEST_ARB = 0x2033
WGL_PBUFFER_WIDTH_ARB = 0x2034
WGL_PBUFFER_HEIGHT_ARB = 0x2035
WGL_PBUFFER_LOST_ARB = 0x2036
WGL_TRANSPARENT_RED_VALUE_ARB = 0x2037
WGL_TRANSPARENT_GREEN_VALUE_ARB = 0x2038
WGL_TRANSPARENT_BLUE_VALUE_ARB = 0x2039
WGL_TRANSPARENT_ALPHA_VALUE_ARB = 0x203A
WGL_TRANSPARENT_INDEX_VALUE_ARB = 0x203B
###############################################################################
# ARB Extension #20
WGL_ARB_render_texture enum:
WGL_BIND_TO_TEXTURE_RGB_ARB = 0x2070
WGL_BIND_TO_TEXTURE_RGBA_ARB = 0x2071
WGL_TEXTURE_FORMAT_ARB = 0x2072
WGL_TEXTURE_TARGET_ARB = 0x2073
WGL_MIPMAP_TEXTURE_ARB = 0x2074
WGL_TEXTURE_RGB_ARB = 0x2075
WGL_TEXTURE_RGBA_ARB = 0x2076
WGL_NO_TEXTURE_ARB = 0x2077
WGL_TEXTURE_CUBE_MAP_ARB = 0x2078
WGL_TEXTURE_1D_ARB = 0x2079
WGL_TEXTURE_2D_ARB = 0x207A
WGL_MIPMAP_LEVEL_ARB = 0x207B
WGL_CUBE_MAP_FACE_ARB = 0x207C
WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = 0x207D
WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = 0x207E
WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = 0x207F
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = 0x2080
WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = 0x2081
WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = 0x2082
WGL_FRONT_LEFT_ARB = 0x2083
WGL_FRONT_RIGHT_ARB = 0x2084
WGL_BACK_LEFT_ARB = 0x2085
WGL_BACK_RIGHT_ARB = 0x2086
WGL_AUX0_ARB = 0x2087
WGL_AUX1_ARB = 0x2088
WGL_AUX2_ARB = 0x2089
WGL_AUX3_ARB = 0x208A
WGL_AUX4_ARB = 0x208B
WGL_AUX5_ARB = 0x208C
WGL_AUX6_ARB = 0x208D
WGL_AUX7_ARB = 0x208E
WGL_AUX8_ARB = 0x208F
WGL_AUX9_ARB = 0x2090
###############################################################################
# ARB Extension #39
WGL_ARB_pixel_format_float enum:
WGL_TYPE_RGBA_FLOAT_ARB = 0x21A0
###############################################################################
#
# non-ARB extensions follow, in registry order
#
###############################################################################
###############################################################################
# Extension #169
WGL_EXT_make_current_read enum:
ERROR_INVALID_PIXEL_TYPE_EXT = 0x2043
###############################################################################
# Extension #170
WGL_EXT_pixel_format enum:
WGL_NUMBER_PIXEL_FORMATS_EXT = 0x2000
WGL_DRAW_TO_WINDOW_EXT = 0x2001
WGL_DRAW_TO_BITMAP_EXT = 0x2002
WGL_ACCELERATION_EXT = 0x2003
WGL_NEED_PALETTE_EXT = 0x2004
WGL_NEED_SYSTEM_PALETTE_EXT = 0x2005
WGL_SWAP_LAYER_BUFFERS_EXT = 0x2006
WGL_SWAP_METHOD_EXT = 0x2007
WGL_NUMBER_OVERLAYS_EXT = 0x2008
WGL_NUMBER_UNDERLAYS_EXT = 0x2009
WGL_TRANSPARENT_EXT = 0x200A
WGL_TRANSPARENT_VALUE_EXT = 0x200B
WGL_SHARE_DEPTH_EXT = 0x200C
WGL_SHARE_STENCIL_EXT = 0x200D
WGL_SHARE_ACCUM_EXT = 0x200E
WGL_SUPPORT_GDI_EXT = 0x200F
WGL_SUPPORT_OPENGL_EXT = 0x2010
WGL_DOUBLE_BUFFER_EXT = 0x2011
WGL_STEREO_EXT = 0x2012
WGL_PIXEL_TYPE_EXT = 0x2013
WGL_COLOR_BITS_EXT = 0x2014
WGL_RED_BITS_EXT = 0x2015
WGL_RED_SHIFT_EXT = 0x2016
WGL_GREEN_BITS_EXT = 0x2017
WGL_GREEN_SHIFT_EXT = 0x2018
WGL_BLUE_BITS_EXT = 0x2019
WGL_BLUE_SHIFT_EXT = 0x201A
WGL_ALPHA_BITS_EXT = 0x201B
WGL_ALPHA_SHIFT_EXT = 0x201C
WGL_ACCUM_BITS_EXT = 0x201D
WGL_ACCUM_RED_BITS_EXT = 0x201E
WGL_ACCUM_GREEN_BITS_EXT = 0x201F
WGL_ACCUM_BLUE_BITS_EXT = 0x2020
WGL_ACCUM_ALPHA_BITS_EXT = 0x2021
WGL_DEPTH_BITS_EXT = 0x2022
WGL_STENCIL_BITS_EXT = 0x2023
WGL_AUX_BUFFERS_EXT = 0x2024
WGL_NO_ACCELERATION_EXT = 0x2025
WGL_GENERIC_ACCELERATION_EXT = 0x2026
WGL_FULL_ACCELERATION_EXT = 0x2027
WGL_SWAP_EXCHANGE_EXT = 0x2028
WGL_SWAP_COPY_EXT = 0x2029
WGL_SWAP_UNDEFINED_EXT = 0x202A
WGL_TYPE_RGBA_EXT = 0x202B
WGL_TYPE_COLORINDEX_EXT = 0x202C
###############################################################################
# Extension #171
WGL_EXT_pbuffer enum:
WGL_DRAW_TO_PBUFFER_EXT = 0x202D
WGL_MAX_PBUFFER_PIXELS_EXT = 0x202E
WGL_MAX_PBUFFER_WIDTH_EXT = 0x202F
WGL_MAX_PBUFFER_HEIGHT_EXT = 0x2030
WGL_OPTIMAL_PBUFFER_WIDTH_EXT = 0x2031
WGL_OPTIMAL_PBUFFER_HEIGHT_EXT = 0x2032
WGL_PBUFFER_LARGEST_EXT = 0x2033
WGL_PBUFFER_WIDTH_EXT = 0x2034
WGL_PBUFFER_HEIGHT_EXT = 0x2035
###############################################################################
# Extension #177
WGL_EXT_depth_float enum:
WGL_DEPTH_FLOAT_EXT = 0x2040
###############################################################################
# Extension #207
WGL_3DFX_multisample enum:
WGL_SAMPLE_BUFFERS_3DFX = 0x2060
WGL_SAMPLES_3DFX = 0x2061
###############################################################################
# Extension #209
WGL_EXT_multisample enum:
WGL_SAMPLE_BUFFERS_EXT = 0x2041
WGL_SAMPLES_EXT = 0x2042
###############################################################################
# Extension #250
WGL_I3D_digital_video_control enum:
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D = 0x2050
WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D = 0x2051
WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D = 0x2052
WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D = 0x2053
###############################################################################
# Extension #251
WGL_I3D_gamma enum:
WGL_GAMMA_TABLE_SIZE_I3D = 0x204E
WGL_GAMMA_EXCLUDE_DESKTOP_I3D = 0x204F
###############################################################################
# Extension #252
WGL_I3D_genlock enum:
WGL_GENLOCK_SOURCE_MULTIVIEW_I3D = 0x2044
WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D = 0x2045
WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D = 0x2046
WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D = 0x2047
WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D = 0x2048
WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D = 0x2049
WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D = 0x204A
WGL_GENLOCK_SOURCE_EDGE_RISING_I3D = 0x204B
WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D = 0x204C
###############################################################################
# Extension #253
WGL_I3D_image_buffer enum:
WGL_IMAGE_BUFFER_MIN_ACCESS_I3D = 0x00000001
WGL_IMAGE_BUFFER_LOCK_I3D = 0x00000002
###############################################################################
# No new tokens
# Extension #254
WGL_I3D_swap_frame_lock enum:
###############################################################################
# Extension #263
WGL_NV_render_depth_texture enum:
WGL_BIND_TO_TEXTURE_DEPTH_NV = 0x20A3
WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV = 0x20A4
WGL_DEPTH_TEXTURE_FORMAT_NV = 0x20A5
WGL_TEXTURE_DEPTH_COMPONENT_NV = 0x20A6
WGL_DEPTH_COMPONENT_NV = 0x20A7
###############################################################################
# Extension #264
WGL_NV_render_texture_rectangle enum:
WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV = 0x20A0
WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV = 0x20A1
WGL_TEXTURE_RECTANGLE_NV = 0x20A2
###############################################################################
# Extension #278
WGL_ATI_pixel_format_float enum:
WGL_TYPE_RGBA_FLOAT_ATI = 0x21A0
###############################################################################
# Extension #281
WGL_NV_float_buffer enum:
WGL_FLOAT_COMPONENTS_NV = 0x20B0
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV = 0x20B1
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV = 0x20B2
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV = 0x20B3
WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV = 0x20B4
WGL_TEXTURE_FLOAT_R_NV = 0x20B5
WGL_TEXTURE_FLOAT_RG_NV = 0x20B6
WGL_TEXTURE_FLOAT_RGB_NV = 0x20B7
WGL_TEXTURE_FLOAT_RGBA_NV = 0x20B8

View file

@ -0,0 +1,746 @@
# wglext.spec file
# DON'T REMOVE PREVIOUS LINE!!! libspec depends on it!
#
# License Applicability. Except to the extent portions of this file are
# made subject to an alternative license as permitted in the SGI Free
# Software License B, Version 1.1 (the "License"), the contents of this
# file are subject only to the provisions of the License. You may not use
# this file except in compliance with the License. You may obtain a copy
# of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
# Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
#
# http://oss.sgi.com/projects/FreeB
#
# Note that, as provided in the License, the Software is distributed on an
# "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
# DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
# CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
# PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
#
# Original Code. The Original Code is: OpenGL Sample Implementation,
# Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
# Inc. The Original Code is Copyright (c) 1991-2002 Silicon Graphics, Inc.
# Copyright in any portions created by third parties is as indicated
# elsewhere herein. All Rights Reserved.
#
# Additional Notice Provisions: This software was created using the
# OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
# not been independently verified as being compliant with the OpenGL(R)
# version 1.2.1 Specification.
required-props:
param: retval retained
category: wgl ARB_buffer_region ARB_extensions_string ARB_pixel_format ARB_make_current_read ARB_pbuffer ARB_render_texture ARB_pixel_format_float EXT_display_color_table EXT_extensions_string EXT_make_current_read EXT_pbuffer EXT_pixel_format EXT_swap_control OML_sync_control I3D_digital_video_control I3D_gamma I3D_genlock I3D_image_buffer I3D_swap_frame_lock I3D_swap_frame_usage NV_vertex_array_range
# required-props in wgl.spec (which is not used for anything):
# dlflags: notlistable handcode
# wglflags: client-handcode server-handcode non-dispatch
#
# Boilerplate to define types used by some extensions. This is done
# up front, since it involves some complexities in protecting
# the declarations whether or not the -protect flag is given to
# the generator scripts.
#
passthru: #ifndef WGL_ARB_pbuffer
passthru: DECLARE_HANDLE(HPBUFFERARB);
passthru: #endif
passthru: #ifndef WGL_EXT_pbuffer
passthru: DECLARE_HANDLE(HPBUFFEREXT);
passthru: #endif
passthru:
###############################################################################
#
# ARB Extension #4
# ARB_buffer_region commands
#
###############################################################################
CreateBufferRegionARB(hDC, iLayerPlane, uType)
return HANDLE
param hDC HDC in value
param iLayerPlane int in value
param uType UINT in value
category ARB_buffer_region
DeleteBufferRegionARB(hRegion)
return VOID
param hRegion HANDLE in value
category ARB_buffer_region
SaveBufferRegionARB(hRegion, x, y, width, height)
return BOOL
param hRegion HANDLE in value
param x int in value
param y int in value
param width int in value
param height int in value
category ARB_buffer_region
RestoreBufferRegionARB(hRegion, x, y, width, height, xSrc, ySrc)
return BOOL
param hRegion HANDLE in value
param x int in value
param y int in value
param width int in value
param height int in value
param xSrc int in value
param ySrc int in value
category ARB_buffer_region
###############################################################################
#
# ARB Extension #5
# ARB_multisample commands
#
###############################################################################
# (none)
newcategory: ARB_multisample
###############################################################################
#
# ARB Extension #8
# ARB_extensions_string commands
#
###############################################################################
GetExtensionsStringARB(hdc)
return String
param hdc HDC in value
category ARB_extensions_string
###############################################################################
#
# ARB Extension #9
# ARB_pixel_format commands
#
###############################################################################
GetPixelFormatAttribivARB(hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues)
return BOOL
param hdc HDC in value
param iPixelFormat int in value
param iLayerPlane int in value
param nAttributes UINT in value
param piAttributes int in array [nAttributes]
param piValues int out array [nAttributes]
category ARB_pixel_format
GetPixelFormatAttribfvARB(hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues)
return BOOL
param hdc HDC in value
param iPixelFormat int in value
param iLayerPlane int in value
param nAttributes UINT in value
param piAttributes int in array [nAttributes]
param pfValues FLOAT out array [nAttributes]
category ARB_pixel_format
ChoosePixelFormatARB(hdc, piAttribIList, pfAttribFList, nMaxFormats, piFormats, nNumFormats)
return BOOL
param hdc HDC in value
param piAttribIList int in array [COMPSIZE()]
param pfAttribFList FLOAT in array [COMPSIZE()]
param nMaxFormats UINT in value
param piFormats int out array [COMPSIZE(nNumFormats)]
param nNumFormats UINT out reference
category ARB_pixel_format
###############################################################################
#
# ARB Extension #10
# ARB_make_current_read commands
#
###############################################################################
MakeContextCurrentARB(hDrawDC, hReadDC, hglrc)
return BOOL
param hDrawDC HDC in value
param hReadDC HDC in value
param hglrc HGLRC in value
category ARB_make_current_read
GetCurrentReadDCARB()
return HDC
category ARB_make_current_read
###############################################################################
#
# ARB Extension #11
# ARB_pbuffer commands
#
###############################################################################
CreatePbufferARB(hDC, iPixelFormat, iWidth, iHeight, piAttribList)
return HPBUFFERARB
param hDC HDC in value
param iPixelFormat int in value
param iWidth int in value
param iHeight int in value
param piAttribList int in array [COMPSIZE()]
category ARB_pbuffer
GetPbufferDCARB(hPbuffer)
return HDC
param hPbuffer HPBUFFERARB in value
category ARB_pbuffer
ReleasePbufferDCARB(hPbuffer, hDC)
return int
param hPbuffer HPBUFFERARB in value
param hDC HDC in value
category ARB_pbuffer
DestroyPbufferARB(hPbuffer)
return BOOL
param hPbuffer HPBUFFERARB in value
category ARB_pbuffer
QueryPbufferARB(hPbuffer, iAttribute, piValue)
return BOOL
param hPbuffer HPBUFFERARB in value
param iAttribute int in value
param piValue int out reference
category ARB_pbuffer
###############################################################################
#
# ARB Extension #20
# ARB_render_texture commands
#
###############################################################################
BindTexImageARB(hPbuffer, iBuffer)
return BOOL
param hPbuffer HPBUFFERARB in value
param iBuffer int in value
category ARB_render_texture
ReleaseTexImageARB(hPbuffer, iBuffer)
return BOOL
param hPbuffer HPBUFFERARB in value
param iBuffer int in value
category ARB_render_texture
SetPbufferAttribARB(hPbuffer, piAttribList)
return BOOL
param hPbuffer HPBUFFERARB in value
param piAttribList int in array [COMPSIZE()]
category ARB_render_texture
###############################################################################
#
# ARB Extension #39
# ARB_pixel_format_float commands
#
###############################################################################
# (none)
newcategory: ARB_pixel_format_float
###############################################################################
#
# Extension #167
# EXT_display_color_table commands
#
###############################################################################
CreateDisplayColorTableEXT(id)
return GLboolean
param id GLushort in value
category EXT_display_color_table
LoadDisplayColorTableEXT(table, length)
return GLboolean
param table GLushort in array [length]
param length GLuint in value
category EXT_display_color_table
BindDisplayColorTableEXT(id)
return GLboolean
param id GLushort in value
category EXT_display_color_table
DestroyDisplayColorTableEXT(id)
return VOID
param id GLushort in value
category EXT_display_color_table
###############################################################################
#
# Extension #168
# EXT_extensions_string commands
#
###############################################################################
GetExtensionsStringEXT()
return String
category EXT_extensions_string
###############################################################################
#
# Extension #169
# EXT_make_current_read commands
#
###############################################################################
MakeContextCurrentEXT(hDrawDC, hReadDC, hglrc)
return BOOL
param hDrawDC HDC in value
param hReadDC HDC in value
param hglrc HGLRC in value
category EXT_make_current_read
GetCurrentReadDCEXT()
return HDC
category EXT_make_current_read
###############################################################################
#
# Extension #171
# EXT_pbuffer commands
#
###############################################################################
CreatePbufferEXT(hDC, iPixelFormat, iWidth, iHeight, piAttribList)
return HPBUFFEREXT
param hDC HDC in value
param iPixelFormat int in value
param iWidth int in value
param iHeight int in value
param piAttribList int in array [COMPSIZE()]
category EXT_pbuffer
GetPbufferDCEXT(hPbuffer)
return HDC
param hPbuffer HPBUFFEREXT in value
category EXT_pbuffer
ReleasePbufferDCEXT(hPbuffer, hDC)
return int
param hPbuffer HPBUFFEREXT in value
param hDC HDC in value
category EXT_pbuffer
DestroyPbufferEXT(hPbuffer)
return BOOL
param hPbuffer HPBUFFEREXT in value
category EXT_pbuffer
QueryPbufferEXT(hPbuffer, iAttribute, piValue)
return BOOL
param hPbuffer HPBUFFEREXT in value
param iAttribute int in value
param piValue int out reference
category EXT_pbuffer
###############################################################################
#
# Extension #170
# EXT_pixel_format commands
#
###############################################################################
GetPixelFormatAttribivEXT(hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues)
return BOOL
param hdc HDC in value
param iPixelFormat int in value
param iLayerPlane int in value
param nAttributes UINT in value
param piAttributes int out array [nAttributes]
param piValues int out array [nAttributes]
category EXT_pixel_format
GetPixelFormatAttribfvEXT(hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues)
return BOOL
param hdc HDC in value
param iPixelFormat int in value
param iLayerPlane int in value
param nAttributes UINT in value
param piAttributes int out array [nAttributes]
param pfValues FLOAT out array [nAttributes]
category EXT_pixel_format
ChoosePixelFormatEXT(hdc, piAttribIList, pfAttribFList, nMaxFormats, piFormats, nNumFormats)
return BOOL
param hdc HDC in value
param piAttribIList int in array [COMPSIZE()]
param pfAttribFList FLOAT in array [COMPSIZE()]
param nMaxFormats UINT in value
param piFormats int out array [COMPSIZE(nNumFormats)]
param nNumFormats UINT out reference
category EXT_pixel_format
###############################################################################
#
# Extension #172
# EXT_swap_control commands
#
###############################################################################
SwapIntervalEXT(interval)
return BOOL
param interval int in value
category EXT_swap_control
GetSwapIntervalEXT()
return int
category EXT_swap_control
###############################################################################
#
# Extension #177
# EXT_depth_float commands
#
###############################################################################
# (none)
newcategory: EXT_depth_float
###############################################################################
#
# Extension #190
# NV_vertex_array_range commands
#
###############################################################################
AllocateMemoryNV(size, readfreq, writefreq, priority)
return VoidPointer
param size GLsizei in value
param readfreq GLfloat in value
param writefreq GLfloat in value
param priority GLfloat in value
category NV_vertex_array_range
FreeMemoryNV(pointer)
return void
param pointer void out array [1]
category NV_vertex_array_range
###############################################################################
#
# Extension #207
# 3DFX_multisample commands
#
###############################################################################
# (none)
newcategory: 3DFX_multisample
###############################################################################
#
# Extension #209
# EXT_multisample commands
#
###############################################################################
# (none)
newcategory: EXT_multisample
###############################################################################
#
# Extension #242
# OML_sync_control commands
#
###############################################################################
GetSyncValuesOML(hdc, ust, msc, sbc)
return BOOL
param hdc HDC in value
param ust INT64 out array [1]
param msc INT64 out array [1]
param sbc INT64 out array [1]
category OML_sync_control
GetMscRateOML(hdc, numerator, denominator)
return BOOL
param hdc HDC in value
param numerator INT32 out array [1]
param denominator INT32 out array [1]
category OML_sync_control
SwapBuffersMscOML(hdc, target_msc, divisor, remainder)
return INT64
param hdc HDC in value
param target_msc INT64 in value
param divisor INT64 in value
param remainder INT64 in value
category OML_sync_control
SwapLayerBuffersMscOML(hdc, fuPlanes, target_msc, divisor, remainder)
return INT64
param hdc HDC in value
param fuPlanes int in value
param target_msc INT64 in value
param divisor INT64 in value
param remainder INT64 in value
category OML_sync_control
WaitForMscOML(hdc, target_msc, divisor, remainder , ust, msc, sbc)
return BOOL
param hdc HDC in value
param target_msc INT64 in value
param divisor INT64 in value
param remainder INT64 in value
param ust INT64 out array [1]
param msc INT64 out array [1]
param sbc INT64 out array [1]
category OML_sync_control
WaitForSbcOML(hdc, target_sbc, ust, msc, sbc)
return BOOL
param hdc HDC in value
param target_sbc INT64 in value
param ust INT64 out array [1]
param msc INT64 out array [1]
param sbc INT64 out array [1]
category OML_sync_control
###############################################################################
#
# Extension #250
# I3D_digital_video_control commands
#
###############################################################################
GetDigitalVideoParametersI3D(hDC, iAttribute, piValue)
return BOOL
param hDC HDC in value
param iAttribute int in value
param piValue int out array [COMPSIZE(iAttribute)]
category I3D_digital_video_control
SetDigitalVideoParametersI3D(hDC, iAttribute, piValue)
return BOOL
param hDC HDC in value
param iAttribute int in value
param piValue int in array [COMPSIZE(iAttribute)]
category I3D_digital_video_control
###############################################################################
#
# Extension #251
# I3D_gamma commands
#
###############################################################################
GetGammaTableParametersI3D(hDC, iAttribute, piValue)
return BOOL
param hDC HDC in value
param iAttribute int in value
param piValue int out array [COMPSIZE(iAttribute)]
category I3D_gamma
SetGammaTableParametersI3D(hDC, iAttribute, piValue)
return BOOL
param hDC HDC in value
param iAttribute int in value
param piValue int in array [COMPSIZE(iAttribute)]
category I3D_gamma
GetGammaTableI3D(hDC, iEntries, puRed, puGreen, puBlue)
return BOOL
param hDC HDC in value
param iEntries int in value
param puRed USHORT out array [iEntries]
param puGreen USHORT out array [iEntries]
param puBlue USHORT out array [iEntries]
category I3D_gamma
SetGammaTableI3D(hDC, iEntries, puRed, puGreen, puBlue)
return BOOL
param hDC HDC in value
param iEntries int in value
param puRed USHORT in array [iEntries]
param puGreen USHORT in array [iEntries]
param puBlue USHORT in array [iEntries]
category I3D_gamma
###############################################################################
#
# Extension #252
# I3D_genlock commands
#
###############################################################################
EnableGenlockI3D(hDC)
return BOOL
param hDC HDC in value
category I3D_genlock
DisableGenlockI3D(hDC)
return BOOL
param hDC HDC in value
category I3D_genlock
IsEnabledGenlockI3D(hDC, pFlag)
return BOOL
param hDC HDC in value
param pFlag BOOL out reference
category I3D_genlock
GenlockSourceI3D(hDC, uSource)
return BOOL
param hDC HDC in value
param uSource UINT in value
category I3D_genlock
GetGenlockSourceI3D(hDC, uSource)
return BOOL
param hDC HDC in value
param uSource UINT out reference
category I3D_genlock
GenlockSourceEdgeI3D(hDC, uEdge)
return BOOL
param hDC HDC in value
param uEdge UINT in value
category I3D_genlock
GetGenlockSourceEdgeI3D(hDC, uEdge)
return BOOL
param hDC HDC in value
param uEdge UINT out reference
category I3D_genlock
GenlockSampleRateI3D(hDC, uRate)
return BOOL
param hDC HDC in value
param uRate UINT in value
category I3D_genlock
GetGenlockSampleRateI3D(hDC, uRate)
return BOOL
param hDC HDC in value
param uRate UINT out reference
category I3D_genlock
GenlockSourceDelayI3D(hDC, uDelay)
return BOOL
param hDC HDC in value
param uDelay UINT in value
category I3D_genlock
GetGenlockSourceDelayI3D(hDC, uDelay)
return BOOL
param hDC HDC in value
param uDelay UINT out reference
category I3D_genlock
QueryGenlockMaxSourceDelayI3D(hDC, uMaxLineDelay, uMaxPixelDelay)
return BOOL
param hDC HDC in value
param uMaxLineDelay UINT out reference
param uMaxPixelDelay UINT out reference
category I3D_genlock
###############################################################################
#
# Extension #253
# I3D_image_buffer commands
#
###############################################################################
CreateImageBufferI3D(hDC, dwSize, uFlags)
return LPVOID
param hDC HDC in value
param dwSize DWORD in value
param uFlags UINT in value
category I3D_image_buffer
DestroyImageBufferI3D(hDC, pAddress)
return BOOL
param hDC HDC in value
param pAddress LPVOID in value
category I3D_image_buffer
AssociateImageBufferEventsI3D(hDC, pEvent, pAddress, pSize, count)
return BOOL
param hDC HDC in value
param pEvent HANDLE in array [count]
param pAddress LPVOID in array [count]
param pSize DWORD in array [count]
param count UINT in value
category I3D_image_buffer
ReleaseImageBufferEventsI3D(hDC, pAddress, count)
return BOOL
param hDC HDC in value
param pAddress LPVOID in array [count]
param count UINT in value
category I3D_image_buffer
###############################################################################
#
# Extension #254
# I3D_swap_frame_lock commands
#
###############################################################################
EnableFrameLockI3D()
return BOOL
category I3D_swap_frame_lock
DisableFrameLockI3D()
return BOOL
category I3D_swap_frame_lock
IsEnabledFrameLockI3D(pFlag)
return BOOL
param pFlag BOOL out reference
category I3D_swap_frame_lock
QueryFrameLockMasterI3D(pFlag)
return BOOL
param pFlag BOOL out reference
category I3D_swap_frame_lock
###############################################################################
#
# Extension #255
# I3D_swap_frame_usage commands
#
###############################################################################
GetFrameUsageI3D(pUsage)
return BOOL
param pUsage float out reference
category I3D_swap_frame_usage
BeginFrameTrackingI3D()
return BOOL
category I3D_swap_frame_usage
EndFrameTrackingI3D()
return BOOL
category I3D_swap_frame_usage
QueryFrameTrackingI3D(pFrameCount, pMissedFrames, pLastMissedUsage)
return BOOL
param pFrameCount DWORD out reference
param pMissedFrames DWORD out reference
param pLastMissedUsage float out reference
category I3D_swap_frame_usage
###############################################################################
#
# Extension #278
# ATI_pixel_format_float commands
#
###############################################################################
# (none)
newcategory: ATI_pixel_format_float
###############################################################################
#
# Extension #281
# NV_float_buffer commands
#
###############################################################################
# (none)
newcategory: NV_float_buffer

View file

@ -0,0 +1,97 @@
#region License
//Copyright (c) 2006 Stefanos Apostolopoulos
//See license.txt for license info
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.OpenGL.Bind
{
#region Constant class
/// <summary>
/// Represents an opengl constant in C# format. Both the constant name and value
/// can be retrieved or set. The value can be either a number, another constant
/// or an alias to a constant
/// </summary>
public class Constant
{
#region Name
string _name;
/// <summary>
/// Gets or sets the name of the opengl constant (eg. GL_LINES).
/// </summary>
public string Name
{
get { return _name; }
set
{
if (!String.IsNullOrEmpty(value))
_name = value.Trim();
}
}
#endregion
#region Value
string _value;
/// <summary>
/// Gets or sets the value of the opengl constant (eg. 0x00000001).
/// </summary>
public string Value
{
get { return _value; }
set
{
if (!String.IsNullOrEmpty(value))
_value = value.Trim();
}
}
#endregion
#region Constructors
/// <summary>
/// Creates an empty Constant.
/// </summary>
public Constant()
{
}
/// <summary>
/// Creates a Constant with the given name and value.
/// </summary>
/// <param name="name">The Name of the Constant.</param>
/// <param name="value">The Type of the Constant.</param>
public Constant(string name, string value)
{
Name = name;
Value = value;
}
#endregion
#region public string ToString()
/// <summary>
/// Returns a string that represents the full constant declaration without decorations
/// (eg const uint GL_XXX_YYY = 0xDEADBEEF).
/// </summary>
/// <returns></returns>
override public string ToString()
{
return Name + " = " + Value;
}
#endregion
}
#endregion
}

View file

@ -0,0 +1,49 @@
#region License
//Copyright (c) 2006 Stefanos Apostolopoulos
//See license.txt for license info
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.OpenGL.Bind
{
#region class Enum
public class Enum
{
string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
System.Collections.Hashtable _constant_collection = new System.Collections.Hashtable();
public System.Collections.Hashtable ConstantCollection
{
get { return _constant_collection; }
set { _constant_collection = value; }
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(" public enum " + Name + " : uint");
sb.AppendLine(" {");
foreach (Constant c in ConstantCollection.Values)
{
sb.AppendLine(" " + c.Name + " = " + c.Value + ",");
}
sb.AppendLine(" }");
return sb.ToString();
}
}
#endregion
}

View file

@ -0,0 +1,266 @@
#region License
//Copyright (c) 2006 Stefanos Apostolopoulos
//See license.txt for license info
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.OpenGL.Bind
{
#region class Function
/// <summary>
/// Represents an opengl function.
/// The return value, function name, function parameters and opengl version can be retrieved or set.
/// </summary>
public class Function
{
#region Constructors
public Function()
{
Parameters = new ParameterCollection();
Body = new FunctionBody();
}
public Function(Function f)
{
this.Body = new FunctionBody(f.Body);
this.Category = new string(f.Category.ToCharArray());
this.Extension = f.Extension;
this.Name = new string(f.Name.ToCharArray());
this.NeedsWrapper = f.NeedsWrapper;
this.Parameters = new ParameterCollection(f.Parameters);
this.ReturnValue = new string(f.ReturnValue.ToCharArray());
this.Version = new string(f.Version.ToCharArray());
this.WrapperType = f.WrapperType;
}
#endregion
#region Function body
FunctionBody _body;
public FunctionBody Body
{
get { return _body; }
set { _body = value; }
}
#endregion
#region Category property
private string _category;
public string Category
{
get { return _category; }
set { _category = value; }
}
#endregion
#region Wrapper type property
private WrapperTypes _wrapper_type = WrapperTypes.None;
public WrapperTypes WrapperType
{
get { return _wrapper_type; }
set { _wrapper_type = value; }
}
#endregion
#region Needs wrapper property
bool _needs_wrapper;
/// <summary>
/// Indicates whether this function needs to be wrapped with a Marshaling function.
/// This flag is set if a function contains an Array parameter, or returns
/// an Array or string.
/// </summary>
public bool NeedsWrapper
{
get { return _needs_wrapper; }
set { _needs_wrapper = value; }
}
#endregion
#region Return value property
string _return_value;
/// <summary>
/// Gets or sets the return value of the opengl function.
/// </summary>
public string ReturnValue
{
get { return _return_value; }
set { _return_value = value; }
}
#endregion
#region Name property
string _name;
/// <summary>
/// Gets or sets the name of the opengl function.
/// </summary>
public string Name
{
get { return _name; }
set
{
if (!String.IsNullOrEmpty(value))
_name = value.Trim();
else
_name = value;
}
}
#endregion
#region Parameter collection property
ParameterCollection _parameters;
public ParameterCollection Parameters
{
get { return _parameters; }
set { _parameters = value; }
}
#endregion
#region Version property
string _version;
/// <summary>
/// Defines the opengl version that introduced this function.
/// </summary>
public string Version
{
get { return _version; }
set { _version = value; }
}
#endregion
#region Extension property
bool _extension = false;
public bool Extension
{
get { return _extension; }
set { _extension = value; }
}
#endregion
#region Call function string
public string CallString()
{
StringBuilder sb = new StringBuilder();
sb.Append(Name);
sb.Append("(");
foreach (Parameter p in Parameters)
{
if (p.Unchecked)
sb.Append("unchecked((" + p.Type + ")");
sb.Append(p.Name);
if (p.Unchecked)
sb.Append(")");
sb.Append(", ");
}
sb.Replace(", ", ")", sb.Length - 2, 2);
return sb.ToString();
}
#endregion
#region ToString function
/// <summary>
/// Gets the string representing the full function declaration without decorations
/// (ie "void glClearColor(float red, float green, float blue, float alpha)"
/// </summary>
override public string ToString()
{
return ToString("");
}
public string ToString(string indentation)
{
StringBuilder sb = new StringBuilder();
sb.Append(indentation + ReturnValue + " " + Name + Parameters.ToString());
if (Body.Count > 0)
{
sb.AppendLine();
sb.Append(Body.ToString(indentation));
}
return sb.ToString();
}
#endregion
}
#endregion
#region class FunctionBody : List<string>
public class FunctionBody : List<string>
{
public FunctionBody()
{
}
public FunctionBody(FunctionBody fb)
{
foreach (string s in fb)
{
this.Add(s);
}
}
public override string ToString()
{
return ToString("");
}
public string ToString(string indentation)
{
if (this.Count == 0)
return String.Empty;
StringBuilder sb = new StringBuilder(this.Count);
sb.AppendLine(indentation + "{");
foreach (string s in this)
{
sb.AppendLine(indentation + " " + s);
}
sb.AppendLine(indentation + "}");
return sb.ToString();
}
}
#endregion
}

View file

@ -0,0 +1,352 @@
#region License
//Copyright (c) 2006 Stefanos Apostolopoulos
//See license.txt for license info
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace OpenTK.OpenGL.Bind
{
#region Parameter class
/// <summary>
/// Represents a single parameter of an opengl function.
/// </summary>
public class Parameter
{
#region Constructors
/// <summary>
/// Creates a new Parameter without type and name.
/// </summary>
public Parameter()
{
}
/// <summary>
/// Creates a new parameter from the parameters passed (deep copy).
/// </summary>
/// <param name="p">The parameter to copy from.</param>
public Parameter(Parameter p)
{
if (p == null)
return;
this.Array = p.Array;
this.Flow = p.Flow;
this.Name = new string(p.Name.ToCharArray());
this.NeedsWrapper = p.NeedsWrapper;
this.PreviousType = new string(p.PreviousType.ToCharArray());
this.Type = new string(p.Type.ToCharArray());
this.Unchecked = p.Unchecked;
this.UnmanagedType = p.UnmanagedType;
this.WrapperType = p.WrapperType;
}
#endregion
#region Name property
string _name;
/// <summary>
/// Gets or sets the name of the parameter.
/// </summary>
public string Name
{
get { return _name; }
set { _name = value; }
}
#endregion
#region UnmanagedType property
UnmanagedType _unmanaged_type;
/// <summary>
/// Gets or sets the name of the parameter.
/// </summary>
public UnmanagedType UnmanagedType
{
get { return _unmanaged_type; }
set { _unmanaged_type = value; }
}
#endregion
#region Type property
string _type;
/// <summary>
/// Gets the type of the parameter.
/// </summary>
public string Type
{
get { return _type; }
set
{
if (_type != null)
PreviousType = _type;
_type = value;
}
}
#endregion
#region Previous type property
private string _previous_type;
public string PreviousType
{
get { return _previous_type; }
set { _previous_type = value; }
}
#endregion
#region Flow property
/// <summary>
/// Enumarates the possible flows of a parameter (ie. is this parameter
/// used as input or as output?)
/// </summary>
public enum FlowDirection
{
Undefined = 0,
In,
Out
}
FlowDirection _flow;
/// <summary>
/// Gets or sets the flow of the parameter.
/// </summary>
public FlowDirection Flow
{
get { return _flow; }
set { _flow = value; }
}
#endregion
#region Array property
bool _array = false;
public bool Array
{
get { return _array; }
set { _array = value; }
}
#endregion
#region Unchecked property
private bool _unchecked;
public bool Unchecked
{
get { return _unchecked; }
set { _unchecked = value; }
}
#endregion
#region NeedsWrapper property
private bool _needs_wrapper;
public bool NeedsWrapper
{
get { return _needs_wrapper; }
set { _needs_wrapper = value; }
}
#endregion
#region WrapperType property
private WrapperTypes _wrapper_type = WrapperTypes.None;
public WrapperTypes WrapperType
{
get { return _wrapper_type; }
set { _wrapper_type = value; }
}
#endregion
#region ToString function
override public string ToString()
{
StringBuilder sb = new StringBuilder();
if (UnmanagedType == UnmanagedType.AsAny && Flow == FlowDirection.In)
sb.Append("[MarshalAs(UnmanagedType.AsAny)] ");
if (UnmanagedType == UnmanagedType.LPArray)
sb.Append("[MarshalAs(UnmanagedType.LPArray)] ");
//if (Flow == FlowDirection.Out && !Array && !(Type == "IntPtr"))
// sb.Append("out ");
sb.Append(Type);
if (Array)
sb.Append("[]");
sb.Append(" ");
sb.Append(Name);
return sb.ToString();
}
#endregion
}
#endregion
#region ParameterCollection class
/// <summary>
/// Holds the parameter list of an opengl function.
/// </summary>
public class ParameterCollection : List<Parameter>
{
#region Constructors
public ParameterCollection()
{
}
public ParameterCollection(ParameterCollection pc)
{
foreach (Parameter p in pc)
{
this.Add(new Parameter(p));
}
}
#endregion
#region override public string ToString()
/// <summary>
///
/// </summary>
/// <returns>The parameter list of an opengl function in the form ( [parameters] )</returns>
override public string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("(");
if (this.Count > 0)
{
foreach (Parameter p in this)
{
sb.Append(p.ToString());
sb.Append(", ");
}
sb.Replace(", ", ")", sb.Length - 2, 2);
}
else
sb.Append(")");
return sb.ToString();
}
public bool ContainsType(string type)
{
foreach (Parameter p in this)
if (p.Type == type)
return true;
return false;
}
#endregion
#region public ParameterCollection ReplaceAll(Parameter, Parameter)
/// <summary>
/// Replaces all parameters that match the old_param with the new_param.
/// </summary>
/// <param name="old_param"></param>
/// <param name="new_param"></param>
/// <returns></returns>
/// <remarks>The PreviousType property is ignored in parameter matching, and is set to the previous type in case of replacement.</remarks>
public ParameterCollection ReplaceAll(Parameter old_param, Parameter new_param)
{
if (old_param == null || new_param == null)
return null;
ParameterCollection pc = new ParameterCollection(this);
foreach (Parameter p in pc)
{
if (p.Array == old_param.Array &&
p.Flow == old_param.Flow &&
p.Name == old_param.Name &&
//p.PreviousType == old_param.PreviousType &&
p.Type == old_param.Type &&
p.UnmanagedType == old_param.UnmanagedType)
{
p.Array = new_param.Array;
p.Flow = new_param.Flow;
p.Name = new_param.Name;
p.PreviousType = p.Type;
p.Type = new_param.Type;
p.UnmanagedType = new_param.UnmanagedType;
}
}
return pc;
}
#endregion
#region public ParameterCollection Replace(Parameter, Parameter)
/// <summary>
/// Replaces the first parameter that matches old_param with new_param.
/// </summary>
/// <param name="old_param"></param>
/// <param name="new_param"></param>
/// <returns></returns>
/// <remarks>The PreviousType property is ignored in parameter matching, and is set to the previous type in case of replacement.</remarks>
public ParameterCollection Replace(Parameter old_param, Parameter new_param)
{
if (old_param == null || new_param == null)
return null;
ParameterCollection pc = new ParameterCollection(this);
foreach (Parameter p in pc)
{
if (p.Array == old_param.Array &&
p.Flow == old_param.Flow &&
p.Name == old_param.Name &&
//p.PreviousType == old_param.PreviousType &&
p.Type == old_param.Type &&
p.UnmanagedType == old_param.UnmanagedType)
{
p.Array = new_param.Array;
p.Flow = new_param.Flow;
p.Name = new_param.Name;
p.PreviousType = p.Type;
p.Type = new_param.Type;
p.UnmanagedType = new_param.UnmanagedType;
return pc;
}
}
return pc;
}
#endregion
}
#endregion
}

358
Source/Build/Build.cs Normal file
View file

@ -0,0 +1,358 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
#endregion
namespace OpenTK.Build
{
class Project
{
static string RootPath;
static string SourcePath;
static string ToolPath = "Build";
static string PrebuildPath = Path.Combine(ToolPath, "Prebuild.exe");
static string BinPath = "Binaries";
static string ExePath = Path.Combine(BinPath, "Exe");
static string LibPath = Path.Combine(BinPath, "Libraries");
static string ExamplePath = Path.Combine(BinPath, "Examples");
static string PrebuildXml = Path.Combine(ToolPath, "Prebuild.xml");
enum BuildMode
{
Default = 0,
Release = 0,
Debug
}
enum BuildTarget
{
Default = 0,
Net = 0,
Mono,
VS2005,
SharpDevelop,
MonoDevelop,
Clean,
DistClean,
SVNClean
}
static BuildMode mode = BuildMode.Default;
static BuildTarget target = BuildTarget.Default;
static void PrintUsage()
{
Console.WriteLine("Usage: Build.exe BuildMode BuildTarget");
Console.WriteLine("\tBuildMode: debug/release");
Console.WriteLine("\tBuildTarget: mono/net/monodev/sharpdev/vs2005 or clean/distclean/svnclean");
}
static void Main(string[] args)
{
RootPath = Directory.GetCurrentDirectory();
RootPath = RootPath.Substring(
0,
Directory.GetCurrentDirectory().LastIndexOf("Build"));
Directory.SetCurrentDirectory(RootPath);
SourcePath = Path.Combine(RootPath, "Source");
// Workaroung for nant on x64 windows (safe for other platforms too, as this affects
// only the current process).
Environment.SetEnvironmentVariable("CommonProgramFiles(x86)", String.Empty, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("ProgramFiles(x86)", String.Empty, EnvironmentVariableTarget.Process);
if (args.Length == 0)
{
PrintUsage();
}
else
{
foreach (string s in args)
{
string arg = s.ToLower();
switch (arg)
{
case "debug":
case "d":
mode = BuildMode.Debug;
break;
case "release":
case "r":
mode = BuildMode.Release;
break;
case "mono":
target = BuildTarget.Mono;
break;
case "net":
target = BuildTarget.Net;
break;
case "monodev":
case "monodevelop":
case "md":
target = BuildTarget.MonoDevelop;
break;
case "sharpdev":
case "sharpdevelop":
case "sd":
target = BuildTarget.SharpDevelop;
break;
case "vs2005":
case "vs":
target = BuildTarget.VS2005;
break;
case "clean":
target = BuildTarget.Clean;
break;
case "svnclean":
target = BuildTarget.SVNClean;
break;
case "distclean":
target = BuildTarget.DistClean;
break;
default:
Console.WriteLine("Unknown command: {0}", s);
PrintUsage();
return;
}
}
ExePath = Path.Combine(
BinPath,
Path.Combine(mode == BuildMode.Debug ? "Debug" : "Release", "Exe"));
LibPath = Path.Combine(
BinPath,
Path.Combine(mode == BuildMode.Debug ? "Debug" : "Release", "Libraries"));
ExamplePath = Path.Combine(
BinPath,
Path.Combine(mode == BuildMode.Debug ? "Debug" : "Release", "Examples"));
switch (target)
{
case BuildTarget.Mono:
Console.WriteLine("Building OpenTK using Mono.");
ExecuteProcess(PrebuildPath, "/target nant /file " + PrebuildXml);
Console.WriteLine();
ExecuteProcess(
"nant",
"-buildfile:./Build/OpenTK.build -t:mono-2.0 " + (mode == BuildMode.Debug ? "build-debug" : "build-release"));
CopyBinaries();
break;
case BuildTarget.Net:
Console.WriteLine("Building OpenTK using .Net");
ExecuteProcess(PrebuildPath, "/target nant /file " + PrebuildXml);
Console.WriteLine();
ExecuteProcess(
"nant",
"-buildfile:./Build/OpenTK.build -t:net-2.0 " + (mode == BuildMode.Debug ? "build-debug" : "build-release"));
CopyBinaries();
break;
case BuildTarget.MonoDevelop:
Console.WriteLine("Creating MonoDevelop project files");
ExecuteProcess(PrebuildPath, "/target monodev /file " + PrebuildXml);
break;
case BuildTarget.SharpDevelop:
Console.WriteLine("Creating SharpDevelop project files");
ExecuteProcess(PrebuildPath, "/target monodev /file " + PrebuildXml);
break;
case BuildTarget.VS2005:
Console.WriteLine("Creating VS2005 project files");
ExecuteProcess(PrebuildPath, "/target vs2005 /file " + PrebuildXml);
break;
case BuildTarget.Clean:
Console.WriteLine("Cleaning intermediate object files.");
ExecuteProcess(PrebuildPath, "/clean /yes /file " + PrebuildXml);
DeleteDirectories(RootPath, "obj");
break;
case BuildTarget.DistClean:
Console.WriteLine("Cleaning intermediate and final object files.");
ExecuteProcess(PrebuildPath, "/clean /yes /file " + PrebuildXml);
DeleteDirectories(RootPath, "obj");
DeleteDirectories(RootPath, "bin");
if (Directory.Exists(RootPath + "Binaries"))
Directory.Delete(RootPath + "Binaries", true);
break;
case BuildTarget.SVNClean:
Console.WriteLine("Deleting svn directories.");
DeleteDirectories(RootPath, ".svn");
break;
default:
Console.WriteLine("Unknown target: {0}", target);
PrintUsage();
return;
}
//Console.WriteLine("Press any key to continue...");
//Console.ReadKey(true);
}
}
static void DeleteDirectories(string root_path, string search)
{
Console.WriteLine("Deleting {0} directories", search);
List<string> matches = new List<string>();
FindDirectories(root_path, search, matches);
foreach (string m in matches)
{
Directory.Delete(m, true);
}
}
static void CopyBinaries()
{
List<string> example_matches = new List<string>();
List<string> exe_matches = new List<string>();
List<string> dll_matches = new List<string>();
List<string> dll_config_matches = new List<string>();
Directory.CreateDirectory(BinPath);
Directory.CreateDirectory(ExePath);
Directory.CreateDirectory(LibPath);
Directory.CreateDirectory(ExamplePath);
// Move the libraries and the config files.
FindFiles(SourcePath, "*.dll", dll_matches);
foreach (string m in dll_matches)
{
File.Delete(Path.Combine(LibPath, Path.GetFileName(m)));
File.Copy(m, Path.Combine(LibPath, Path.GetFileName(m)));
File.Delete(Path.Combine(ExamplePath, Path.GetFileName(m)));
File.Copy(m, Path.Combine(ExamplePath, Path.GetFileName(m)));
}
FindFiles(SourcePath, "*.dll.config", dll_config_matches);
foreach (string m in dll_config_matches)
{
File.Delete(Path.Combine(LibPath, Path.GetFileName(m)));
File.Copy(m, Path.Combine(LibPath, Path.GetFileName(m)));
File.Delete(Path.Combine(ExamplePath, Path.GetFileName(m)));
File.Copy(m, Path.Combine(ExamplePath, Path.GetFileName(m)));
}
// Then the examples.
FindFiles(Path.Combine(SourcePath, "Examples"), "*.exe", example_matches);
foreach (string m in example_matches)
{
File.Delete(Path.Combine(ExamplePath, Path.GetFileName(m)));
File.Move(m, Path.Combine(ExamplePath, Path.GetFileName(m)));
}
// Then the rest of the exes.
FindFiles(SourcePath, "*.exe", exe_matches);
foreach (string m in exe_matches)
{
File.Delete(Path.Combine(ExePath, Path.GetFileName(m)));
File.Move(m, Path.Combine(ExePath, Path.GetFileName(m)));
}
}
static void FindDirectories(string directory, string search, List<string> matches)
{
try
{
foreach (string d in Directory.GetDirectories(directory))
{
foreach (string f in Directory.GetDirectories(d, search))
{
matches.Add(f);
}
FindDirectories(d, search, matches);
}
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
}
static void FindFiles(string directory, string search, List<string> matches)
{
try
{
foreach (string f in Directory.GetFiles(directory, search, SearchOption.AllDirectories))
{
matches.Add(f);
}
//FindFiles(d, search, matches);
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
}
static void ExecuteProcess(string path, string args)
{
using (Process p = new Process())
{
ProcessStartInfo sinfo = new ProcessStartInfo();
if (Environment.OSVersion.Platform == PlatformID.Unix && !path.ToLower().Contains("nant"))
{
sinfo.FileName = "mono";
sinfo.Arguments = path + " " + args;
}
else
{
sinfo.FileName = path;
sinfo.Arguments = args;
}
sinfo.WorkingDirectory = RootPath;
sinfo.CreateNoWindow = true;
sinfo.RedirectStandardOutput = true;
sinfo.UseShellExecute = false;
p.StartInfo = sinfo;
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
p.Start();
p.BeginOutputReadLine();
//StreamReader sr = p.StandardOutput;
//while (!p.HasExited)
//{
// Console.WriteLine(sr.ReadLine());
// Console.Out.Flush();
//}
p.WaitForExit();
}
}
static void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
if (!String.IsNullOrEmpty(e.Data))
{
// Eat the last \n, we use WriteLine instead. This way we get the same result
// in both windows and linux (linux would interpret both \n and WriteLine).
Console.WriteLine(e.Data.TrimEnd('\n'));
}
}
}
}

View file

@ -0,0 +1,62 @@
namespace Examples
{
partial class ExampleLauncher
{
/// <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.components = new System.ComponentModel.Container();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(284, 264);
this.listBox1.TabIndex = 0;
this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick);
//
// ExampleLauncher
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 264);
this.Controls.Add(this.listBox1);
this.Name = "ExampleLauncher";
this.Text = "OpenTK Example Launcher";
this.Load += new System.EventHandler(this.ExampleLauncher_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox listBox1;
}
}

View file

@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Threading;
using OpenTK;
namespace Examples
{
public partial class ExampleLauncher : Form
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
using (Form exampleLauncher = new ExampleLauncher())
{
Application.EnableVisualStyles();
Application.Run(exampleLauncher);
}
}
public ExampleLauncher()
{
InitializeComponent();
}
private void listBox1_DoubleClick(object sender, EventArgs e)
{
if (listBox1.SelectedItem != null)
{
Type example =
Assembly.GetExecutingAssembly().GetType(
"Examples." + listBox1.SelectedItem.ToString().Replace(": ", ".").Replace(' ', '_'),
true,
true
);
if (example.BaseType == typeof(GameWindow))
{
// Start the GameWindow in a new thread - it runs its own message loop, and it would
// interfere with the message loop of the ExampleLauncher.
new Thread(Launch).Start(example);
}
else if (example.BaseType == typeof(Form))
{
try
{
// In this we do not want a different thread: these examples rely on the Application.Idle
// event, which would then be raised by both the ExampleLauncher thread *and* the new one!
this.AddOwnedForm((Form)example.GetConstructor(Type.EmptyTypes).Invoke(null));
}
catch (Exception expt)
{
MessageBox.Show(
String.Format(
"Stacktrace:{0}{1}{0}{0}Inner exception:{0}{2}",
System.Environment.NewLine,
expt.StackTrace,
expt.InnerException
),
expt.Message
);
}
}
}
}
void Launch(object example)
{
try
{
(example as Type).InvokeMember("Launch", BindingFlags.InvokeMethod, null, null, null);
}
catch (Exception expt)
{
MessageBox.Show(
String.Format(
"Stacktrace:{0}{1}{0}{0}Inner exception:{0}{2}",
System.Environment.NewLine,
expt.StackTrace,
expt.InnerException
),
expt.Message
);
}
}
public void ExampleLauncher_Load(object sender, EventArgs e)
{
SortedList<string, string> sl = new SortedList<string, string>();
// Get all examples
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
foreach (Type type in types)
{
if (type.GetInterface("IExample") != null)
{
sl.Add(
(type.Namespace.Replace("Examples.", String.Empty) + ": " + type.Name).Replace('_', ' '),
null
);
}
}
foreach (string s in sl.Keys)
listBox1.Items.Add(s);
// Select first item
if (listBox1.Items.Count > 0)
{
this.listBox1.SelectedIndex = 0;
}
}
}
}

View file

@ -0,0 +1,126 @@
<?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>
<metadata name="exampleLauncherBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="exampleLauncherBindingSource1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>243, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Examples
{
/// <summary>
/// Examples should implement this (empty) interface, so that the ExampleLauncher
/// can identify them.
/// </summary>
interface IExample
{
}
}

View file

@ -0,0 +1,183 @@
namespace Examples.Windowing
{
partial class W02_Multiple_GLControls
{
/// <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.components = new System.ComponentModel.Container();
this.panel1 = new System.Windows.Forms.Panel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.panel2 = new System.Windows.Forms.Panel();
this.create1 = new System.Windows.Forms.Button();
this.dispose1 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.create2 = new System.Windows.Forms.Button();
this.dispose2 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Location = new System.Drawing.Point(12, 12);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(283, 131);
this.panel1.TabIndex = 0;
//
// timer1
//
this.timer1.Interval = 40;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// panel2
//
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panel2.Location = new System.Drawing.Point(12, 149);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(283, 130);
this.panel2.TabIndex = 0;
//
// create1
//
this.create1.Location = new System.Drawing.Point(6, 19);
this.create1.Name = "create1";
this.create1.Size = new System.Drawing.Size(63, 23);
this.create1.TabIndex = 0;
this.create1.Text = "Create";
this.create1.UseVisualStyleBackColor = true;
this.create1.Click += new System.EventHandler(this.create1_Click);
//
// dispose1
//
this.dispose1.Enabled = false;
this.dispose1.Location = new System.Drawing.Point(6, 48);
this.dispose1.Name = "dispose1";
this.dispose1.Size = new System.Drawing.Size(63, 23);
this.dispose1.TabIndex = 0;
this.dispose1.Text = "Dispose";
this.dispose1.UseVisualStyleBackColor = true;
this.dispose1.Click += new System.EventHandler(this.dispose1_Click);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.create1);
this.groupBox1.Controls.Add(this.dispose1);
this.groupBox1.Location = new System.Drawing.Point(301, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(75, 77);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Context";
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.create2);
this.groupBox2.Controls.Add(this.dispose2);
this.groupBox2.Location = new System.Drawing.Point(301, 149);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(75, 77);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Context";
//
// create2
//
this.create2.Location = new System.Drawing.Point(6, 19);
this.create2.Name = "create2";
this.create2.Size = new System.Drawing.Size(63, 23);
this.create2.TabIndex = 0;
this.create2.Text = "Create";
this.create2.UseVisualStyleBackColor = true;
this.create2.Click += new System.EventHandler(this.create2_Click);
//
// dispose2
//
this.dispose2.Enabled = false;
this.dispose2.Location = new System.Drawing.Point(6, 48);
this.dispose2.Name = "dispose2";
this.dispose2.Size = new System.Drawing.Size(63, 23);
this.dispose2.TabIndex = 0;
this.dispose2.Text = "Dispose";
this.dispose2.UseVisualStyleBackColor = true;
this.dispose2.Click += new System.EventHandler(this.dispose2_Click);
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 287);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(210, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Press F1 to toggle FullScreen / Windowed.";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(388, 310);
this.Controls.Add(this.label1);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.KeyPreview = true;
this.Name = "Form1";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.Text = "Form1";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button create1;
private System.Windows.Forms.Button dispose1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button create2;
private System.Windows.Forms.Button dispose2;
private System.Windows.Forms.Label label1;
}
}

View file

@ -0,0 +1,264 @@
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenTK.OpenGL;
using Enums = OpenTK.OpenGL.Enums;
using OpenTK;
using OpenTK.Platform;
#endregion
namespace Examples.Windowing
{
public partial class W02_Multiple_GLControls : Form
{
OpenTK.GLControl glWindow1, glWindow2;
public W02_Multiple_GLControls()
{
InitializeComponent();
timer1.Enabled = true;
throw new NotImplementedException();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
if (glWindow1 != null)
glWindow1.Dispose();
if (glWindow2 != null)
glWindow2.Dispose();
}
static float angle;
#region Load event handler
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
OnResize(e);
}
#endregion
int count;
private void timer1_Tick(object sender, EventArgs e)
{
PaintGLScene();
count++;
if (count == 20)
create1_Click(null, EventArgs.Empty);
if (glWindow1 == null)
return;
//if (count == 60)
// ToggleFullScreen();
if (glWindow1.Fullscreen)
{
this.Location = new Point(this.Location.X + (int)(Math.Sin(count / (5 * Math.PI)) * 3),
this.Location.Y);
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
PaintGLScene();
}
private void PaintGLScene()
{
RenderToContext(glWindow1, 0);
RenderToContext(glWindow2, 45);
}
private void RenderToContext(OpenTK.GLControl glWindow, float angle_add)
{
glWindow.Context.MakeCurrent();
GL.ClearColor(0.1f, 0.1f, 0.5f, 0.0f);
GL.Enable(Enums.EnableCap.DEPTH_TEST);
GL.Viewport(0, 0, glWindow.Width, glWindow.Height);
double ratio = 0.0;
ratio = glWindow.Width / (double)glWindow.Height;
GL.MatrixMode(Enums.MatrixMode.PROJECTION);
GL.LoadIdentity();
Glu.Perspective(45.0, ratio, 1.0, 64.0);
GL.MatrixMode(Enums.MatrixMode.MODELVIEW);
GL.LoadIdentity();
Glu.LookAt(
0.0, 5.0, 5.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
);
GL.Rotatef(angle + angle_add, 0.0f, 1.0f, 0.0f);
angle += 0.5f;
GL.Clear(Enums.ClearBufferMask.COLOR_BUFFER_BIT | Enums.ClearBufferMask.DEPTH_BUFFER_BIT);
DrawCube();
glWindow.Context.SwapBuffers();
}
#region KeyDown event handler
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
switch (e.KeyData)
{
case Keys.Escape:
Application.Exit();
break;
case Keys.F1:
//this.SetResolution(this.Width, this.Height, this.ColorDepth, !this.Fullscreen);
break;
}
}
#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
private void create1_Click(object sender, EventArgs e)
{
glWindow1 = new OpenTK.GLControl();
create1.Enabled = false;
dispose1.Enabled = true;
Text =
GL.GetString(Enums.StringName.VENDOR) + " " +
GL.GetString(Enums.StringName.RENDERER) + " " +
GL.GetString(Enums.StringName.VERSION);
}
private void create2_Click(object sender, EventArgs e)
{
//glWindow2 = GLContext.Create(panel2, new OpenTK.OpenGL.ColorDepth(8, 8, 8, 8), 8, 0);
glWindow2 = new GLControl(
new DisplayMode(0, 0, new OpenTK.Platform.ColorDepth(32), 16, 0, 0, 2, false, false, false, 0.0f));
create2.Enabled = false;
dispose2.Enabled = true;
}
private void dispose1_Click(object sender, EventArgs e)
{
glWindow1.Dispose();
glWindow1 = null;
panel1.Invalidate();
create1.Enabled = true;
dispose1.Enabled = false;
}
private void dispose2_Click(object sender, EventArgs e)
{
glWindow2.Dispose();
glWindow2 = null;
panel2.Invalidate();
create2.Enabled = true;
dispose2.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
this.BringToFront();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (glWindow1 == null)
return;
if (e.KeyCode == Keys.F1)
{
ToggleFullScreen();
}
}
private void ToggleFullScreen()
{
glWindow1.Fullscreen = !glWindow1.Fullscreen;
/*
if (glWindow1.Fullscreen)
glWindow1.SetWindowed();
else
{
glWindow1.SetFullScreen(640, 480, new OpenTK.OpenGL.ColorDepth(8, 8, 8, 8));
}
*/
}
}
}

View file

@ -0,0 +1,123 @@
<?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>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,60 @@
namespace Examples.Windowing
{
partial class W01_DisplayModesForm
{
/// <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.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(292, 264);
this.listBox1.TabIndex = 0;
//
// DisplayModes
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.listBox1);
this.Name = "DisplayModes";
this.Text = "Query Display Modes";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox listBox1;
}
}

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Platform;
namespace Examples.Windowing
{
public partial class W01_DisplayModesForm : Form
{
OpenTK.Platform.IGLControl glWindow;
public W01_DisplayModesForm()
{
InitializeComponent();
glWindow = new GLControl();
IEnumerable<DisplayMode> modes = glWindow.Context.GetDisplayModes();
foreach (DisplayMode m in modes)
{
listBox1.Items.Add(m);
}
}
}
}

View file

@ -0,0 +1,120 @@
<?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

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace QueryDisplayModes
{
static class Program
{
}
}

View file

@ -0,0 +1,187 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using OpenTK;
using OpenTK.OpenGL;
using OpenTK.Platform;
using Enums = OpenTK.OpenGL.Enums;
using OpenTK.Input;
#endregion
namespace Examples.Tutorial
{
public class T03_RotatingCube : OpenTK.GameWindow, IExample
{
#region --- Fields ---
/// <summary>
/// Denotes the cube rotation.
/// </summary>
float angle = 0.0f;
#endregion
#region --- Constructors ---
public T03_RotatingCube()
{
Context.MakeCurrent();
GL.ClearColor(0.1f, 0.1f, 0.5f, 0.0f);
GL.Enable(Enums.EnableCap.DEPTH_TEST);
this.OnResize(new ResizeEventArgs(this.Width, this.Height));
}
#endregion
#region Resize event handler
/// <summary>
/// Called when the user resizes the window.
/// </summary>
/// <param name="e">Contains the new width/height of the window.</param>
/// <remarks>
/// You want the OpenGL viewport to match the window. This is the place to do it!
/// </remarks>
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, e.Width, e.Height);
double ratio = e.Width / (double)e.Height;
GL.MatrixMode(Enums.MatrixMode.PROJECTION);
GL.LoadIdentity();
Glu.Perspective(45.0, ratio, 1.0, 64.0);
}
#endregion
#region UpdateFrame function
/// <summary>
/// Prepares the next frame for rendering.
/// </summary>
/// <remarks>
/// Place your control logic here. This is the place to respond to user input,
/// update object positions etc.
/// </remarks>
public override void UpdateFrame()
{
if (Key.Escape)
{
Quit = true;
return;
}
GL.MatrixMode(Enums.MatrixMode.MODELVIEW);
GL.LoadIdentity();
Glu.LookAt(
0.0, 5.0, 5.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
);
GL.Rotatef(angle, 0.0f, 1.0f, 0.0f);
angle += 0.5f;
}
#endregion
#region RenderFrame function
/// <summary>
/// Place your rendering code here.
/// </summary>
public override void RenderFrame()
{
GL.Clear(Enums.ClearBufferMask.COLOR_BUFFER_BIT | Enums.ClearBufferMask.DEPTH_BUFFER_BIT);
DrawCube();
Context.SwapBuffers();
}
#endregion
#region DrawCube function
/// <summary>
/// Draws simple, colored cube.
/// </summary>
protected 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 static public void Launch()
/// <summary>
/// Launches this example.
/// </summary>
/// <remarks>
/// Provides a simple way for the example launcher to launch the examples.
/// </remarks>
static public void Launch()
{
using (T03_RotatingCube ex = new T03_RotatingCube())
{
ex.Run();
}
}
#endregion
}
}

View file

@ -0,0 +1,170 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#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;
using Enums = OpenTK.OpenGL.Enums;
using OpenTK;
using OpenTK.Input;
#endregion --- Using Directives ---
namespace Examples.Tutorial
{
public partial class T07_DisplayLists_Cube : GameWindow, IExample
{
#region --- Variables ---
List<DisplayList> lists = new List<DisplayList>();
#endregion --- Variables ---
#region --- Constructors ---
public T07_DisplayLists_Cube()
{
//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(new OpenTK.Platform.ResizeEventArgs(this.Width, this.Height));
}
#endregion
#region static public void Launch()
/// <summary>
/// Launches this example.
/// </summary>
/// <remarks>
/// Provides a simple way for the example launcher to launch the examples.
/// </remarks>
static public void Launch()
{
using (T03_RotatingCube ex = new T03_RotatingCube())
{
ex.Run();
}
}
#endregion
#region --- Event Handlers ---
#region OnResize
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, this.Width, this.Height);
double ratio = 0.0;
ratio = this.Width / (double)this.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 RenderFrame
public override void RenderFrame()
{
base.RenderFrame();
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;
}
Context.SwapBuffers();
}
#endregion
#region UpdateFrame
public override void UpdateFrame()
{
base.UpdateFrame();
if (Key.Escape)
{
this.Quit = true;
}
}
#endregion
#endregion --- Event Handlers ---
}
}

View file

@ -0,0 +1,235 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
#region --- Using directives ---
using System;
using System.Collections.Generic;
using System.Text;
using OpenTK;
using OpenTK.OpenGL;
using OpenTK.Input;
using OpenTK.Platform;
#endregion
namespace Examples.Tutorial
{
public class T08_VBO : OpenTK.GameWindow, IExample
{
#region --- Private Fields ---
int vbo, ibo, nbo; // vertex, index and normal buffer objects.
float angle;
// Cube vertices
float[] vdata =
{
-1.0f, -1.0f, 1.0f ,
1.0f, -1.0f, 1.0f ,
1.0f, 1.0f, 1.0f ,
-1.0f, 1.0f, 1.0f ,
-1.0f, -1.0f, -1.0f ,
1.0f, -1.0f, -1.0f ,
1.0f, 1.0f, -1.0f ,
-1.0f, 1.0f, -1.0f ,
};
// Cube normals
float[,] ndata =
{
{ 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f },
{ -1.0f, 0.0f, 0.0f },
{ 0.0f, -1.0f, 0.0f },
{ 0.0f, 0.0f, -1.0f },
};
// Indices
ushort[] idata =
{
// front face
0, 1, 2, 3,
// top face
3, 4, 6, 7,
// back face
7, 6, 5, 4,
// left face
4, 0, 3, 7,
// bottom face
0, 1, 5, 4,
// right face
1, 5, 6, 2,
};
#endregion
#region --- Constructor ---
public T08_VBO()
{
this.Context.MakeCurrent();
GL.ClearColor(0.1f, 0.1f, 0.5f, 0.0f);
GL.Enable(OpenTK.OpenGL.Enums.EnableCap.DEPTH_TEST);
GL.EnableClientState(OpenTK.OpenGL.Enums.EnableCap.VERTEX_ARRAY);
GL.EnableClientState(OpenTK.OpenGL.Enums.EnableCap.INDEX_ARRAY);
//GL.Enable(OpenTK.OpenGL.Enums.EnableCap.VERTEX_ARRAY);
//GL.Enable(OpenTK.OpenGL.Enums.EnableCap.INDEX_ARRAY);
LoadCube();
this.OnResize(new ResizeEventArgs(this.Width, this.Height));
}
#endregion
#region RenderFrame
public override void RenderFrame()
{
base.RenderFrame();
GL.Clear(
OpenTK.OpenGL.Enums.ClearBufferMask.COLOR_BUFFER_BIT |
OpenTK.OpenGL.Enums.ClearBufferMask.DEPTH_BUFFER_BIT);
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, vbo);
GL.VertexPointer(3, OpenTK.OpenGL.Enums.VertexPointerType.FLOAT, 0, 0);
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo);
GL.IndexPointer(OpenTK.OpenGL.Enums.IndexPointerType.FLOAT, 0, 0);
GL.Color3f(1.0f, 1.0f, 1.0f);
GL.DrawElements(
OpenTK.OpenGL.Enums.BeginMode.QUADS,
idata.Length,
OpenTK.OpenGL.Enums.GLenum.UNSIGNED_SHORT,
idata);
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, 0);
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, 0);
Context.SwapBuffers();
}
#endregion
#region UpdateFrame
/// <summary>
/// Prepares the next frame for rendering.
/// </summary>
/// <remarks>
/// Place your control logic here. This is the place to respond to user input,
/// update object positions etc.
/// </remarks>
public override void UpdateFrame()
{
if (Key.Escape)
{
Quit = true;
return;
}
GL.MatrixMode(OpenTK.OpenGL.Enums.MatrixMode.MODELVIEW);
GL.LoadIdentity();
Glu.LookAt(
0.0, 5.0, 5.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
);
//GL.Rotatef(angle, 0.0f, 1.0f, 0.0f);
//angle += 0.5f;
}
#endregion
#region Resize event
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, e.Width, e.Height);
double ratio = e.Width / (double)e.Height;
GL.MatrixMode(OpenTK.OpenGL.Enums.MatrixMode.PROJECTION);
GL.LoadIdentity();
Glu.Perspective(45.0, ratio, 1.0, 64.0);
}
#endregion
#region LoadCube
private void LoadCube()
{
int size; // To check whether the buffers were uploaded correctly.
// First, generate the buffer objects
GL.GenBuffers(1, out vbo);
GL.GenBuffers(1, out ibo);
// Upload the vertex data
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER, vbo);
GL.BufferData(
OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER,
(IntPtr)(vdata.Length * 4),
vdata,
OpenTK.OpenGL.Enums.VERSION_1_5.STATIC_DRAW);
GL.GetBufferParameteriv(
OpenTK.OpenGL.Enums.VERSION_1_5.ARRAY_BUFFER,
OpenTK.OpenGL.Enums.VERSION_1_5.BUFFER_SIZE,
out size);
if (vdata.Length * 4 != size)
{
throw new ApplicationException("Vertex array not uploaded correctly");
}
// Upload the index data
GL.BindBuffer(OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER, ibo);
GL.BufferData(
OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER,
(IntPtr)(idata.Length * 2),
idata,
OpenTK.OpenGL.Enums.VERSION_1_5.STATIC_DRAW
);
GL.GetBufferParameteriv(
OpenTK.OpenGL.Enums.VERSION_1_5.ELEMENT_ARRAY_BUFFER,
OpenTK.OpenGL.Enums.VERSION_1_5.BUFFER_SIZE,
out size);
if (idata.Length * 2 != size)
{
throw new ApplicationException("Index array not uploaded correctly");
}
}
#endregion
#region static public void Launch()
/// <summary>
/// Launches this example.
/// </summary>
/// <remarks>
/// Provides a simple way for the example launcher to launch the examples.
/// </remarks>
static public void Launch()
{
using (T08_VBO ex = new T08_VBO())
{
ex.Run();
}
}
#endregion
}
}

View file

@ -0,0 +1,228 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using OpenTK.OpenGL;
using Enums = OpenTK.OpenGL.Enums;
using OpenTK;
using OpenTK.Input;
#endregion --- Using Directives ---
namespace Examples.Tutorial
{
public class T10_GLSL_Cube : GameWindow, IExample
{
#region --- Fields ---
#region Shaders
string[] vertex_shader_source =
{
"void main() {",
"gl_FrontColor = gl_Color;",
"gl_Position = ftransform();",
"}",
};
string[] fragment_shader_source =
{
"void main() { gl_FragColor = gl_Color; }\0"
};
#endregion
static float angle;
#endregion
#region --- Constructors ---
public T10_GLSL_Cube()
{
Context.MakeCurrent();
//Text =
// GL.GetString(Enums.StringName.VENDOR) + " " +
// 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);
int vertex_shader_object, fragment_shader_object;
int status;
int shader_program;
vertex_shader_object = GL.CreateShader(Enums.VERSION_2_0.VERTEX_SHADER);
fragment_shader_object = GL.CreateShader(Enums.VERSION_2_0.FRAGMENT_SHADER);
GL.ShaderSource(vertex_shader_object, vertex_shader_source.Length, vertex_shader_source, null);
GL.CompileShader(vertex_shader_object);
GL.GetShaderiv(vertex_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
if (status != (int)Enums.Boolean.TRUE)
{
StringBuilder info = new StringBuilder(1024);
GL.GetShaderInfoLog(vertex_shader_object, info.MaxCapacity, null, info);
throw new Exception(info.ToString());
}
GL.ShaderSource(fragment_shader_object, fragment_shader_source.Length, fragment_shader_source, null);
GL.CompileShader(fragment_shader_object);
GL.GetShaderiv(fragment_shader_object, Enums.VERSION_2_0.COMPILE_STATUS, out status);
if (status != (int)Enums.Boolean.TRUE)
{
StringBuilder info = new StringBuilder(1024);
GL.GetShaderInfoLog(fragment_shader_object, 1024, null, info);
throw new Exception(info.ToString());
}
shader_program = GL.CreateProgram();
GL.AttachShader(shader_program, fragment_shader_object);
GL.AttachShader(shader_program, vertex_shader_object);
GL.LinkProgram(shader_program);
GL.UseProgram(shader_program);
OnResize(new OpenTK.Platform.ResizeEventArgs(this.Width, this.Height));
}
#endregion
#region static public void Launch()
/// <summary>
/// Launches this example.
/// </summary>
/// <remarks>
/// Provides a simple way for the example launcher to launch the examples.
/// </remarks>
static public void Launch()
{
using (T10_GLSL_Cube ex = new T10_GLSL_Cube())
{
ex.Run();
}
}
#endregion
#region OnResize
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, this.Width, this.Height);
double ratio = 0.0;
ratio = this.Width / (double)this.Height;
GL.MatrixMode(Enums.MatrixMode.PROJECTION);
GL.LoadIdentity();
Glu.Perspective(45.0, ratio, 1.0, 64.0);
}
#endregion
#region UpdateFrame
public override void UpdateFrame()
{
base.UpdateFrame();
if (Key.Escape)
{
this.Quit = true;
}
GL.MatrixMode(Enums.MatrixMode.MODELVIEW);
GL.LoadIdentity();
Glu.LookAt(
0.0, 5.0, 5.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
);
GL.Rotatef(angle, 0.0f, 1.0f, 0.0f);
angle += 0.05f;
}
#endregion
#region RenderFrame
public override void RenderFrame()
{
base.RenderFrame();
GL.Clear(Enums.ClearBufferMask.COLOR_BUFFER_BIT | Enums.ClearBufferMask.DEPTH_BUFFER_BIT);
DrawCube();
Context.SwapBuffers();
}
#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
}
}

View file

@ -0,0 +1,60 @@
namespace Examples.WinForms
{
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.glControl = new OpenTK.GLControl();
this.SuspendLayout();
//
// glControl
//
this.glControl.BackColor = System.Drawing.Color.MidnightBlue;
this.glControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.glControl.Fullscreen = false;
this.glControl.Location = new System.Drawing.Point(0, 0);
this.glControl.Name = "glControl";
this.glControl.Size = new System.Drawing.Size(624, 444);
this.glControl.TabIndex = 0;
//
// Cube
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(624, 444);
this.Controls.Add(this.glControl);
this.Name = "Cube";
this.Text = "Cube";
this.ResumeLayout(false);
}
#endregion
private OpenTK.GLControl glControl;
}
}

View file

@ -0,0 +1,210 @@
#region --- License ---
/* This source file is released under the MIT license. See License.txt for more information.
* Coded by Erik Ylvisaker and Stefanos 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;
using Enums = OpenTK.OpenGL.Enums;
using OpenTK.Platform;
#endregion
namespace Examples.WinForms
{
public partial class Cube : Form, IExample
{
static float angle;
#region --- Constructor ---
public Cube()
{
InitializeComponent();
Application.Idle += Application_Idle;
this.ShowDialog();
}
#endregion
#region Closing event
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
Application.Idle -= Application_Idle;
}
#endregion
#region Application_Idle event
void Application_Idle(object sender, EventArgs e)
{
while (glControl.IsIdle)
{
Render();
}
}
#endregion
#region private void Render()
private void Render()
{
GL.MatrixMode(Enums.MatrixMode.MODELVIEW);
GL.LoadIdentity();
Glu.LookAt(
0.0, 5.0, 5.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0
);
GL.Rotatef(angle, 0.0f, 1.0f, 0.0f);
angle += 0.5f;
GL.Clear(Enums.ClearBufferMask.COLOR_BUFFER_BIT | Enums.ClearBufferMask.DEPTH_BUFFER_BIT);
DrawCube();
glControl.Context.SwapBuffers();
}
#endregion
#region Load event handler
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Text =
GL.GetString(Enums.StringName.VENDOR) + " " +
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);
glControl.KeyDown += new KeyEventHandler(Cube_KeyDown);
OnResize(e);
}
#endregion
#region Resize event handler
protected override void OnResize(EventArgs e)
{
base.OnResize(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;
//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
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Render();
}
#endregion
#region KeyDown event handler
void Cube_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.Shift)
{
//this.SetResolution(this.Width, this.Height, this.ColorDepth, !this.IsFullscreen);
glControl.Fullscreen = !glControl.Fullscreen;
}
switch (e.KeyData)
{
case Keys.Escape:
this.Close();
break;
}
}
#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
}
}

View file

@ -0,0 +1,120 @@
<?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

@ -0,0 +1,107 @@
namespace Examples.WinForms
{
partial class W01_First_Window
{
/// <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.glControl1 = new OpenTK.GLControl();
this.redButton = new System.Windows.Forms.Button();
this.greenButton = new System.Windows.Forms.Button();
this.blueButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// glControl1
//
this.glControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.glControl1.BackColor = System.Drawing.SystemColors.ControlDarkDark;
this.glControl1.Fullscreen = false;
this.glControl1.Location = new System.Drawing.Point(1, 0);
this.glControl1.Name = "glControl1";
this.glControl1.Size = new System.Drawing.Size(629, 565);
this.glControl1.TabIndex = 0;
this.glControl1.Resize += new OpenTK.Platform.ResizeEvent(this.glControl1_Resize);
this.glControl1.Paint += new System.Windows.Forms.PaintEventHandler(this.glControl1_Paint);
this.glControl1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.glControl1_KeyDown);
//
// redButton
//
this.redButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.redButton.Location = new System.Drawing.Point(639, 13);
this.redButton.Name = "redButton";
this.redButton.Size = new System.Drawing.Size(133, 23);
this.redButton.TabIndex = 1;
this.redButton.Text = "Red";
this.redButton.UseVisualStyleBackColor = true;
this.redButton.Click += new System.EventHandler(this.redButton_Click);
//
// greenButton
//
this.greenButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.greenButton.Location = new System.Drawing.Point(639, 43);
this.greenButton.Name = "greenButton";
this.greenButton.Size = new System.Drawing.Size(133, 23);
this.greenButton.TabIndex = 2;
this.greenButton.Text = "Green";
this.greenButton.UseVisualStyleBackColor = true;
this.greenButton.Click += new System.EventHandler(this.greenButton_Click);
//
// blueButton
//
this.blueButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.blueButton.Location = new System.Drawing.Point(639, 73);
this.blueButton.Name = "blueButton";
this.blueButton.Size = new System.Drawing.Size(133, 23);
this.blueButton.TabIndex = 3;
this.blueButton.Text = "Blue";
this.blueButton.UseVisualStyleBackColor = true;
this.blueButton.Click += new System.EventHandler(this.blueButton_Click);
//
// W01_First_Window
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(781, 564);
this.Controls.Add(this.blueButton);
this.Controls.Add(this.greenButton);
this.Controls.Add(this.redButton);
this.Controls.Add(this.glControl1);
this.Name = "W01_First_Window";
this.Text = "OpenTK Windows Forms Tutorial 01 - Your first window";
this.ResumeLayout(false);
}
#endregion
private OpenTK.GLControl glControl1;
private System.Windows.Forms.Button redButton;
private System.Windows.Forms.Button greenButton;
private System.Windows.Forms.Button blueButton;
}
}

View file

@ -0,0 +1,75 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#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;
using OpenTK.OpenGL;
#endregion
namespace Examples.WinForms
{
public partial class W01_First_Window : Form, IExample
{
public W01_First_Window()
{
InitializeComponent();
this.ShowDialog();
}
private void redButton_Click(object sender, EventArgs e)
{
GL.ClearColor(0.7f, 0.0f, 0.0f, 0.0f);
glControl1.Invalidate();
}
private void greenButton_Click(object sender, EventArgs e)
{
GL.ClearColor(0.0f, 0.5f, 0.0f, 0.0f);
glControl1.Invalidate();
}
private void blueButton_Click(object sender, EventArgs e)
{
GL.ClearColor(0.0f, 0.0f, 0.7f, 0.0f);
glControl1.Invalidate();
}
private void glControl1_Paint(object sender, PaintEventArgs e)
{
GL.Clear(OpenTK.OpenGL.Enums.ClearBufferMask.COLOR_BUFFER_BIT);
glControl1.Context.SwapBuffers();
}
private void glControl1_Resize(object sender, OpenTK.Platform.ResizeEventArgs e)
{
if (glControl1.ClientSize.Height == 0)
glControl1.ClientSize = new System.Drawing.Size(glControl1.ClientSize.Width, 1);
GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
}
private void glControl1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.Escape:
this.Close();
break;
}
}
}
}

View file

@ -0,0 +1,120 @@
<?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>

39
Source/OpenTK/GLControl.Designer.cs generated Normal file
View file

@ -0,0 +1,39 @@
using System;
namespace OpenTK
{
partial class GLControl
{
/// <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 Component 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()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

296
Source/OpenTK/GLControl.cs Normal file
View file

@ -0,0 +1,296 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using OpenTK.Platform;
#endregion
namespace OpenTK
{
// TODO: Document the GLControl class.
/// <summary>
///
/// </summary>
public partial class GLControl : UserControl, IGLControl
{
#region --- Private Fields ---
private bool fullscreen;
private IGLControl glControl;
#endregion
#region --- Contructors ---
/// <summary>
/// Constructs a new GLControl.
/// </summary>
public GLControl()
:this(new DisplayMode())
{
}
public GLControl(DisplayMode mode)
{
InitializeComponent();
System.Diagnostics.Debug.Listeners.Clear();
System.Diagnostics.Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
System.Diagnostics.Debug.AutoFlush = true;
System.Diagnostics.Trace.Listeners.Clear();
System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
System.Diagnostics.Trace.AutoFlush = true;
Trace.AutoFlush = true;
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
Environment.OSVersion.Platform == PlatformID.Win32Windows)
{
glControl = new OpenTK.Platform.Windows.WinGLControl(this, Width, Height, false);
}
else if (Environment.OSVersion.Platform == PlatformID.Unix ||
Environment.OSVersion.Platform == (PlatformID)128)
// some older versions of Mono reported 128.
{
glControl = new OpenTK.Platform.X11.X11GLControl(this, Width, Height, false);
}
else
{
throw new PlatformNotSupportedException(
"Your operating system is not currently supported. We are sorry for the inconvenience."
);
}
glControl.Context.MakeCurrent();
/*
Context.MakeCurrent();
//GL.ReloadFunctions();
if (width > 0)
this.Width = width;
if (height > 0)
this.Height = height;
*/
if (fullscreen)
this.Fullscreen = true;
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
#endregion
#region --- Public Methods ---
/// <summary>
/// Swaps the front and back buffers, and presents the rendered scene to the screen.
/// </summary>
public void SwapBuffers()
{
Context.SwapBuffers();
}
/// <summary>
/// Makes the underlying GLContext of this GLControl current. All OpenGL commands issued
/// from this point are interpreted by this GLContext.
/// </summary>
public void MakeCurrent()
{
Context.MakeCurrent();
}
#endregion
#region --- Public Properties ---
/// <summary>
/// Gets the AspectRatio of the control this GLContext object
/// renders to. This is usually used in a call to Glu.Perspective.
/// </summary>
public double AspectRatio
{
get
{
return this.Width / (double)this.Height;
}
}
/// <summary>
/// Gets or sets the display mode of the control.
/// </summary>
public bool Fullscreen
{
get
{
return fullscreen;
}
set
{
if (!fullscreen && value)
{
//fullscreen = this.SetFullscreenResolution(this.Width, this.Height);
}
else if (fullscreen && !value)
{
}
}
}
#endregion
#region --- IGLControl Members ---
public event CreateEvent Create;
#region public bool IsIdle
/// <summary>
/// Gets the idle status of the control.
/// </summary>
public bool IsIdle
{
get { return glControl.IsIdle; }
}
#endregion
#region public IGLContext Context
/// <summary>
/// Gets the opengl context associated with this control.
/// </summary>
public IGLContext Context
{
get { return glControl.Context; }
}
#endregion
#region DisplayMode changes
/// <summary>
/// Selects the fullscreen DisplayMode closest to the DisplayMode requested.
/// </summary>
/// <param name="mode">
/// The fullscreen DisplayMode to match, or null to get the current screen DisplayMode.
/// </param>
/// <returns>The DisplayMode closest to the requested one, or null if no DisplayModes are available.</returns>
/// <remarks>
/// <see cref="SetDisplayMode">SetDisplayMode</see>
/// </remarks>
public DisplayMode SelectDisplayMode(DisplayMode mode)
{
throw new NotImplementedException();
//return glWindow.SelectDisplayMode(mode);
}
/// <summary>
/// Selects the fullscreen DisplayMode closest to the DisplayMode requested, accoriding to the specified
/// parameters.
/// </summary>
/// <param name="mode">
/// The fullscreen DisplayMode to match, or null to get the current screen DisplayMode.
/// </param>
/// <param name="options">
/// The DisplayModeMatchOptions flags that indicate how to search for the requested DisplayMode.
/// </param>
/// <returns>
/// The DisplayMode closest to the requested one, or null if no DisplayModes are available or
/// DisplayModeMatchOptions.ExactMatch was passed.
/// </returns>
/// <remarks>
/// <see cref="SetDisplayMode">SetDisplayMode</see>
/// </remarks>
public DisplayMode SelectDisplayMode(DisplayMode mode, DisplayModeMatchOptions options)
{
throw new NotImplementedException();
//return glWindow.SelectDisplayMode(mode, options);
}
/// <summary>
/// Sets the requested DisplayMode.
/// </summary>
/// <param name="mode">
/// The fulscreen DisplayMode to set. Passing null will return the application to windowed
/// mode.
/// </param>
/// <remarks>
/// Use SelectDisplayMode to select one of the available fullscreen modes.
/// <para>
/// If the mode requested is not available, this function will throw a
/// <exception cref="DisplayModeNotAvailable">DisplayModeNotAvailable</exception> exception.
/// </para>
/// <para>
/// Pass null to return to windowed mode. The previous desktop DisplayMode will be automatically reset by this
/// function. This function cannot be used to permanently change the user's desktop DisplayMode.
/// </para>
/// <see cref="SelectDisplayMode(DisplayMode mode)">SelectDisplayMode</see>
/// <seealso cref="DisplayModeNotAvailable">DisplayModeNotAvailable exception</seealso>
/// </remarks>
public void SetDisplayMode(DisplayMode mode)
{
throw new NotImplementedException();
//glWindow.SetDisplayMode(mode);
}
#endregion
public void ProcessEvents()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
#region --- IResizable Members ---
public new event ResizeEvent Resize;
#endregion
#region --- IDisposable Members ---
protected override void DestroyHandle()
{
base.DestroyHandle();
glControl.Dispose();
}
/*
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool manuallyCalled)
{
if (manuallyCalled)
{
glWindow.Dispose();
}
}
~GLControl()
{
this.Dispose(false);
}
*/
#endregion
}
}

263
Source/OpenTK/GameWindow.cs Normal file
View file

@ -0,0 +1,263 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using OpenTK.Platform;
using System.Diagnostics;
namespace OpenTK
{
public class GameWindow : OpenTK.Platform.IGLControl, OpenTK.Platform.IGameWindow
{
INativeWindow glWindow;
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
#region --- Contructors ---
/// <summary>
/// Constructs a new GameWindow, using a safe DisplayMode.
/// </summary>
public GameWindow()
{
System.Diagnostics.Debug.Listeners.Clear();
System.Diagnostics.Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
System.Diagnostics.Debug.AutoFlush = true;
System.Diagnostics.Trace.Listeners.Clear();
System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
System.Diagnostics.Trace.AutoFlush = true;
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
Environment.OSVersion.Platform == PlatformID.Win32Windows)
{
// Create a new Windows native window. We want to be notified when it's ready,
// in order to do some preparatory work.
glWindow = new OpenTK.Platform.Windows.WinGLNative();
}
else if (Environment.OSVersion.Platform == PlatformID.Unix ||
Environment.OSVersion.Platform == (PlatformID)128) // some older versions of Mono reported 128.
{
glWindow = new OpenTK.Platform.X11.X11GLNative();
}
else
{
throw new PlatformNotSupportedException(
"Your operating system is not currently supported. We are sorry for the inconvenience."
);
}
glWindow.Context.MakeCurrent();
// When the glWindow construction is complete, hook the resize events.
resizeEventArgs.Width = this.Width;
resizeEventArgs.Height = this.Height;
glWindow.Resize += new ResizeEvent(glWindow_Resize);
glWindow.Create += new CreateEvent(glWindow_Create);
}
void glWindow_Create(object sender, EventArgs e)
{
this.OnCreate(e);
}
void glWindow_Resize(object sender, ResizeEventArgs e)
{
this.OnResize(e);
}
#endregion
#region --- IGLWindow Members ---
#region public bool IsIdle
public bool IsIdle
{
get { return glWindow.IsIdle; }
}
#endregion
#region public bool Fullscreen
public bool Fullscreen
{
get { return glWindow.Fullscreen; }
set { glWindow.Fullscreen = value; }
}
#endregion
#region public OpenTK.Platform.IGLContext Context
public OpenTK.Platform.IGLContext Context
{
get { return glWindow.Context; }
}
#endregion
#region public bool Quit
public bool Quit
{
get { return glWindow.Quit; }
set { glWindow.Quit = value; }
}
#endregion
#endregion
#region --- IGameWindow Members ---
/// <summary>
/// Runs a default game loop on the GameWindow.
/// </summary>
/// <remarks>
/// <para>
/// A default game loop consists of three parts: Event processing,
/// a frame update and a frame render.
/// </para>
/// <para>
/// Override this function if you want to change the behaviour of the
/// default game loop. If you override this function, you must place
/// a call to the ProcessEvents function, so that your window will respond
/// to Operating System events.
/// </para>
/// </remarks>
public virtual void Run()
{
while (!this.Quit)
{
this.ProcessEvents();
this.UpdateFrame();
this.RenderFrame();
}
}
public void ProcessEvents()
{
glWindow.ProcessEvents();
}
#region public event CreateEvent Create;
public event CreateEvent Create;
private void OnCreate(EventArgs e)
{
if (this.Create != null)
{
this.Create(this, e);
}
}
#endregion
public virtual void RenderFrame()
{
if (RenderFrameNotify != null)
RenderFrameNotify(EventArgs.Empty);
}
public virtual void UpdateFrame()
{
if (UpdateFrameNotify != null)
UpdateFrameNotify(EventArgs.Empty);
}
public event UpdateFrameEvent UpdateFrameNotify;
public event RenderFrameEvent RenderFrameNotify;
#endregion
#region --- IResizable Members ---
#region public int Width, Height
public int Width
{
get { return glWindow.Width; }
set
{
if (value == this.Width)
{
return;
}
else if (value > 0)
{
glWindow.Width = value;
}
else
{
throw new ArgumentOutOfRangeException(
"Width",
value,
"Width must be greater than 0"
);
}
}
}
public int Height
{
get { return glWindow.Height; }
set
{
if (value == this.Height)
{
return;
}
else if (value > 0)
{
glWindow.Height = value;
}
else
{
throw new ArgumentOutOfRangeException(
"Height",
value,
"Height must be greater than 0"
);
}
}
}
#endregion
#region public event ResizeEvent Resize;
public event ResizeEvent Resize;
/// <summary>
/// Raises the Resize event.
/// </summary>
/// <param name="e">Contains the new Width and Height of the window.</param>
protected virtual void OnResize(ResizeEventArgs e)
{
if (this.Resize != null)
this.Resize(this, e);
}
#endregion
#endregion
#region --- IDisposable Members ---
public void Dispose()
{
glWindow.Dispose();
glWindow = null;
}
#endregion
}
}

255
Source/OpenTK/Input/Key.cs Normal file
View file

@ -0,0 +1,255 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Input
{
static public class Key
{
static private bool[] keys = new bool[(int)Keys.MaxKeys];
#region Modifiers
static public bool LeftShift
{
get { return keys[(int)Keys.LeftShift]; }
internal set { keys[(int)Keys.LeftShift] = value; }
}
static public bool RightShift
{
get { return keys[(int)Keys.RightShift]; }
internal set { keys[(int)Keys.RightShift] = value; }
}
static public bool LeftControl
{
get { return keys[(int)Keys.LeftControl]; }
internal set { keys[(int)Keys.LeftControl] = value; }
}
static public bool RightControl
{
get { return keys[(int)Keys.RightControl]; }
internal set { keys[(int)Keys.RightControl] = value; }
}
static public bool LeftAlt
{
get { return keys[(int)Keys.LeftAlt]; }
internal set { keys[(int)Keys.LeftAlt] = value; }
}
static public bool RightAlt
{
get { return keys[(int)Keys.RightAlt]; }
internal set { keys[(int)Keys.RightAlt] = value; }
}
#endregion
#region Function Keys
static public bool F1
{
get { return keys[(int)Keys.F1]; }
internal set { keys[(int)Keys.F1] = value; }
}
static public bool F2
{
get { return keys[(int)Keys.F2]; }
internal set { keys[(int)Keys.F2] = value; }
}
static public bool F3
{
get { return keys[(int)Keys.F3]; }
internal set { keys[(int)Keys.F3] = value; }
}
static public bool F4
{
get { return keys[(int)Keys.F4]; }
internal set { keys[(int)Keys.F4] = value; }
}
static public bool F5
{
get { return keys[(int)Keys.F5]; }
internal set { keys[(int)Keys.F5] = value; }
}
static public bool F6
{
get { return keys[(int)Keys.F6]; }
internal set { keys[(int)Keys.F6] = value; }
}
static public bool F7
{
get { return keys[(int)Keys.F7]; }
internal set { keys[(int)Keys.F7] = value; }
}
static public bool F8
{
get { return keys[(int)Keys.F8]; }
internal set { keys[(int)Keys.F8] = value; }
}
static public bool F9
{
get { return keys[(int)Keys.F9]; }
internal set { keys[(int)Keys.F9] = value; }
}
static public bool F10
{
get { return keys[(int)Keys.F10]; }
internal set { keys[(int)Keys.F10] = value; }
}
static public bool F11
{
get { return keys[(int)Keys.F11]; }
internal set { keys[(int)Keys.F11] = value; }
}
static public bool F12
{
get { return keys[(int)Keys.F12]; }
internal set { keys[(int)Keys.F12] = value; }
}
static public bool F13
{
get { return keys[(int)Keys.F13]; }
internal set { keys[(int)Keys.F13] = value; }
}
static public bool F14
{
get { return keys[(int)Keys.F14]; }
internal set { keys[(int)Keys.F14] = value; }
}
static public bool F15
{
get { return keys[(int)Keys.F15]; }
internal set { keys[(int)Keys.F15] = value; }
}
static public bool F16
{
get { return keys[(int)Keys.F16]; }
internal set { keys[(int)Keys.F16] = value; }
}
#endregion
static public bool Enter
{
get { return keys[(int)Keys.Enter]; }
internal set { keys[(int)Keys.Enter] = value; }
}
static public bool Escape
{
get { return keys[(int)Keys.Escape]; }
internal set { keys[(int)Keys.Escape] = value; }
}
}
enum Keys : int
{
// Modifiers
LeftShift = 0,
RightShift,
LeftControl,
RightControl,
LeftAlt,
RightAlt,
// Function keys (hopefully enough for most keyboards - mine has 26)
F1, F2, F3, F4,
F5, F6, F7, F8,
F9, F10, F11, F12,
F13, F14, F15, F16,
F17, F18, F19, F20,
F21, F22, F23, F24,
F25, F26, F27, F28,
F29, F30, F31, F32,
// Direction arrows
Up,
Down,
Left,
Right,
// Special keys
Enter,
Escape,
Space,
Tab,
Backspace,
Insert,
Delete,
PageUp,
PageDown,
Home,
End,
CapsLock,
// Keypad keys
Keypad0,
Keypad1,
Keypad2,
Keypad3,
Keypad4,
Keypad5,
Keypad6,
Keypad7,
Keypad8,
Keypad9,
KeypadDivide,
KeypadMultiply,
KeypadSubtract,
KeypadAdd,
KeypadDecimal,
KeypadEqual,
KeypadEnter,
// Letters
A, B, C, D, E, F, G,
H, I, J, K, L, M, N,
O, P, Q, R, S, T, U,
V, W, X, Y, Z,
// Numbers
Number0,
Number1,
Number2,
Number3,
Number4,
Number5,
Number6,
Number7,
Number8,
Number9,
// Symbols
Minus,
Equal,
LeftBracket,
RightBracket,
Semicolon,
QuotationMark,
Comma,
FullStop,
Slash,
BackSlash,
MaxKeys
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,98 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.OpenGL
{
/// <summary>
/// Provides methods to create and render a display list.
/// </summary>
public class DisplayList : IDisposable
{
#region --- Private variables ---
private int id = -1;
#endregion
#region --- Constructors ---
/// <summary>
/// Allocates a new DisplayList.
/// </summary>
public DisplayList()
{
Id = GL.GenLists(1);
}
#endregion
#region --- Public properties ---
/// <summary>
/// Gets the display list number.
/// </summary>
public int Id
{
get { return id; }
private set { id = value; }
}
#endregion
#region --- Public methods ---
/// <summary>
/// Starts recording elements into the display list.
/// </summary>
public void Begin()
{
GL.NewList(Id, Enums.ListMode.COMPILE);
}
/// <summary>
/// Starts recording elements into the display list.
/// </summary>
/// <param name="listMode">Sets if the list is to be compiled or compiled and executed immediately.</param>
public void Begin(Enums.ListMode listMode)
{
GL.NewList(Id, listMode);
}
/// <summary>
/// Stops recording elements into the display list.
/// </summary>
public void End()
{
GL.EndList();
}
/// <summary>
/// Renders the display list elements.
/// </summary>
public void Render()
{
GL.CallList(Id);
}
#region IDisposable Members
public void Dispose()
{
if (Id > 0)
GL.DeleteLists(Id, 1);
Id = -1;
}
#endregion
#endregion
}
}

View file

@ -0,0 +1,468 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
#endregion
//[assembly: CLSCompliant(true)]
namespace OpenTK.OpenGL
{
/// <summary>
/// OpenGL binding for .NET, implementing OpenGL 2.1, plus extensions.
/// </summary>
/// <remarks>
/// <para>
/// OpenTK.OpenGL.GL contains all OpenGL enums and functions defined in the 2.1 specification.
/// The official .spec files can be found at: http://opengl.org/registry/.
/// </para>
/// <para>
/// OpenTK.OpenGL.GL relies on static initialization to obtain the entry points for OpenGL functions.
/// Please ensure that a valid OpenGL context has been made current in the pertinent thread <b>before</b>
/// any OpenGL functions are called (toolkits like GLUT, SDL or GLFW will automatically take care of
/// the context initialization process). Without a valid OpenGL context, OpenTK.OpenGL.GL will only be able
/// to retrieve statically exported entry points (typically corresponding to OpenGL version 1.1 under Windows,
/// 1.3 under Linux and 1.4 under Windows Vista), and extension methods will need to be loaded manually.
/// </para>
/// <para>
/// If you prefer not to rely on static initialisation for the Gl class, you can use the
/// ReloadFunctions or ReloadFunction methods to manually force the initialisation of OpenGL entry points.
/// The ReloadFunctions method should be called whenever you change an existing visual or pixelformat. This
/// generally happens when you change the color/stencil/depth buffer associated with a window (but probably
/// not the resolution). This may or may not be necessary under Linux/MacOS, but is generally required for
/// Windows.
/// </para>
/// <para>
/// You can use the Gl.IsExtensionSupported method to check whether any given category of extension functions
/// exists in the current OpenGL context. The results can be cached to speed up future searches.
/// Keep in mind that different OpenGL contexts may support different extensions, and under different entry
/// points. Always check if all required extensions are still supported when changing visuals or pixel
/// formats.
/// </para>
/// <para>
/// You may retrieve the entry point for an OpenGL extension using the Gl.GetDelegateForExtensionMethod
/// and Gl.GetFunctionPointerForExtensionMethod methods. You may retrieve the entry point for an OpenGL
/// function using the Gl.GetDelegateForMethod method. All three methods are cross-platform.
/// </para>
/// <para>
/// <see href="http://opengl.org/registry/"/>
/// <seealso cref="Gl.IsExtensionSupported(string, bool)"/>
/// <seealso cref="Gl.GetDelegateForExtensionMethod"/>
/// <seealso cref="Gl.GetFunctionPointerForExtensionMethod"/>
/// <seealso cref="Gl.GetDelegateForMethod"/>
/// <seealso cref="Gl.ReloadFunctions"/>
/// <seealso cref="Gl.ReloadFunction"/>
/// </para>
/// </remarks>
public static partial class GL
{
#region private enum Platform
/// <summary>
/// Enumerates the platforms OpenTK can run on.
/// </summary>
private enum Platform
{
Unknown,
Windows,
X11,
X11_ARB,
OSX
};
#endregion private enum Platform
private static Platform platform = Platform.Unknown;
private static System.Collections.Generic.Dictionary<string, bool> AvailableExtensions;
#region internal static extern IntPtr glxGetProcAddressARB(string s);
// also linux, for our ARB-y friends
[DllImport(GL_NATIVE_LIBRARY, EntryPoint = "glXGetProcAddressARB")]
internal static extern IntPtr glxGetProcAddressARB(string s);
#endregion
#region internal static IntPtr aglGetProcAddress(string s)
// osx gets complicated
[DllImport("libdl.dylib", EntryPoint = "NSIsSymbolNameDefined")]
internal static extern bool NSIsSymbolNameDefined(string s);
[DllImport("libdl.dylib", EntryPoint = "NSLookupAndBindSymbol")]
internal static extern IntPtr NSLookupAndBindSymbol(string s);
[DllImport("libdl.dylib", EntryPoint = "NSAddressOfSymbol")]
internal static extern IntPtr NSAddressOfSymbol(IntPtr symbol);
internal static IntPtr aglGetProcAddress(string s)
{
string fname = "_" + s;
if (!NSIsSymbolNameDefined(fname))
return IntPtr.Zero;
IntPtr symbol = NSLookupAndBindSymbol(fname);
if (symbol != IntPtr.Zero)
symbol = NSAddressOfSymbol(symbol);
return symbol;
}
#endregion
#region public static IntPtr GetFunctionPointerForExtensionMethod(string name)
/// <summary>
/// Retrieves the entry point for a dynamically exported OpenGL function.
/// </summary>
/// <param name="name">The function string for the OpenGL function (eg. "glNewList")</param>
/// <returns>
/// An IntPtr contaning the address for the entry point, or IntPtr.Zero if the specified
/// OpenGL function is not dynamically exported.
/// </returns>
/// <remarks>
/// <para>
/// The Marshal.GetDelegateForFunctionPointer method can be used to turn the return value
/// into a call-able delegate.
/// </para>
/// <para>
/// This function is cross-platform. It determines the underlying platform and uses the
/// correct wgl, glx or agl GetAddress function to retrieve the function pointer.
/// </para>
/// <see cref="Marshal.GetDelegateForFunctionPointer"/>
/// <seealso cref="Gl.GetDelegateForExtensionMethod"/>
/// </remarks>
public static IntPtr GetFunctionPointerForExtensionMethod(string name)
{
IntPtr result = IntPtr.Zero;
switch (platform)
{
case Platform.Unknown:
// WGL?
try
{
result = OpenTK.Platform.Windows.Wgl.GetProcAddress(name);
platform = Platform.Windows;
return result;
}
catch (Exception)
{ }
// AGL? (before X11, since GLX might exist on OSX)
try
{
result = aglGetProcAddress(name);
platform = Platform.OSX;
return result;
}
catch (Exception)
{ }
// X11?
try
{
result = OpenTK.Platform.X11.Glx.GetProcAddress(name);
platform = Platform.X11;
return result;
}
catch (Exception)
{ }
// X11 ARB?
try
{
result = glxGetProcAddressARB(name);
platform = Platform.X11_ARB;
return result;
}
catch (Exception)
{ }
// Ack!
throw new NotSupportedException(
@"Could not find out how to retrive function pointers for this platform.
Did you remember to copy OpenTK.OpenGL.dll.config to your binary's folder?
");
case Platform.Windows:
return OpenTK.Platform.Windows.Wgl.GetProcAddress(name);
case Platform.OSX:
return aglGetProcAddress(name);
case Platform.X11:
return OpenTK.Platform.X11.Glx.GetProcAddress(name);
case Platform.X11_ARB:
return glxGetProcAddressARB(name);
}
throw new NotSupportedException("Internal error - please report.");
}
#endregion public static IntPtr GetFunctionPointerForExtensionMethod(string s)
#region public static Delegate GetDelegateForExtensionMethod(string name, Type signature)
/// <summary>
/// Creates a System.Delegate that can be used to call a dynamically exported OpenGL function.
/// </summary>
/// <param name="name">The name of the OpenGL function (eg. "glNewList")</param>
/// <param name="signature">The signature of the OpenGL function.</param>
/// <returns>
/// A System.Delegate that can be used to call this OpenGL function or null
/// if the function is not available in the current OpenGL context.
/// </returns>
public static Delegate GetDelegateForExtensionMethod(string name, Type signature)
{
IntPtr address = GetFunctionPointerForExtensionMethod(name);
if (address == IntPtr.Zero ||
address == new IntPtr(1) || // Workaround for buggy nvidia drivers which return
address == new IntPtr(2)) // 1 or 2 instead of IntPtr.Zero for some extensions.
{
return null;
}
else
{
return Marshal.GetDelegateForFunctionPointer(address, signature);
}
}
#endregion public static Delegate GetAddress(string name, Type signature)
#region public static Delegate GetDelegateForMethod(string name, Type signature)
/// <summary>
/// Creates a System.Delegate that can be used to call an OpenGL function, core or extension.
/// </summary>
/// <param name="name">The name of the OpenGL function (eg. "glNewList")</param>
/// <param name="signature">The signature of the OpenGL function.</param>
/// <returns>
/// A System.Delegate that can be used to call this OpenGL function, or null if the specified
/// function name did not correspond to an OpenGL function.
/// </returns>
public static Delegate GetDelegateForMethod(string name, Type signature)
{
Delegate d;
if (Assembly.Load("OpenTK.OpenGL").GetType("OpenTK.OpenGL.Imports").GetMethod(name.Substring(2)) != null)
{
d = GetDelegateForExtensionMethod(name, signature) ??
Delegate.CreateDelegate(signature, typeof(Imports), name.Substring(2));
}
else
{
d = GetDelegateForExtensionMethod(name, signature);
}
return d;
}
#endregion
#region public static bool IsExtensionSupported(string name)
/// <summary>
/// Determines whether the specified OpenGL extension category is available in
/// the current OpenGL context. Equivalent to IsExtensionSupported(name, true)
/// </summary>
/// <param name="name">The string for the OpenGL extension category (eg. "GL_ARB_multitexture")</param>
/// <returns>True if the specified extension is available, false otherwise.</returns>
public static bool IsExtensionSupported(string name)
{
return IsExtensionSupported(name, true);
}
#endregion
#region public static bool IsExtensionSupported(string name, bool useCache)
/// <summary>
/// Determines whether the specified OpenGL extension category is available in
/// the current OpenGL context.
/// </summary>
/// <param name="name">The string for the OpenGL extension category (eg. "GL_ARB_multitexture")</param>
/// <param name="useCache">If true, the results will be cached to speed up future results.</param>
/// <returns>True if the specified extension is available, false otherwise.</returns>
public static bool IsExtensionSupported(string name, bool useCache)
{
// Use cached results
if (useCache)
{
// Build cache if it is not available
if (AvailableExtensions == null)
{
ParseAvailableExtensions();
}
// Search the cache for the string. Note that the cache substitutes
// strings "1.0" to "2.1" with "GL_VERSION_1_0" to "GL_VERSION_2_1"
if (AvailableExtensions.ContainsKey(name))
return AvailableExtensions[name];
else
return false;
}
// Do not use cached results
string extension_string = GL.GetString(Enums.StringName.EXTENSIONS);
if (String.IsNullOrEmpty(extension_string))
return false; // no extensions are available
// Check if the user searches for GL_VERSION_X_X and search glGetString(GL_VERSION) instead.
if (name.Contains("GL_VERSION_"))
{
return GL.GetString(OpenTK.OpenGL.Enums.StringName.VERSION).Trim().StartsWith(name.Replace("GL_VERSION_", String.Empty).Replace('_', '.'));
}
// Search for the string given.
string[] extensions = extension_string.Split(' ');
foreach (string s in extensions)
{
if (name == s)
return true;
}
return false;
}
#endregion
#region private static void ParseAvailableExtensions()
/// <summary>
/// Builds a cache of the supported extensions to speed up searches.
/// </summary>
private static void ParseAvailableExtensions()
{
// Assumes there is a current context.
AvailableExtensions = new Dictionary<string, bool>();
string version_string = GL.GetString(OpenTK.OpenGL.Enums.StringName.VERSION);
if (String.IsNullOrEmpty(version_string))
return; // this shoudn't happen
string version = version_string.Trim(' ');
if (version.StartsWith("1.2"))
{
AvailableExtensions.Add("GL_VERSION_1_2", true);
}
else if (version.StartsWith("1.3"))
{
AvailableExtensions.Add("GL_VERSION_1_2", true);
AvailableExtensions.Add("GL_VERSION_1_3", true);
}
else if (version.StartsWith("1.4"))
{
AvailableExtensions.Add("GL_VERSION_1_2", true);
AvailableExtensions.Add("GL_VERSION_1_3", true);
AvailableExtensions.Add("GL_VERSION_1_4", true);
}
else if (version.StartsWith("1.5"))
{
AvailableExtensions.Add("GL_VERSION_1_2", true);
AvailableExtensions.Add("GL_VERSION_1_3", true);
AvailableExtensions.Add("GL_VERSION_1_4", true);
AvailableExtensions.Add("GL_VERSION_1_5", true);
}
else if (version.StartsWith("2.0"))
{
AvailableExtensions.Add("GL_VERSION_1_2", true);
AvailableExtensions.Add("GL_VERSION_1_3", true);
AvailableExtensions.Add("GL_VERSION_1_4", true);
AvailableExtensions.Add("GL_VERSION_1_5", true);
AvailableExtensions.Add("GL_VERSION_2_0", true);
}
else if (version.StartsWith("2.1"))
{
AvailableExtensions.Add("GL_VERSION_1_2", true);
AvailableExtensions.Add("GL_VERSION_1_3", true);
AvailableExtensions.Add("GL_VERSION_1_4", true);
AvailableExtensions.Add("GL_VERSION_1_5", true);
AvailableExtensions.Add("GL_VERSION_2_0", true);
AvailableExtensions.Add("GL_VERSION_2_1", true);
}
string extension_string = GL.GetString(OpenTK.OpenGL.Enums.StringName.EXTENSIONS);
if (String.IsNullOrEmpty(extension_string))
return; // no extensions are available
string[] extensions = extension_string.Split(' ');
foreach (string ext in extensions)
{
AvailableExtensions.Add(ext, true);
}
}
#endregion
#region public static void ReloadFunctions()
/// <summary>
/// Reloads all OpenGL functions (core and extensions).
/// </summary>
/// <remarks>
/// <para>
/// Call this function to reload all OpenGL entry points. This should be done
/// whenever you change the pixelformat/visual, or in the case you cannot (or do not want)
/// to use the automatic initialisation.
/// </para>
/// <para>
/// Calling this function before the automatic initialisation has taken place will result
/// in the Gl class being initialised twice. This is harmless, but given the automatic
/// initialisation should be preferred.
/// </para>
/// </remarks>
public static void ReloadFunctions()
{
Assembly asm = Assembly.Load("OpenTK.OpenGL");
Type delegates_class = asm.GetType("OpenTK.OpenGL.Delegates");
Type imports_class = asm.GetType("OpenTK.OpenGL.Imports");
FieldInfo[] v = delegates_class.GetFields();
foreach (FieldInfo f in v)
{
f.SetValue(null, GetDelegateForMethod(f.Name, f.FieldType));
}
ParseAvailableExtensions();
}
#endregion
#region public static bool ReloadFunction(string name)
/// <summary>
/// Tries to reload the given OpenGL function (core or extension).
/// </summary>
/// <param name="name">The name of the OpenGL function (i.e. glShaderSource)</param>
/// <returns>True if the function was found and reloaded, false otherwise.</returns>
/// <remarks>
/// <para>
/// Use this function if you require greater granularity when loading OpenGL entry points.
/// </para>
/// <para>
/// While the automatic initialisation will load all OpenGL entry points, in some cases
/// the initialisation can take place before an OpenGL Context has been established.
/// In this case, use this function to load the entry points for the OpenGL functions
/// you will need, or use ReloadFunctions() to load all available entry points.
/// </para>
/// <para>
/// This function will return true if the given OpenGL function exists, false otherwise.
/// A return value of "true" does not mean that any specific OpenGL function is supported;
/// rather it means that the string passed to this function denotes a known OpenGL function.
/// </para>
/// <para>
/// To query supported extensions use the IsExtensionSupported() function instead.
/// </para>
/// </remarks>
public static bool ReloadFunction(string name)
{
Assembly asm = Assembly.Load("OpenTK.OpenGL");
Type delegates_class = asm.GetType("OpenTK.OpenGL.Delegates");
Type imports_class = asm.GetType("OpenTK.OpenGL.Imports");
FieldInfo f = delegates_class.GetField(name);
if (f == null)
return false;
f.SetValue(null, GetDelegateForMethod(f.Name, f.FieldType));
return true;
}
#endregion
}
}

View file

@ -0,0 +1,68 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace OpenTK.OpenGL
{
/// <summary>
/// Provides access to GLU functions.
/// </summary>
public class Glu
{
#region GLU functions
private const string GLUDLLName = "glu32.dll";
[DllImport(GLUDLLName, EntryPoint = "gluOrtho2D")]
private static extern IntPtr ErrorString_(int errCode);
[DllImport(GLUDLLName, EntryPoint = "gluGetString")]
private static extern IntPtr GetString_(int errCode);
[DllImport(GLUDLLName, EntryPoint = "gluOrtho2D")]
public static extern void Ortho2D(double left, double right, double bottom, double top);
[DllImport(GLUDLLName, EntryPoint = "gluPerspective")]
public static extern void Perspective(double fovy, double aspect, double zNear, double zFar);
[DllImport(GLUDLLName, EntryPoint = "gluPickMatrix")]
public static extern void PickMatrix(double x, double y, double width, double height, int[] viewport);
[DllImport(GLUDLLName, EntryPoint = "gluLookAt")]
public static extern void LookAt(double eyex, double eyey, double eyez, double centerx, double centery, double centerz, double upx, double upy, double upz);
[DllImport(GLUDLLName, EntryPoint = "gluProject")]
public static extern int Project(double objx, double objy, double objz, double[] modelMatrix, double[] projMatrix, int[] viewport, out double winx, out double winy, out double winz);
[DllImport(GLUDLLName, EntryPoint = "gluUnProject")]
public static extern int UnProject(double winx, double winy, double winz, double[] modelMatrix, double[] projMatrix, int[] viewport, out double objx, out double objy, out double objz);
[DllImport(GLUDLLName, EntryPoint = "ScaleImage")]
public static extern void ScaleImage(int format, int widthin, int heightin, int typein, IntPtr datain, int widthout, int heightout, int typeout, IntPtr dataout);
[DllImport(GLUDLLName, EntryPoint = "gluBuild1DMipmaps")]
public static extern int Build1DMipmaps(int target, int components, int width, int format, int type, IntPtr data);
[DllImport(GLUDLLName, EntryPoint = "gluBuild2DMipmaps")]
public static extern int Build2DMipmaps(int target, int components, int width, int height, int format, int type, IntPtr data);
public static string GetString(int name)
{
return Marshal.PtrToStringAnsi(GetString_(name));
}
public static string ErrorString(int name)
{
return Marshal.PtrToStringAnsi(ErrorString_(name));
}
#endregion
}
}

View file

@ -0,0 +1,4 @@
<configuration>
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
</configuration>

View file

@ -0,0 +1,94 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Drawing;
using System.Globalization;
namespace OpenTK.Platform
{
public class ColorDepth
{
public byte Red, Green, Blue, Alpha;
public bool IsIndexed = false;
public int BitsPerPixel;
public ColorDepth(int bpp)
{
Red = Green = Blue = Alpha = 0;
BitsPerPixel = bpp;
switch (bpp)
{
case 32:
Red = Green = Blue = Alpha = 8;
break;
case 24:
Red = Green = Blue = 8;
break;
case 16:
Red = Blue = 5;
Green = 6;
break;
case 15:
Red = Green = Blue = 5;
break;
case 8:
IsIndexed = true;
break;
case 4:
IsIndexed = true;
break;
default:
break;
}
}
public ColorDepth(int red, int green, int blue, int alpha)
{
Red = (byte)red;
Green = (byte)green;
Blue = (byte)blue;
Alpha = (byte)alpha;
BitsPerPixel = red + green + blue + alpha;
}
public override bool Equals(object obj)
{
return (obj is ColorDepth) ? (this == (ColorDepth)obj) : false;
}
public static bool operator ==(ColorDepth left, ColorDepth right)
{
if ((object)left == (object)null && (object)right != (object)null ||
(object)left != (object)null && (object)right == (object)null)
return false;
if ((object)left == (object)null && (object)right == (object)null)
return true;
return left.Red == right.Red &&
left.Green == right.Green &&
left.Blue == right.Blue &&
left.Alpha == right.Alpha;
}
public static bool operator !=(ColorDepth left, ColorDepth right)
{
return !(left == right);
}
public override int GetHashCode()
{
return Red ^ Green ^ Blue ^ Alpha;
}
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{0}", BitsPerPixel + (IsIndexed ? " indexed" : String.Empty) + " bpp");
}
}
}

View file

@ -0,0 +1,226 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
#region --- Using directives ---
using System;
using System.Drawing;
using System.Globalization;
#endregion
namespace OpenTK.Platform
{
public sealed class DisplayMode
{
#region --- Private Variables ---
private int width, height;
private ColorDepth color;
private int depthBits, stencilBits, auxBits;
private float refreshRate;
private bool vsync;
private bool fullscreen;
private int buffers;
private bool stereo;
#endregion
#region --- Constructors ---
/// <summary>
/// Constructs a new DisplayMode from the given parameters.
/// </summary>
/// <param name="width">The Width of the DisplayMode, in pixels.</param>
/// <param name="height">The Height of the DisplayMode, in pixels.</param>
/// <param name="color">The ColorDepth of the DisplayMode.</param>
/// <param name="depth">The size of the Depth Buffer, in bits.</param>
/// <param name="stencil">The size of Stencil Buffer, in bits.</param>
/// <param name="aux">The size of the Auxilliary Buffer, in bits.</param>
/// <param name="fullscreen">Set to true for a fullscreen DisplayMode.</param>
/// <param name="stereo">Set to true for a DisplayMode with stereographic capabilities.</param>
/// <param name="buffers">The number of Display Buffers. Usually one, two or three.</param>
/// <param name="vsync">Set to true to sync the updates to the screen refresh rate.</param>
/// <param name="refresh">The desired RefreshRate. Taken into account only for Fullscreen DisplayModes.</param>
public DisplayMode(
int width,
int height,
ColorDepth color,
int depth,
int stencil,
int aux,
int buffers,
bool fullscreen,
bool stereo,
bool vsync,
float refresh
)
{
this.Width = width;
this.Height = height;
this.Color = color;
this.DepthBits = depth;
this.StencilBits = stencil;
this.AuxBits = aux;
this.Buffers = buffers;
this.Fullscreen = fullscreen;
this.Stereo = stereo;
this.Vsync = vsync;
this.RefreshRate = refresh;
}
/// <summary>
/// Constructs a new DisplayMode with default values.
/// </summary>
public DisplayMode()
: this(0, 0, new ColorDepth(0), 0, 0, 0, 0, false, false, false, 0.0f)
{
}
/// <summary>
/// Creates a DisplayMode.
/// </summary>
/// <param name="width">The Width of the DisplayMode in pixels.</param>
/// <param name="height">The Height of the DisplayMode in pixels.</param>
public DisplayMode(int width, int height)
: this(width, height, new ColorDepth(0), 0, 0, 0, 0, false, false, false, 0.0f)
{
}
/*
public DisplayMode(int width, int height, int bpp, int frequency)
: this(width, height, 0, 0, 0, 0, frequency)
{
color = new ColorDepth(bpp);
}
*/
/*
public DisplayMode(int width, int height, int r, int g, int b, int a, int frequency)
{
size = new Size(width, height);
color = new ColorDepth(r, g, b, a);
displayFrequency = frequency;
}
*/
#endregion
#region --- Public Properties ---
#region public int Height
/// <summary>
/// Gets or sets the Height of the DisplayMode. Height is the vertical span measured in pixels.
/// </summary>
public int Height
{
get { return height; }
set
{
if (value > 0 /* && (value < Screen[0].Height) */)
{
height = value;
}
}
}
#endregion
#region public int Width
/// <summary>
/// Gets or sets the Width of the DisplayMode. Width is the horizontal span measured in pixels.
/// </summary>
public int Width
{
get { return width; }
set
{
if (value > 0 /* && (value < Screen[0].Width) */)
{
width = value;
}
}
}
#endregion
#region public ColorDepth Color
public ColorDepth Color
{
get { return this.color; }
set { this.color = value; }
}
#endregion
public int DepthBits
{
get { return this.depthBits; }
set { this.depthBits = value; }
}
public int StencilBits
{
get { return this.stencilBits; }
set { this.stencilBits = value; }
}
public int AuxBits
{
get { return this.auxBits; }
set { this.auxBits = value; }
}
public bool Stereo
{
get { return this.stereo; }
set { this.stereo = value; }
}
public bool Fullscreen
{
get { return this.fullscreen; }
set { this.fullscreen = value; }
}
public bool Vsync
{
get { return this.vsync; }
set { this.vsync = value; }
}
public int Buffers
{
get { return this.buffers; }
set { this.buffers = value; }
}
public float RefreshRate
{
get { return this.refreshRate; }
set { this.refreshRate = value; }
}
#endregion
public override string ToString()
{
return string.Format(
CultureInfo.CurrentCulture,
"{0}x{1}, {2}, {3}Hz",
Width, Height,
Color,
RefreshRate
);
}
}
public class DisplayModeMatchOptions { }
}

View file

@ -0,0 +1,42 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Platform
{
public interface IGLContext : IDisposable
{
/// <summary>
/// Swaps buffers on a context. This presents the rendered scene to the user.
/// </summary>
void SwapBuffers();
/// <summary>
/// Makes this context the current rendering target.
/// </summary>
void MakeCurrent();
/// <summary>
/// Gets the address of an OpenGL extension function.
/// </summary>
/// <param name="function">The name of the OpenGL function (e.g. "glGetString")</param>
/// <returns>
/// A pointer to the specified function or IntPtr.Zero if the function isn't
/// available in the current opengl context.
/// </returns>
/// <see cref="Marshal.GetDelegateForFunctionPointer"/>
IntPtr GetAddress(string function);
/// <summary>
/// Returns the display modes supported by the current opengl context.
/// </summary>
/// <returns>An array containing all supported display modes.</returns>
IEnumerable<DisplayMode> GetDisplayModes();
}
}

View file

@ -0,0 +1,28 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using OpenTK.OpenGL;
namespace OpenTK.Platform
{
public interface IGLControl : IDisposable
{
void ProcessEvents();
event CreateEvent Create;
bool IsIdle { get; }
//bool Quit { get; set; }
bool Fullscreen { get; set; }
IGLContext Context { get; }
}
public delegate void CreateEvent(object sender, EventArgs e);
}

View file

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Platform
{
interface IGameWindow : IDisposable
{
void Run();
void RenderFrame();
void UpdateFrame();
event UpdateFrameEvent UpdateFrameNotify;
event RenderFrameEvent RenderFrameNotify;
}
public delegate void UpdateFrameEvent(EventArgs e);
public delegate void RenderFrameEvent(EventArgs e);
}

View file

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Platform
{
interface INativeWindow : IResizable, IDisposable
{
void ProcessEvents();
event CreateEvent Create;
bool IsIdle { get; }
bool Quit { get; set; }
bool Fullscreen { get; set; }
IGLContext Context { get; }
}
}

View file

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Platform
{
public interface IResizable
{
int Height { get; set; }
int Width { get; set; }
event ResizeEvent Resize;
}
public delegate void ResizeEvent(object sender, ResizeEventArgs e);
public class ResizeEventArgs : EventArgs
{
public int Width, Height;
public ResizeEventArgs()
{
}
public ResizeEventArgs(int width, int height)
{
this.Width = width;
this.Height = height;
}
}
}

View file

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Platform
{
public interface IWindowInfo
{
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,304 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* Contributions from Erik Ylvisaker
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace OpenTK.Platform.Windows
{
/// <summary>
/// Provides access to WGL functions.
/// </summary>
internal static class Wgl
{
// Disable BeforeFieldInit optimization.
static Wgl() { }
const string _dll_name = "OPENGL32.DLL";
/// <summary>
/// Contains all WGL constants.
/// </summary>
public class Constant
{
#region WGL constants
public const int WGLEXT_VERSION = 4;
public const int FRONT_COLOR_BUFFER_BIT_ARB = 0x00000001;
public const int BACK_COLOR_BUFFER_BIT_ARB = 0x00000002;
public const int DEPTH_BUFFER_BIT_ARB = 0x00000004;
public const int STENCIL_BUFFER_BIT_ARB = 0x00000008;
public const int SAMPLE_BUFFERS_ARB = 0x2041;
public const int SAMPLES_ARB = 0x2042;
public const int NUMBER_PIXEL_FORMATS_ARB = 0x2000;
public const int DRAW_TO_WINDOW_ARB = 0x2001;
public const int DRAW_TO_BITMAP_ARB = 0x2002;
public const int ACCELERATION_ARB = 0x2003;
public const int NEED_PALETTE_ARB = 0x2004;
public const int NEED_SYSTEM_PALETTE_ARB = 0x2005;
public const int SWAP_LAYER_BUFFERS_ARB = 0x2006;
public const int SWAP_METHOD_ARB = 0x2007;
public const int NUMBER_OVERLAYS_ARB = 0x2008;
public const int NUMBER_UNDERLAYS_ARB = 0x2009;
public const int TRANSPARENT_ARB = 0x200A;
public const int TRANSPARENT_RED_VALUE_ARB = 0x2037;
public const int TRANSPARENT_GREEN_VALUE_ARB = 0x2038;
public const int TRANSPARENT_BLUE_VALUE_ARB = 0x2039;
public const int TRANSPARENT_ALPHA_VALUE_ARB = 0x203A;
public const int TRANSPARENT_INDEX_VALUE_ARB = 0x203B;
public const int SHARE_DEPTH_ARB = 0x200C;
public const int SHARE_STENCIL_ARB = 0x200D;
public const int SHARE_ACCUM_ARB = 0x200E;
public const int SUPPORT_GDI_ARB = 0x200F;
public const int SUPPORT_OPENGL_ARB = 0x2010;
public const int DOUBLE_BUFFER_ARB = 0x2011;
public const int STEREO_ARB = 0x2012;
public const int PIXEL_TYPE_ARB = 0x2013;
public const int COLOR_BITS_ARB = 0x2014;
public const int RED_BITS_ARB = 0x2015;
public const int RED_SHIFT_ARB = 0x2016;
public const int GREEN_BITS_ARB = 0x2017;
public const int GREEN_SHIFT_ARB = 0x2018;
public const int BLUE_BITS_ARB = 0x2019;
public const int BLUE_SHIFT_ARB = 0x201A;
public const int ALPHA_BITS_ARB = 0x201B;
public const int ALPHA_SHIFT_ARB = 0x201C;
public const int ACCUM_BITS_ARB = 0x201D;
public const int ACCUM_RED_BITS_ARB = 0x201E;
public const int ACCUM_GREEN_BITS_ARB = 0x201F;
public const int ACCUM_BLUE_BITS_ARB = 0x2020;
public const int ACCUM_ALPHA_BITS_ARB = 0x2021;
public const int DEPTH_BITS_ARB = 0x2022;
public const int STENCIL_BITS_ARB = 0x2023;
public const int AUX_BUFFERS_ARB = 0x2024;
public const int NO_ACCELERATION_ARB = 0x2025;
public const int GENERIC_ACCELERATION_ARB = 0x2026;
public const int FULL_ACCELERATION_ARB = 0x2027;
public const int SWAP_EXCHANGE_ARB = 0x2028;
public const int SWAP_COPY_ARB = 0x2029;
public const int SWAP_UNDEFINED_ARB = 0x202A;
public const int TYPE_RGBA_ARB = 0x202B;
public const int TYPE_COLORINDEX_ARB = 0x202C;
public const int ERROR_INVALID_PIXEL_TYPE_ARB = 0x2043;
public const int ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB = 0x2054;
public const int DRAW_TO_PBUFFER_ARB = 0x202D;
public const int MAX_PBUFFER_PIXELS_ARB = 0x202E;
public const int MAX_PBUFFER_WIDTH_ARB = 0x202F;
public const int MAX_PBUFFER_HEIGHT_ARB = 0x2030;
public const int PBUFFER_LARGEST_ARB = 0x2033;
public const int PBUFFER_WIDTH_ARB = 0x2034;
public const int PBUFFER_HEIGHT_ARB = 0x2035;
public const int PBUFFER_LOST_ARB = 0x2036;
public const int BIND_TO_TEXTURE_RGB_ARB = 0x2070;
public const int BIND_TO_TEXTURE_RGBA_ARB = 0x2071;
public const int TEXTURE_FORMAT_ARB = 0x2072;
public const int TEXTURE_TARGET_ARB = 0x2073;
public const int MIPMAP_TEXTURE_ARB = 0x2074;
public const int TEXTURE_RGB_ARB = 0x2075;
public const int TEXTURE_RGBA_ARB = 0x2076;
public const int NO_TEXTURE_ARB = 0x2077;
public const int TEXTURE_CUBE_MAP_ARB = 0x2078;
public const int TEXTURE_1D_ARB = 0x2079;
public const int TEXTURE_2D_ARB = 0x207A;
public const int MIPMAP_LEVEL_ARB = 0x207B;
public const int CUBE_MAP_FACE_ARB = 0x207C;
public const int TEXTURE_CUBE_MAP_POSITIVE_X_ARB = 0x207D;
public const int TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = 0x207E;
public const int TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = 0x207F;
public const int TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = 0x2080;
public const int TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = 0x2081;
public const int TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = 0x2082;
public const int FRONT_LEFT_ARB = 0x2083;
public const int FRONT_RIGHT_ARB = 0x2084;
public const int BACK_LEFT_ARB = 0x2085;
public const int BACK_RIGHT_ARB = 0x2086;
public const int AUX0_ARB = 0x2087;
public const int AUX1_ARB = 0x2088;
public const int AUX2_ARB = 0x2089;
public const int AUX3_ARB = 0x208A;
public const int AUX4_ARB = 0x208B;
public const int AUX5_ARB = 0x208C;
public const int AUX6_ARB = 0x208D;
public const int AUX7_ARB = 0x208E;
public const int AUX8_ARB = 0x208F;
public const int AUX9_ARB = 0x2090;
public const int ERROR_INVALID_PIXEL_TYPE_EXT = 0x2043;
public const int NUMBER_PIXEL_FORMATS_EXT = 0x2000;
public const int DRAW_TO_WINDOW_EXT = 0x2001;
public const int DRAW_TO_BITMAP_EXT = 0x2002;
public const int ACCELERATION_EXT = 0x2003;
public const int NEED_PALETTE_EXT = 0x2004;
public const int NEED_SYSTEM_PALETTE_EXT = 0x2005;
public const int SWAP_LAYER_BUFFERS_EXT = 0x2006;
public const int SWAP_METHOD_EXT = 0x2007;
public const int NUMBER_OVERLAYS_EXT = 0x2008;
public const int NUMBER_UNDERLAYS_EXT = 0x2009;
public const int TRANSPARENT_EXT = 0x200A;
public const int TRANSPARENT_VALUE_EXT = 0x200B;
public const int SHARE_DEPTH_EXT = 0x200C;
public const int SHARE_STENCIL_EXT = 0x200D;
public const int SHARE_ACCUM_EXT = 0x200E;
public const int SUPPORT_GDI_EXT = 0x200F;
public const int SUPPORT_OPENGL_EXT = 0x2010;
public const int DOUBLE_BUFFER_EXT = 0x2011;
public const int STEREO_EXT = 0x2012;
public const int PIXEL_TYPE_EXT = 0x2013;
public const int COLOR_BITS_EXT = 0x2014;
public const int RED_BITS_EXT = 0x2015;
public const int RED_SHIFT_EXT = 0x2016;
public const int GREEN_BITS_EXT = 0x2017;
public const int GREEN_SHIFT_EXT = 0x2018;
public const int BLUE_BITS_EXT = 0x2019;
public const int BLUE_SHIFT_EXT = 0x201A;
public const int ALPHA_BITS_EXT = 0x201B;
public const int ALPHA_SHIFT_EXT = 0x201C;
public const int ACCUM_BITS_EXT = 0x201D;
public const int ACCUM_RED_BITS_EXT = 0x201E;
public const int ACCUM_GREEN_BITS_EXT = 0x201F;
public const int ACCUM_BLUE_BITS_EXT = 0x2020;
public const int ACCUM_ALPHA_BITS_EXT = 0x2021;
public const int DEPTH_BITS_EXT = 0x2022;
public const int STENCIL_BITS_EXT = 0x2023;
public const int AUX_BUFFERS_EXT = 0x2024;
public const int NO_ACCELERATION_EXT = 0x2025;
public const int GENERIC_ACCELERATION_EXT = 0x2026;
public const int FULL_ACCELERATION_EXT = 0x2027;
public const int SWAP_EXCHANGE_EXT = 0x2028;
public const int SWAP_COPY_EXT = 0x2029;
public const int SWAP_UNDEFINED_EXT = 0x202A;
public const int TYPE_RGBA_EXT = 0x202B;
public const int TYPE_COLORINDEX_EXT = 0x202C;
public const int DRAW_TO_PBUFFER_EXT = 0x202D;
public const int MAX_PBUFFER_PIXELS_EXT = 0x202E;
public const int MAX_PBUFFER_WIDTH_EXT = 0x202F;
public const int MAX_PBUFFER_HEIGHT_EXT = 0x2030;
public const int OPTIMAL_PBUFFER_WIDTH_EXT = 0x2031;
public const int OPTIMAL_PBUFFER_HEIGHT_EXT = 0x2032;
public const int PBUFFER_LARGEST_EXT = 0x2033;
public const int PBUFFER_WIDTH_EXT = 0x2034;
public const int PBUFFER_HEIGHT_EXT = 0x2035;
public const int DEPTH_FLOAT_EXT = 0x2040;
public const int SAMPLE_BUFFERS_3DFX = 0x2060;
public const int SAMPLES_3DFX = 0x2061;
public const int SAMPLE_BUFFERS_EXT = 0x2041;
public const int SAMPLES_EXT = 0x2042;
public const int DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D = 0x2051;
public const int DIGITAL_VIDEO_CURSOR_INCLUDED_I3D = 0x2052;
public const int DIGITAL_VIDEO_GAMMA_CORRECTED_I3D = 0x2053;
public const int GAMMA_TABLE_SIZE_I3D = 0x204E;
public const int GAMMA_EXCLUDE_DESKTOP_I3D = 0x204F;
public const int GENLOCK_SOURCE_MULTIVIEW_I3D = 0x2044;
public const int GENLOCK_SOURCE_EXTENAL_SYNC_I3D = 0x2045;
public const int GENLOCK_SOURCE_EXTENAL_FIELD_I3D = 0x2046;
public const int GENLOCK_SOURCE_EXTENAL_TTL_I3D = 0x2047;
public const int GENLOCK_SOURCE_DIGITAL_SYNC_I3D = 0x2048;
public const int GENLOCK_SOURCE_DIGITAL_FIELD_I3D = 0x2049;
public const int GENLOCK_SOURCE_EDGE_FALLING_I3D = 0x204A;
public const int GENLOCK_SOURCE_EDGE_RISING_I3D = 0x204B;
public const int GENLOCK_SOURCE_EDGE_BOTH_I3D = 0x204C;
public const int IMAGE_BUFFER_MIN_ACCESS_I3D = 0x00000001;
public const int IMAGE_BUFFER_LOCK_I3D = 0x00000002;
public const int BIND_TO_TEXTURE_DEPTH_NV = 0x20A3;
public const int BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV = 0x20A4;
public const int DEPTH_TEXTURE_FORMAT_NV = 0x20A5;
public const int TEXTURE_DEPTH_COMPONENT_NV = 0x20A6;
public const int DEPTH_COMPONENT_NV = 0x20A7;
public const int BIND_TO_TEXTURE_RECTANGLE_RGB_NV = 0x20A0;
public const int BIND_TO_TEXTURE_RECTANGLE_RGBA_NV = 0x20A1;
public const int TEXTURE_RECTANGLE_NV = 0x20A2;
public const int FLOAT_COMPONENTS_NV = 0x20B0;
public const int TEXTURE_FLOAT_R_NV = 0x20B5;
public const int TEXTURE_FLOAT_RG_NV = 0x20B6;
public const int TEXTURE_FLOAT_RGB_NV = 0x20B7;
public const int TEXTURE_FLOAT_RGBA_NV = 0x20B8;
#endregion
}
#region WGL functions
[DllImport(_dll_name)]
public static extern IntPtr GetProcAddress(IntPtr hwnd);
[DllImport(_dll_name, EntryPoint = "wglGetProcAddress", SetLastError=true)]
public static extern IntPtr GetProcAddress(string funcname);
#region public static extern IntPtr CreateContext(IntPtr dc);
[DllImport(_dll_name, EntryPoint = "wglCreateContext")]
public static extern IntPtr CreateContext(IntPtr dc);
#endregion
#region public static extern bool MakeCurrent(IntPtr dc, IntPtr rc)
/// <summary>
/// The wglMakeCurrent function makes a specified OpenGL rendering context the calling thread's current rendering context.
/// All subsequent OpenGL calls made by the thread are drawn on the device identified by hdc.
/// You can also use wglMakeCurrent to change the calling thread's current rendering context so it's no longer current.
/// </summary>
/// <param name="dc">Device context of device that OpenGL calls are to be drawn on</param>
/// <param name="rc">OpenGL rendering context to be made the calling thread's current rendering context</param>
/// <returns>
/// When the wglMakeCurrent function succeeds, the return value is TRUE; otherwise the return value is FALSE.
/// To get extended error information, call GetLastError.
/// </returns>
/// <remarks>
/// <para>
/// The hdc parameter must refer to a drawing surface supported by OpenGL. It need not be the same hdc
/// that was passed to wglCreateContext when hglrc was created, but it must be on the same device and have
/// the same pixel format. GDI transformation and clipping in hdc are not supported by the rendering context.
/// The current rendering context uses the hdc device context until the rendering context is no longer current.
/// </para>
/// <para>
/// Before switching to the new rendering context, OpenGL flushes any previous rendering context
/// that was current to the calling thread.
/// </para>
/// <para>
/// A thread can have one current rendering context. A process can have multiple rendering contexts
/// by means of multithreading. A thread must set a current rendering context before calling any OpenGL functions.
/// Otherwise, all OpenGL calls are ignored.
/// </para>
/// <para>
/// A rendering context can be current to only one thread at a time. You cannot make a rendering context current
/// to multiple threads.
/// </para>
/// <para>
/// An application can perform multithread drawing by making different rendering contexts current
/// to different threads, supplying each thread with its own rendering context and device context.
/// </para>
/// <para>
/// If an error occurs, the wglMakeCurrent function makes the thread's current rendering context not current
/// before returning.
/// </para>
/// </remarks>
[DllImport(_dll_name, EntryPoint = "wglMakeCurrent")]
[System.Security.SuppressUnmanagedCodeSecurity]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MakeCurrent(IntPtr dc, IntPtr rc);
#endregion
[DllImport(_dll_name, EntryPoint = "wglDeleteContext", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteContext(IntPtr rc);
[DllImport(_dll_name, EntryPoint = "wglGetCurrentContext")]
public static extern IntPtr GetCurrentContext();
[DllImport(_dll_name, EntryPoint = "wglGetCurrentDC")]
public static extern IntPtr GetCurrentDC();
[DllImport(_dll_name, EntryPoint = "wglShareLists")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShareLists(IntPtr r1, IntPtr r2);
#endregion
}
}

View file

@ -0,0 +1,276 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* Contributions from Erik Ylvisaker
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using OpenTK.OpenGL;
using System.Diagnostics;
namespace OpenTK.Platform.Windows
{
public sealed class WinGLContext : OpenTK.Platform.IGLContext, IDisposable
{
private IntPtr deviceContext;
private IntPtr renderContext;
static private IntPtr opengl32Handle;
static private readonly string opengl32Name = "OPENGL32.DLL";
private IntPtr windowHandle;
private bool disposed;
#region --- Contructors ---
public WinGLContext(IntPtr windowHandle)
: this(windowHandle, new DisplayMode(640, 480, new ColorDepth(32), 16, 0, 0, 2, false, false, false, 0.0f))
{
}
public WinGLContext(IntPtr windowHandle, DisplayMode mode)
{
Trace.WriteLine(String.Format("Creating opengl context (driver: {0})", this.ToString()));
Trace.Indent();
this.windowHandle = windowHandle;
Trace.WriteLine(String.Format("Window handle: {0}", windowHandle));
PrepareContext(mode);
CreateContext();
Trace.Unindent();
}
#endregion
public void CreateContext()
{
Trace.Write("Creating render context... ");
renderContext = Wgl.CreateContext(deviceContext);
Trace.WriteLine(String.Format("done! (id: {0})", renderContext));
}
public void PrepareContext(DisplayMode mode)
{
// Dynamically load the OpenGL32.dll in order to use the extension loading capabilities of Wgl.
if (opengl32Handle == IntPtr.Zero)
{
opengl32Handle = API.LoadLibrary(opengl32Name);
if (opengl32Handle == IntPtr.Zero)
{
//System.Diagnostics.Debug.WriteLine("LoadLibrary({0}) set error code: {1}. Will not load extensions.", _dll_name, error_code);
throw new ApplicationException(
String.Format(
"LoadLibrary(\"{0}\") call failed with code {1}",
opengl32Name,
Marshal.GetLastWin32Error()
)
);
}
Trace.WriteLine(String.Format("Loaded opengl32.dll: {0}", opengl32Handle));
}
deviceContext = API.GetDC(windowHandle);
Trace.WriteLine(String.Format("Device context: {0}", deviceContext));
Trace.Write("Setting pixel format... ");
API.PixelFormatDescriptor pixelFormat = new API.PixelFormatDescriptor();
pixelFormat.ColorBits = (byte)(mode.Color.Red + mode.Color.Green + mode.Color.Blue);
pixelFormat.RedBits = (byte)mode.Color.Red;
pixelFormat.GreenBits = (byte)mode.Color.Green;
pixelFormat.BlueBits = (byte)mode.Color.Blue;
pixelFormat.AlphaBits = (byte)mode.Color.Alpha;
/*
if (accum != null)
{
pixelFormat.AccumBits = (byte)(accum.Red + accum.Green + accum.Blue);
pixelFormat.AccumRedBits = (byte)accum.Red;
pixelFormat.AccumGreenBits = (byte)accum.Green;
pixelFormat.AccumBlueBits = (byte)accum.Blue;
pixelFormat.AccumAlphaBits = (byte)accum.Alpha;
}
*/
pixelFormat.DepthBits = (byte)mode.DepthBits;
pixelFormat.StencilBits = (byte)mode.StencilBits;
if (mode.DepthBits <= 0)
{
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.DEPTH_DONTCARE;
}
if (mode.Stereo)
{
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.STEREO;
}
if (mode.Buffers > 1)
{
pixelFormat.Flags |= API.PixelFormatDescriptorFlags.DOUBLEBUFFER;
}
// TODO: More elaborate mode setting, using DescribePixelFormat.
int pixel = API.ChoosePixelFormat(deviceContext, pixelFormat);
if (pixel == 0)
{
throw new ApplicationException("The requested pixel format is not supported by the hardware configuration.");
}
API.SetPixelFormat(deviceContext, pixel, pixelFormat);
Trace.WriteLine(String.Format("done! (format: {0})", pixel));
}
#region --- IGLContext Members ---
#region public void SwapBuffers()
public void SwapBuffers()
{
API.SwapBuffers(deviceContext);
}
#endregion
#region public IntPtr GetAddress(string function_string)
public IntPtr GetAddress(string function_string)
{
return Wgl.GetProcAddress(function_string);
}
#endregion
#region public void MakeCurrent()
public void MakeCurrent()
{
Wgl.MakeCurrent(deviceContext, renderContext);
}
#endregion
#region public DisplayMode[] GetDisplayModes()
public IEnumerable<DisplayMode> GetDisplayModes()
{
List<DisplayMode> modes = new List<DisplayMode>();
bool done = false;
int index = 0;
while (!done)
{
API.DeviceMode currentMode = new API.DeviceMode();
IntPtr handle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(API.DeviceMode)));
Marshal.StructureToPtr(currentMode, handle, true);
done = (API.EnumDisplaySettings(null, index++, handle) != 0) ? false : true;
int error = Marshal.GetLastWin32Error();
Marshal.PtrToStructure(handle, currentMode);
Marshal.FreeHGlobal(handle);
if (error != 0)
{
Console.WriteLine("Error: {0}", error);
continue;
}
if (done)
break;
//DisplayMode mode = new DisplayMode(currentMode.PelsWidth, currentMode.PelsHeight);
DisplayMode mode = new DisplayMode(
currentMode.PelsWidth,
currentMode.PelsHeight,
new ColorDepth(currentMode.BitsPerPel),
0,
0,
0,
0,
false,
false,
false,
currentMode.DisplayFrequency
);
modes.Add(mode);
}
return modes.ToArray();
}
#endregion
#endregion
#region --- IDisposable Members ---
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool calledManually)
{
if (!disposed)
{
// Clean unmanaged resources here:
Wgl.DeleteContext(renderContext);
API.ReleaseDC(windowHandle, deviceContext);
API.FreeLibrary(opengl32Handle);
if (calledManually)
{
// Safe to clean managed resources
}
disposed = true;
}
}
~WinGLContext()
{
Dispose(false);
}
#region public void ReleaseResources()
private void ReleaseResources()
{
if (renderContext != IntPtr.Zero)
{
if (!Wgl.DeleteContext(renderContext))
{
throw new ApplicationException(
"Could not destroy the OpenGL render context. Error: " + Marshal.GetLastWin32Error()
);
}
renderContext = IntPtr.Zero;
}
if (opengl32Handle != IntPtr.Zero)
{
if (!API.FreeLibrary(opengl32Handle))
{
throw new ApplicationException(
"FreeLibray call failed ('opengl32.dll'), Error: " + Marshal.GetLastWin32Error()
);
}
opengl32Handle = IntPtr.Zero;
}
}
#endregion
#endregion
}
}

View file

@ -0,0 +1,132 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* Contributions from Erik Ylvisaker
* See license.txt for license info
*/
#endregion
#region --- Using directives ---
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
#endregion
namespace OpenTK.Platform.Windows
{
sealed class WinGLControl : OpenTK.Platform.IGLControl
{
private WinGLContext glContext;
private bool fullscreen;
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
private bool disposed;
#region --- Constructors ---
public WinGLControl(Control c, int width, int height, bool fullscreen)
{
glContext = new WinGLContext(
c.Handle,
new DisplayMode(
width, height,
new ColorDepth(32),
16, 0, 0, 2,
fullscreen,
false,
false,
0.0f
)
);
}
#endregion
#region --- IGLControl membmers ---
public event CreateEvent Create;
#region public void ProcessEvents()
private API.Message msg;
public void ProcessEvents()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
#region public bool IsIdle
public bool IsIdle
{
get
{
return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
}
}
#endregion
#region public OpenTK.Platform.IGLContext Context
public OpenTK.Platform.IGLContext Context
{
get { return glContext; }
}
#endregion
#region public bool Fullscreen
public bool Fullscreen
{
get
{
return fullscreen;
}
set
{
throw new NotImplementedException();
fullscreen = true;
}
}
#endregion
#endregion
#region --- IDisposable Members ---
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool calledManually)
{
if (!disposed)
{
// Clean unmanaged resources here:
if (calledManually)
{
// Safe to clean managed resources
glContext.Dispose();
}
disposed = true;
}
}
~WinGLControl()
{
Dispose(false);
}
#endregion
}
}

View file

@ -0,0 +1,404 @@
#region --- License ---
/* Copyright (c) 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
#region --- Using directives ---
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using OpenTK.Input;
#endregion
namespace OpenTK.Platform.Windows
{
sealed class WinGLNative : NativeWindow, OpenTK.Platform.INativeWindow, IDisposable
{
private WinGLContext glContext;
private DisplayMode mode = new DisplayMode();
private bool disposed;
#region --- Contructors ---
/// <summary>
/// Constructs a new WinGLNative window, using safe defaults for the DisplayMode.
/// </summary>
public WinGLNative()
{
mode = new DisplayMode();
mode.Width = 640;
mode.Height = 480;
this.CreateWindow(mode);
}
#endregion
#region private void CreateWindow()
private void CreateWindow(DisplayMode mode)
{
CreateParams cp = new CreateParams();
cp.ClassStyle =
(int)API.WindowClassStyle.OwnDC |
(int)API.WindowClassStyle.VRedraw |
(int)API.WindowClassStyle.HRedraw;
cp.Style =
(int)API.WindowStyle.Visible |
(int)API.WindowStyle.ClipChildren |
(int)API.WindowStyle.ClipSiblings |
(int)API.WindowStyle.OverlappedWindow;
cp.Width = mode.Width;
cp.Height = mode.Height;
cp.Caption = "OpenTK Game Window";
base.CreateHandle(cp);
glContext = new WinGLContext(
this.Handle,
new DisplayMode(
width, height,
new ColorDepth(32),
16, 0, 0, 2,
fullscreen,
false,
false,
0.0f
)
);
}
/*
private void CreateWindow()
{
WinApi.WindowClass wc = new WinApi.WindowClass();
wc.style =
WinApi.WindowClassStyle.HRedraw |
WinApi.WindowClassStyle.VRedraw |
WinApi.WindowClassStyle.OwnDC;
wc.WindowProcedure = new WinApi.WindowProcedureEventHandler(WndProc);
wc.Instance = instance;
//wc.ClassName = Marshal.StringToHGlobalAuto(className);
wc.ClassName = className;
classAtom = WinApi.RegisterClass(wc);
if (classAtom == 0)
{
throw new Exception("Could not register class, error: " + Marshal.GetLastWin32Error());
}
// Change for fullscreen!
handle = WinApi.CreateWindowEx(
WinApi.ExtendedWindowStyle.ApplicationWindow |
WinApi.ExtendedWindowStyle.OverlappedWindow |
WinApi.ExtendedWindowStyle.Topmost,
className,
//Marshal.StringToHGlobalAuto("OpenTK Game Window"),
"OpenTK Game Window",
WinApi.WindowStyle.OverlappedWindow |
WinApi.WindowStyle.ClipChildren |
WinApi.WindowStyle.ClipSiblings,
0, 0,
640, 480,
IntPtr.Zero,
IntPtr.Zero,
instance,
IntPtr.Zero
);
if (handle == IntPtr.Zero)
{
throw new Exception("Could not create window, error: " + Marshal.GetLastWin32Error());
}
}
*/
#endregion
#region protected override void WndProc(ref Message m)
/// <summary>
/// For use in WndProc only.
/// </summary>
private int width, height;
/// <summary>
/// Processes incoming WM_* messages.
/// </summary>
/// <param name="m">Reference to the incoming Windows Message.</param>
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case API.Constants.WM_WINDOWPOSCHANGED:
// Get window size
width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.WindowPosition), "cx"));
height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.WindowPosition), "cy"));
//if (resizeEventArgs.Width != width || resizeEventArgs.Height != height)
if (mode.Width != width || mode.Height != height)
{
// If the size has changed, raise the ResizeEvent.
resizeEventArgs.Width = width;
resizeEventArgs.Height = height;
this.OnResize(resizeEventArgs);
// The message was processed.
return;
}
// If the message was not a resize notification, send it to the default WndProc.
break;
case API.Constants.WM_CREATE:
// Set the window width and height:
mode.Width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cx"));
mode.Height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(API.CreateStruct), "cy"));
// Raise the Create event
this.OnCreate(EventArgs.Empty);
// Raise the resize event:
//resizeEventArgs.Width = width;
//resizeEventArgs.Height = height;
//this.OnResize(resizeEventArgs);
return;
case API.Constants.WM_KEYDOWN:
case API.Constants.WM_KEYUP:
if (this.ProcessKey(ref m))
return;
else
break;
case API.Constants.WM_CLOSE:
API.PostQuitMessage(0);
return;
case API.Constants.WM_QUIT:
quit = true;
break;
}
base.WndProc(ref m);
}
private bool ProcessKey(ref Message m)
{
switch ((int)m.WParam)
{
case API.Constants.VK_ESCAPE:
Key.Escape = (m.Msg == API.Constants.WM_KEYDOWN) ? true : false;
return true;
}
return false;
}
#endregion
#region --- IGLWindow Members ---
#region public void ProcessEvents()
private System.Windows.Forms.Message msg;
public void ProcessEvents()
{
while (API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0))
{
API.GetMessage(out msg, IntPtr.Zero, 0, 0);
WndProc(ref msg);
}
}
#endregion
#region public event CreateEvent Create;
public event CreateEvent Create;
private void OnCreate(EventArgs e)
{
if (this.Create != null)
{
this.Create(this, e);
}
}
#endregion
#region public bool Quit
private bool quit;
public bool Quit
{
get { return quit; }
set
{
if (value)
{
API.PostQuitMessage(0);
//quit = true;
}
}
}
#endregion
#region public IGLContext Context
public IGLContext Context
{
get { return glContext; }
}
#endregion
#region public bool Fullscreen
bool fullscreen;
public bool Fullscreen
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#endregion
#region public bool IsIdle
public bool IsIdle
{
get
{
return !API.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0);
}
}
#endregion
#endregion
#region --- IDisposable Members ---
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool calledManually)
{
if (!disposed)
{
// Clean unmanaged resources here:
if (calledManually)
{
// Safe to clean managed resources
glContext.Dispose();
base.DestroyHandle();
}
disposed = true;
}
}
~WinGLNative()
{
Dispose(false);
}
#endregion
#region --- IResizable Members ---
#region public int Width
public int Width
{
get
{
return mode.Width;
}
set
{
throw new NotImplementedException();
//WinApi.PostMessage(
// this.Handle,
// WinApi.Constants.WM_WINDOWPOSCHANGING,
//mode.Width = value;
}
}
#endregion
#region public int Height
public int Height
{
get
{
return mode.Height;
}
set
{
throw new NotImplementedException();
//WinApi.PostMessage(
// this.Handle,
// WinApi.Constants.WM_WINDOWPOSCHANGING,
//mode.Height = value;
}
}
#endregion
#region public event ResizeEvent Resize
public event ResizeEvent Resize;
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
public void OnResize(ResizeEventArgs e)
{
mode.Width = e.Width;
mode.Height = e.Height;
if (this.Resize != null)
this.Resize(this, e);
}
#endregion
#endregion
}
#region class WindowHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
/*
class WindowHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
{
protected override bool ReleaseHandle()
{
throw new Exception("The method or operation is not implemented.");
}
public override bool IsInvalid
{
get
{
return base.IsInvalid;
}
}
}
*/
#endregion
}

View file

@ -0,0 +1,938 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* Contributions from Erik Ylvisaker
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace OpenTK.Platform.X11
{
#region Types
// using XID = System.Int32;
using Window = System.IntPtr;
using Drawable = System.IntPtr;
using Font = System.IntPtr;
using Pixmap = System.IntPtr;
using Cursor = System.IntPtr;
using Colormap = System.IntPtr;
using GContext = System.IntPtr;
using KeySym = System.IntPtr;
using Mask = System.IntPtr;
using Atom = System.IntPtr;
using VisualID = System.IntPtr;
using Time = System.UInt32;
using KeyCode = System.IntPtr; /* In order to use IME, the Macintosh needs
* to pack 3 bytes into the keyCode field in
* the XEvent. In the real X.h, a KeyCode is
* defined as a short, which wouldn't be big
* enough. */
using Display = System.IntPtr;
#endregion
#region internal static class API
internal static class API
{
// Prevent BeforeFieldInit optimization.
static API() { }
private const string _dll_name = "libX11";
private const string _dll_name_vid = "libXxf86vm";
// Display management
[DllImport(_dll_name, EntryPoint = "XOpenDisplay")]
extern internal static IntPtr OpenDisplay([MarshalAs(UnmanagedType.LPTStr)] string display_name);
[DllImport(_dll_name, EntryPoint = "XCloseDisplay")]
extern internal static void CloseDisplay(Display display);
[DllImport(_dll_name, EntryPoint = "XCreateColormap")]
extern internal static IntPtr CreateColormap(Display display, Window window, IntPtr visual, int alloc);
#region Window handling
[DllImport(_dll_name, EntryPoint = "XRootWindow")]
internal static extern Window RootWindow(Display display, int screen);
[DllImport(_dll_name, EntryPoint = "XCreateWindow")]
internal extern static Window CreateWindow(
Display display,
Window parent,
int x, int y,
uint width, uint height,
uint border_width,
int depth,
uint @class,
IntPtr visual,
[MarshalAs(UnmanagedType.SysUInt)] CreateWindowMask valuemask,
SetWindowAttributes attributes
);
[DllImport(_dll_name, EntryPoint = "XCreateSimpleWindow")]
internal extern static Window CreateSimpleWindow(
Display display,
Window parent,
int x, int y,
int width, int height,
int border_width,
long border,
long background
);
[DllImport(_dll_name, EntryPoint = "XResizeWindow")]
internal extern static int XResizeWindow(Display display, Window window, int width, int height);
[DllImport(_dll_name, EntryPoint = "XDestroyWindow")]
internal extern static void DestroyWindow(Display display, Window window);
[DllImport(_dll_name, EntryPoint = "XMapWindow")]
extern internal static void MapWindow(Display display, Window window);
[DllImport(_dll_name, EntryPoint = "XMapRaised")]
extern internal static void MapRaised(Display display, Window window);
#endregion
[DllImport(_dll_name, EntryPoint = "XDefaultScreen")]
extern internal static int DefaultScreen(Display display);
[DllImport(_dll_name, EntryPoint = "XDefaultVisual")]
extern internal static IntPtr DefaultVisual(Display display, int screen_number);
#region XFree
/// <summary>
/// Frees the memory used by an X structure. Only use on unmanaged structures!
/// </summary>
/// <param name="data">A pointer to the structure that will be freed.</param>
[DllImport(_dll_name, EntryPoint = "XFree")]
extern internal static void Free(IntPtr data);
#endregion
#region Event queue management
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport(_dll_name, EntryPoint = "XEventsQueued")]
extern internal static int EventsQueued(Display display, int mode);
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport(_dll_name, EntryPoint = "XPending")]
extern internal static int Pending(Display display);
//[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport(_dll_name, EntryPoint = "XNextEvent")]
extern internal static void NextEvent(
Display display,
[MarshalAs(UnmanagedType.AsAny)][In, Out]object e);
[DllImport(_dll_name, EntryPoint = "XNextEvent")]
extern internal static void NextEvent(Display display, [In, Out] IntPtr e);
[DllImport(_dll_name, EntryPoint = "XPeekEvent")]
extern internal static void PeekEvent(
Display display,
[MarshalAs(UnmanagedType.AsAny)][In, Out]object event_return
);
[DllImport(_dll_name, EntryPoint = "XPeekEvent")]
extern internal static void PeekEvent(
Display display,
[In, Out]Event event_return
);
[DllImport(_dll_name, EntryPoint = "XSendEvent")]
[return: MarshalAs(UnmanagedType.Bool)]
extern internal static bool SendEvent(
Display display,
Window window,
bool propagate,
[MarshalAs(UnmanagedType.SysInt)]
EventMask event_mask,
ref Event event_send
);
#endregion
#region Thing grabbin'
[DllImport(_dll_name, EntryPoint = "XGrabPointer")]
extern internal static ErrorCodes XGrabPointer(
Display display,
IntPtr grab_window,
bool owner_events, int event_mask,
GrabMode pointer_mode,
GrabMode keyboard_mode,
IntPtr confine_to,
IntPtr cursor,
int time
);
[DllImport(_dll_name, EntryPoint = "XUngrabPointer")]
extern internal static ErrorCodes XUngrabPointer(Display display, int time);
[DllImport(_dll_name, EntryPoint = "XGrabKeyboard")]
extern internal static ErrorCodes XGrabKeyboard(Display display, IntPtr grab_window,
bool owner_events, GrabMode pointer_mode, GrabMode keyboard_mode, int time);
[DllImport(_dll_name, EntryPoint = "XUngrabKeyboard")]
extern internal static void XUngrabKeyboard(Display display, int time);
#endregion
#region Xf86VidMode internal structures
[StructLayout(LayoutKind.Sequential)]
internal struct XF86VidModeModeLine
{
short hdisplay; /* Number of display pixels horizontally */
short hsyncstart; /* Horizontal sync start */
short hsyncend; /* Horizontal sync end */
short htotal; /* Total horizontal pixels */
short vdisplay; /* Number of display pixels vertically */
short vsyncstart; /* Vertical sync start */
short vsyncend; /* Vertical sync start */
short vtotal; /* Total vertical pixels */
int flags; /* Mode flags */
int privsize; /* Size of private */
IntPtr _private; /* Server privates */
}
/// <summary>
/// Specifies an XF86 display mode.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
internal struct XF86VidModeModeInfo
{
/// <summary>
/// Pixel clock.
/// </summary>
internal int dotclock;
/// <summary>
/// Number of display pixels horizontally
/// </summary>
internal short hdisplay;
/// <summary>
/// Horizontal sync start
/// </summary>
internal short hsyncstart;
/// <summary>
/// Horizontal sync end
/// </summary>
internal short hsyncend;
/// <summary>
/// Total horizontal pixel
/// </summary>
internal short htotal;
/// <summary>
///
/// </summary>
internal short hskew;
/// <summary>
/// Number of display pixels vertically
/// </summary>
internal short vdisplay;
/// <summary>
/// Vertical sync start
/// </summary>
internal short vsyncstart;
/// <summary>
/// Vertical sync end
/// </summary>
internal short vsyncend;
/// <summary>
/// Total vertical pixels
/// </summary>
internal short vtotal;
/// <summary>
///
/// </summary>
internal short vskew;
/// <summary>
/// Mode flags
/// </summary>
internal int flags;
int privsize; /* Size of private */
IntPtr _private; /* Server privates */
}
//Monitor information:
[StructLayout(LayoutKind.Sequential)]
internal struct XF86VidModeMonitor
{
[MarshalAs(UnmanagedType.LPStr)]
string vendor; /* Name of manufacturer */
[MarshalAs(UnmanagedType.LPStr)]
string model; /* Model name */
float EMPTY; /* unused, for backward compatibility */
byte nhsync; /* Number of horiz sync ranges */
/*XF86VidModeSyncRange* */
IntPtr hsync;/* Horizontal sync ranges */
byte nvsync; /* Number of vert sync ranges */
/*XF86VidModeSyncRange* */
IntPtr vsync;/* Vertical sync ranges */
}
[StructLayout(LayoutKind.Sequential)]
internal struct XF86VidModeSyncRange
{
float hi; /* Top of range */
float lo; /* Bottom of range */
}
[StructLayout(LayoutKind.Sequential)]
internal struct XF86VidModeNotifyEvent
{
int type; /* of event */
ulong serial; /* # of last request processed by server */
bool send_event; /* true if this came from a SendEvent req */
Display display; /* Display the event was read from */
IntPtr root; /* root window of event screen */
int state; /* What happened */
int kind; /* What happened */
bool forced; /* extents of new region */
/* Time */
IntPtr time; /* event timestamp */
}
[StructLayout(LayoutKind.Sequential)]
internal struct XF86VidModeGamma
{
float red; /* Red Gamma value */
float green; /* Green Gamma value */
float blue; /* Blue Gamma value */
}
#endregion
#region libXxf86vm Functions
[DllImport(_dll_name_vid)]
extern internal static bool XF86VidModeQueryExtension(
Display display,
out int event_base_return,
out int error_base_return);
/*
[DllImport(_dll_name_vid)]
extern internal static bool XF86VidModeSwitchMode(
Display display,
int screen,
int zoom);
*/
[DllImport(_dll_name_vid)]
extern internal static bool XF86VidModeSwitchToMode(
Display display,
int screen,
IntPtr
/*XF86VidModeModeInfo* */ modeline);
[DllImport(_dll_name_vid)]
extern internal static bool XF86VidModeQueryVersion(
Display display,
out int major_version_return,
out int minor_version_return);
[DllImport(_dll_name_vid)]
extern internal static bool XF86VidModeGetAllModeLines(
Display display,
int screen,
out int modecount_return,
/*XF86VidModeModeInfo*** <-- yes, that's three *'s. */
out IntPtr modesinfo);
[DllImport(_dll_name_vid)]
extern internal static bool XF86VidModeSetViewPort(
Display display,
int screen,
int x,
int y);
/*
Bool XF86VidModeSetClientVersion(
Display *display);
Bool XF86VidModeGetModeLine(
Display *display,
int screen,
int *dotclock_return,
XF86VidModeModeLine *modeline);
Bool XF86VidModeDeleteModeLine(
Display *display,
int screen,
XF86VidModeModeInfo *modeline);
Bool XF86VidModeModModeLine(
Display *display,
int screen,
XF86VidModeModeLine *modeline);
Status XF86VidModeValidateModeLine(
Display *display,
int screen,
XF86VidModeModeLine *modeline);
Bool XF86VidModeLockModeSwitch(
Display *display,
int screen,
int lock);
Bool XF86VidModeGetMonitor(
Display *display,
int screen,
XF86VidModeMonitor *monitor);
Bool XF86VidModeGetViewPort(
Display *display,
int screen,
int *x_return,
int *y_return);
XF86VidModeGetDotClocks(
Display *display,
int screen,
int *flags return,
int *number of clocks return,
int *max dot clock return,
int **clocks return);
XF86VidModeGetGamma(
Display *display,
int screen,
XF86VidModeGamma *Gamma);
XF86VidModeSetGamma(
Display *display,
int screen,
XF86VidModeGamma *Gamma);
XF86VidModeGetGammaRamp(
Display *display,
int screen,
int size,
unsigned short *red array,
unsigned short *green array,
unsigned short *blue array);
XF86VidModeSetGammaRamp(
Display *display,
int screen,
int size,
unsigned short *red array,
unsigned short *green array,
unsigned short *blue array);
XF86VidModeGetGammaRampSize(
Display *display,
int screen,
int *size);
* */
#endregion
}
#endregion
#region X11 Structures
#region internal class VisualInfo
[StructLayout(LayoutKind.Sequential)]
public class VisualInfo
{
internal IntPtr visual;
internal int visualid;
internal int screen;
internal int depth;
internal int @class;
internal long redMask;
internal long greenMask;
internal long blueMask;
internal int colormap_size;
internal int bits_per_rgb;
public override string ToString()
{
return base.ToString();
}
}
#endregion
#region internal class SetWindowAttributes
[StructLayout(LayoutKind.Sequential)]
internal class SetWindowAttributes
{
/// <summary>
/// background, None, or ParentRelative
/// </summary>
internal Pixmap background_pixmap;
/// <summary>
/// background pixel
/// </summary>
internal long background_pixel;
/// <summary>
/// border of the window or CopyFromParent
/// </summary>
internal Pixmap border_pixmap;
/// <summary>
/// border pixel value
/// </summary>
internal long border_pixel;
/// <summary>
/// one of bit gravity values
/// </summary>
internal int bit_gravity;
/// <summary>
/// one of the window gravity values
/// </summary>
internal int win_gravity;
/// <summary>
/// NotUseful, WhenMapped, Always
/// </summary>
internal int backing_store;
/// <summary>
/// planes to be preserved if possible
/// </summary>
internal long backing_planes;
/// <summary>
/// value to use in restoring planes
/// </summary>
internal long backing_pixel;
/// <summary>
/// should bits under be saved? (popups)
/// </summary>
internal bool save_under;
/// <summary>
/// set of events that should be saved
/// </summary>
internal EventMask event_mask;
/// <summary>
/// set of events that should not propagate
/// </summary>
internal long do_not_propagate_mask;
/// <summary>
/// boolean value for override_redirect
/// </summary>
internal bool override_redirect;
/// <summary>
/// color map to be associated with window
/// </summary>
internal Colormap colormap;
/// <summary>
/// cursor to be displayed (or None)
/// </summary>
internal Cursor cursor;
}
#endregion
#region internal struct SizeHints
[StructLayout(LayoutKind.Sequential)]
internal struct SizeHints
{
internal long flags; /* marks which fields in this structure are defined */
internal int x, y; /* Obsolete */
internal int width, height; /* Obsolete */
internal int min_width, min_height;
internal int max_width, max_height;
internal int width_inc, height_inc;
internal struct min_aspect
{
internal int x; /* numerator */
internal int y; /* denominator */
}
internal struct max_aspect
{
internal int x; /* numerator */
internal int y; /* denominator */
}
internal int base_width, base_height;
internal int win_gravity;
/* this structure may be extended in the future */
}
#endregion
#region Event structures
#region XEvent
[StructLayout(LayoutKind.Sequential)]
//[StructLayout(LayoutKind.Explicit)]
internal class Event
{
internal EventType Type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=192)]
byte[] pad = new byte[192];
/*[FieldOffset(0)]internal EventType Type;*/
/*[FieldOffset(0)]
IntPtr
pad1 , pad2 , pad3 , pad4 , pad5 , pad6 ,
pad7 , pad8 , pad9 , pad10, pad11, pad12,
pad13, pad14, pad15, pad16, pad17, pad18,
pad19, pad20, pad21, pad22, pad23, pad24;*/
/*private ConfigureNotifyEvent cne = new ConfigureNotifyEvent();
internal ConfigureNotifyEvent ConfigureEvent
{
get
{
cne.type = this.Type;
cne.serial = this.pad1;
}
}*/
//[FieldOffset(0)]internal AnyEvent Any;
//[FieldOffset(0)]internal KeyEvent Key;
//[FieldOffset(0)]internal DestroyWindowEvent DestroyWindow;
//[FieldOffset(0)]internal CreateWindowEvent CreateWindow;
//[FieldOffset(0)]internal ResizeRequestEvent ResizeRequest;
//[FieldOffset(0)]internal ConfigureNotifyEvent ConfigureNotify;
//[FieldOffset(0)]internal ReparentNotifyEvent ReparentNotify;
//[FieldOffset(0)]internal ExposeEvent Expose;
}
#endregion
#region XAnyEvent
[StructLayout(LayoutKind.Sequential)]
internal class AnyEvent
{
internal EventType type;
//[MarshalAs(UnmanagedType.SysUInt)]
internal IntPtr serial; /* # of last request processed by server */
[MarshalAs(UnmanagedType.Bool)]
internal bool send_event; /* true if this came from a SendEvent request */
internal Display display; /* Display the event was read from */
internal Window window;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=192)]
byte[] pad = new byte[192];
}
#endregion
#region XKeyEvent
[StructLayout(LayoutKind.Sequential)]
internal class KeyEvent
{
internal EventType type; /* KeyPress or KeyRelease */
[MarshalAs(UnmanagedType.SysUInt)]
internal ulong serial; /* # of last request processed by server */
[MarshalAs(UnmanagedType.Bool)]
internal bool send_event; /* true if this came from a SendEvent request */
internal Display display; /* Display the event was read from */
internal Window window; /* ``event'' window it is reported relative to */
internal Window root; /* root window that the event occurred on */
internal Window subwindow; /* child window */
[MarshalAs(UnmanagedType.SysUInt)]
internal Time time; /* milliseconds */
internal int x, y; /* pointer x, y coordinates in event window */
internal int x_root, y_root; /* coordinates relative to root */
internal uint state; /* key or button mask */
internal uint keycode; /* detail */
[MarshalAs(UnmanagedType.Bool)]
internal bool same_screen; /* same screen flag */
[MarshalAs(UnmanagedType.ByValArray, SizeConst=192)]
byte[] pad = new byte[192];
}
#endregion
#region XDestroyWindowEvent
[StructLayout(LayoutKind.Sequential)]
internal class DestroyWindowEvent
{
internal EventType type; /* DestroyNotify */
internal ulong serial; /* # of last request processed by server */
[MarshalAs(UnmanagedType.Bool)]
internal bool send_event; /* true if this came from a SendEvent request */
internal Display display; /* Display the event was read from */
internal Window @event;
internal Window window;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=192)]
byte[] pad = new byte[192];
}
#endregion
#region XCreateWindowEvent
[StructLayout(LayoutKind.Sequential)]
internal class CreateWindowEvent
{
internal EventType type; /* CreateNotify */
internal ulong serial; /* # of last request processed by server */
[MarshalAs(UnmanagedType.Bool)]
internal bool send_event; /* true if this came from a SendEvent request */
internal Display display; /* Display the event was read from */
internal Window parent; /* parent of the window */
internal Window window; /* window id of window created */
internal int x, y; /* window location */
internal int width, height; /* size of window */
internal int border_width; /* border width */
[MarshalAs(UnmanagedType.Bool)]
internal bool override_redirect; /* creation should be overridden */
[MarshalAs(UnmanagedType.ByValArray, SizeConst=192)]
byte[] pad = new byte[192];
}
#endregion
#region XResizeRequestEvent
[StructLayout(LayoutKind.Sequential)]
internal class ResizeRequestEvent
{
internal EventType type; /* ResizeRequest */
internal ulong serial; /* # of last request processed by server */
[MarshalAs(UnmanagedType.Bool)]
internal bool send_event; /* true if this came from a SendEvent request */
internal Display display; /* Display the event was read from */
internal Window window;
internal int width, height;
}
#endregion
#region XConfigureNotifyEvent
[StructLayout(LayoutKind.Sequential)]
internal class ConfigureNotifyEvent
{
internal EventType type; /* ConfigureNotify */
internal ulong serial; /* # of last request processed by server */
[MarshalAs(UnmanagedType.Bool)]
internal bool send_event; /* true if this came from a SendEvent request */
internal Display display; /* Display the event was read from */
internal Window @event;
internal Window window;
internal int x, y;
internal int width, height;
internal int border_width;
internal Window above;
[MarshalAs(UnmanagedType.Bool)]
internal bool override_redirect;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=192)]
byte[] pad = new byte[192];
}
#endregion
#region XReparentNotifyEvent
[StructLayout(LayoutKind.Sequential)]
internal class ReparentNotifyEvent
{
internal EventType type; /* ReparentNotify */
//[MarshalAs(UnmanagedType.SysUInt)]
internal IntPtr serial; /* # of last request processed by server */
//[MarshalAs(UnmanagedType.Bool)]
internal bool send_event; /* true if this came from a SendEvent request */
internal Display display; /* Display the event was read from */
internal Window @event;
internal Window window;
internal Window parent;
internal int x, y;
//[MarshalAs(UnmanagedType.Bool)]
internal bool override_redirect;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=192)]
byte[] pad = new byte[192];
}
#endregion
#region XExposeEvent
[StructLayout(LayoutKind.Sequential)]
internal class ExposeEvent
{
internal EventType type; /* Expose */
internal ulong serial; /* # of last request processed by server */
[MarshalAs(UnmanagedType.Bool)]
internal bool send_event; /* true if this came from a SendEvent request */
internal Display display; /* Display the event was read from */
internal Window window;
internal int x, y;
internal int width, height;
internal int count; /* if nonzero, at least this many more */
[MarshalAs(UnmanagedType.ByValArray, SizeConst=192)]
byte[] pad = new byte[192];
}
#endregion
#endregion
#endregion
#region X11 Constants and Enums
internal struct Constants
{
internal const int QueuedAlready = 0;
internal const int QueuedAfterReading = 1;
internal const int QueuedAfterFlush = 2;
internal const int CopyFromParent = 0;
internal const int CWX = 1;
internal const int InputOutput = 1;
internal const int InputOnly = 2;
}
internal enum EventType : int
{
NoEventMask = 0,
FocusOut = 10,
KeymapNotify = 11,
Expose = 12,
GraphicsExpose = 13,
NoExpose = 14,
VisibilityNotify = 15,
CreateNotify = 16,
DestroyNotify = 17,
UnmapNotify = 18,
MapNotify = 19,
KeyPress = 2,
MapRequest = 20,
ReparentNotify = 21,
ConfigureNotify = 22,
ConfigureRequest = 23,
GravityNotify = 24,
ResizeRequest = 25,
CirculateNotify = 26,
CirculateRequest = 27,
PropertyNotify = 28,
SelectionClear = 29,
KeyRelease = 3,
SelectionRequest = 30,
SelectionNotify = 31,
ColormapNotify = 32,
ClientMessage = 33,
MappingNotify = 34,
LASTEvent = 35,
ButtonPress = 4,
ButtonRelease = 5,
MotionNotify = 6,
EnterNotify = 7,
LeaveNotify = 8,
FocusIn = 9,
}
internal enum ErrorCodes : int
{
Success = 0,
BadRequest = 1,
BadValue = 2,
BadWindow = 3,
BadPixmap = 4,
BadAtom = 5,
BadCursor = 6,
BadFont = 7,
BadMatch = 8,
BadDrawable = 9,
BadAccess = 10,
BadAlloc = 11,
BadColor = 12,
BadGC = 13,
BadIDChoice = 14,
BadName = 15,
BadLength = 16,
BadImplementation = 17,
}
internal enum GrabMode : int
{
Sync = 0,
Async = 1,
}
[Flags]
internal enum EventMask : ulong
{
NoEventMask = 0,
KeyPressMask = (1L<<0),
KeyReeaseMask = (1L<<1),
Button3MotionMask = (1L<<10),
Button4MotionMask = (1L<<11),
Button5MotionMask = (1L<<12),
ButtonMotionMask = (1L<<13),
KeymapStateMask = (1L<<14),
ExposureMask = (1L<<15),
VisibiityChangeMask = (1L<<16),
StructureNotifyMask = (1L<<17),
ResizeRedirectMask = (1L<<18),
SubstructureNotifyMask = (1L<<19),
ButtonPressMask = (1L<<2),
SubstructureRedirectMask = (1L<<20),
FocusChangeMask = (1L<<21),
PropertyChangeMask = (1L<<22),
CoormapChangeMask = (1L<<23),
ButtonReeaseMask = (1L<<3),
EnterWindowMask = (1L<<4),
eaveWindowMask = (1L<<5),
PointerMotionMask = (1L<<6),
PointerMotionHintMask = (1L<<7),
Button1MotionMask = (1L<<8),
Button2MotionMask = (1L<<9),
}
[Flags]
internal enum CreateWindowMask : ulong
{
CWBackPixmap = (1L<<0),
CWBackPixel = (1L<<1),
CWSaveUnder = (1L<<10),
CWEventMask = (1L<<11),
CWDontPropagate = (1L<<12),
CWColormap = (1L<<13),
CWCursor = (1L<<14),
CWBorderPixmap = (1L<<2),
CWBorderPixel = (1L<<3),
CWBitGravity = (1L<<4),
CWWinGravity = (1L<<5),
CWBackingStore = (1L<<6),
CWBackingPlanes = (1L<<7),
CWBackingPixel = (1L<<8),
CWOverrideRedirect = (1L<<9),
/*
CWY = (1<<1),
CWWidth = (1<<2),
CWHeight = (1<<3),
CWBorderWidth = (1<<4),
CWSibling = (1<<5),
CWStackMode = (1<<6),
*/
}
#endregion
}

View file

@ -0,0 +1,324 @@
#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* Contributions from Erik Ylvisaker
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace OpenTK.Platform.X11
{
#region Types
using GLsizeiptrARB = System.IntPtr;
using GLintptrARB = System.IntPtr;
using GLhandleARB = System.Int32;
using GLhalfARB = System.Int16;
using GLhalfNV = System.Int16;
using GLcharARB = System.Char;
using GLsizei = System.Int32;
using GLsizeiptr = System.IntPtr;
using GLintptr = System.IntPtr;
using GLenum = System.Int32;
using GLboolean = System.Boolean;
using GLbitfield = System.Int32;
using GLchar = System.Char;
using GLbyte = System.Byte;
using GLubyte = System.Byte;
using GLshort = System.Int16;
using GLushort = System.Int16;
using GLint = System.Int32;
using GLuint = System.Int32;
using GLfloat = System.Single;
using GLclampf = System.Single;
using GLdouble = System.Double;
using GLclampd = System.Double;
using GLstring = System.String;
#endregion
/// <summary>
/// Provides access to GLX functions.
/// </summary>
internal static class Glx
{
// Disable BeforeFieldInit optimization.
static Glx() { }
const string _dll_name = "libGL.so.1";
#region Enums
public struct Enums
{
public enum GLXAttribute : int
{
TRANSPARENT_BLUE_VALUE_EXT = 0x27,
GRAY_SCALE = 0x8006,
RGBA_TYPE = 0x8014,
TRANSPARENT_RGB_EXT = 0x8008,
ACCUM_BLUE_SIZE = 16,
SHARE_CONTEXT_EXT = 0x800A,
STEREO = 6,
ALPHA_SIZE = 11,
FLOAT_COMPONENTS_NV = 0x20B0,
NONE = 0x8000,
DEPTH_SIZE = 12,
TRANSPARENT_INDEX_VALUE_EXT = 0x24,
MAX_PBUFFER_WIDTH_SGIX = 0x8016,
GREEN_SIZE = 9,
X_RENDERABLE_SGIX = 0x8012,
LARGEST_PBUFFER = 0x801C,
DONT_CARE = unchecked((int)0xFFFFFFFF),
TRANSPARENT_ALPHA_VALUE_EXT = 0x28,
PSEUDO_COLOR_EXT = 0x8004,
USE_GL = 1,
SAMPLE_BUFFERS_SGIS = 100000,
TRANSPARENT_GREEN_VALUE_EXT = 0x26,
HYPERPIPE_ID_SGIX = 0x8030,
COLOR_INDEX_TYPE_SGIX = 0x8015,
SLOW_CONFIG = 0x8001,
PRESERVED_CONTENTS = 0x801B,
ACCUM_RED_SIZE = 14,
EVENT_MASK = 0x801F,
VISUAL_ID_EXT = 0x800B,
EVENT_MASK_SGIX = 0x801F,
SLOW_VISUAL_EXT = 0x8001,
TRANSPARENT_GREEN_VALUE = 0x26,
MAX_PBUFFER_WIDTH = 0x8016,
DIRECT_COLOR_EXT = 0x8003,
VISUAL_ID = 0x800B,
ACCUM_GREEN_SIZE = 15,
DRAWABLE_TYPE_SGIX = 0x8010,
SCREEN_EXT = 0x800C,
SAMPLES = 100001,
HEIGHT = 0x801E,
TRANSPARENT_INDEX_VALUE = 0x24,
SAMPLE_BUFFERS_ARB = 100000,
PBUFFER = 0x8023,
RGBA_TYPE_SGIX = 0x8014,
MAX_PBUFFER_HEIGHT = 0x8017,
FBCONFIG_ID_SGIX = 0x8013,
DRAWABLE_TYPE = 0x8010,
SCREEN = 0x800C,
RED_SIZE = 8,
VISUAL_SELECT_GROUP_SGIX = 0x8028,
VISUAL_CAVEAT_EXT = 0x20,
PSEUDO_COLOR = 0x8004,
PBUFFER_HEIGHT = 0x8040,
STATIC_GRAY = 0x8007,
PRESERVED_CONTENTS_SGIX = 0x801B,
RGBA_FLOAT_TYPE_ARB = 0x20B9,
TRANSPARENT_RED_VALUE = 0x25,
TRANSPARENT_ALPHA_VALUE = 0x28,
WINDOW = 0x8022,
X_RENDERABLE = 0x8012,
STENCIL_SIZE = 13,
TRANSPARENT_RGB = 0x8008,
LARGEST_PBUFFER_SGIX = 0x801C,
STATIC_GRAY_EXT = 0x8007,
TRANSPARENT_BLUE_VALUE = 0x27,
DIGITAL_MEDIA_PBUFFER_SGIX = 0x8024,
BLENDED_RGBA_SGIS = 0x8025,
NON_CONFORMANT_VISUAL_EXT = 0x800D,
COLOR_INDEX_TYPE = 0x8015,
TRANSPARENT_RED_VALUE_EXT = 0x25,
GRAY_SCALE_EXT = 0x8006,
WINDOW_SGIX = 0x8022,
X_VISUAL_TYPE = 0x22,
MAX_PBUFFER_HEIGHT_SGIX = 0x8017,
DOUBLEBUFFER = 5,
OPTIMAL_PBUFFER_WIDTH_SGIX = 0x8019,
X_VISUAL_TYPE_EXT = 0x22,
WIDTH_SGIX = 0x801D,
STATIC_COLOR_EXT = 0x8005,
BUFFER_SIZE = 2,
DIRECT_COLOR = 0x8003,
MAX_PBUFFER_PIXELS = 0x8018,
NONE_EXT = 0x8000,
HEIGHT_SGIX = 0x801E,
RENDER_TYPE = 0x8011,
FBCONFIG_ID = 0x8013,
TRANSPARENT_INDEX_EXT = 0x8009,
TRANSPARENT_INDEX = 0x8009,
TRANSPARENT_TYPE_EXT = 0x23,
ACCUM_ALPHA_SIZE = 17,
PBUFFER_SGIX = 0x8023,
MAX_PBUFFER_PIXELS_SGIX = 0x8018,
OPTIMAL_PBUFFER_HEIGHT_SGIX = 0x801A,
DAMAGED = 0x8020,
SAVED_SGIX = 0x8021,
TRANSPARENT_TYPE = 0x23,
MULTISAMPLE_SUB_RECT_WIDTH_SGIS = 0x8026,
NON_CONFORMANT_CONFIG = 0x800D,
BLUE_SIZE = 10,
TRUE_COLOR_EXT = 0x8002,
SAMPLES_SGIS = 100001,
SAMPLES_ARB = 100001,
TRUE_COLOR = 0x8002,
RGBA = 4,
AUX_BUFFERS = 7,
SAMPLE_BUFFERS = 100000,
SAVED = 0x8021,
MULTISAMPLE_SUB_RECT_HEIGHT_SGIS = 0x8027,
DAMAGED_SGIX = 0x8020,
STATIC_COLOR = 0x8005,
PBUFFER_WIDTH = 0x8041,
WIDTH = 0x801D,
LEVEL = 3,
CONFIG_CAVEAT = 0x20,
RENDER_TYPE_SGIX = 0x8011,
}
public enum GLXHyperpipeAttrib : int
{
PIPE_RECT_LIMITS_SGIX = 0x00000002,
PIPE_RECT_SGIX = 0x00000001,
HYPERPIPE_STEREO_SGIX = 0x00000003,
HYPERPIPE_PIXEL_AVERAGE_SGIX = 0x00000004,
}
public enum GLXStringName : int
{
EXTENSIONS = 0x3,
VERSION = 0x2,
VENDOR = 0x1,
}
public enum GLXEventMask : int
{
PBUFFER_CLOBBER_MASK = 0x08000000,
BUFFER_CLOBBER_MASK_SGIX = 0x08000000,
}
public enum GLXRenderTypeMask : int
{
COLOR_INDEX_BIT_SGIX = 0x00000002,
RGBA_BIT = 0x00000001,
RGBA_FLOAT_BIT_ARB = 0x00000004,
RGBA_BIT_SGIX = 0x00000001,
COLOR_INDEX_BIT = 0x00000002,
}
public enum GLXHyperpipeTypeMask : int
{
HYPERPIPE_RENDER_PIPE_SGIX = 0x00000002,
HYPERPIPE_DISPLAY_PIPE_SGIX = 0x00000001,
}
public enum GLXPbufferClobberMask : int
{
ACCUM_BUFFER_BIT_SGIX = 0x00000080,
FRONT_LEFT_BUFFER_BIT = 0x00000001,
BACK_RIGHT_BUFFER_BIT = 0x00000008,
FRONT_RIGHT_BUFFER_BIT_SGIX = 0x00000002,
STENCIL_BUFFER_BIT_SGIX = 0x00000040,
SAMPLE_BUFFERS_BIT_SGIX = 0x00000100,
STENCIL_BUFFER_BIT = 0x00000040,
BACK_RIGHT_BUFFER_BIT_SGIX = 0x00000008,
BACK_LEFT_BUFFER_BIT_SGIX = 0x00000004,
AUX_BUFFERS_BIT = 0x00000010,
DEPTH_BUFFER_BIT_SGIX = 0x00000020,
ACCUM_BUFFER_BIT = 0x00000080,
AUX_BUFFERS_BIT_SGIX = 0x00000010,
DEPTH_BUFFER_BIT = 0x00000020,
FRONT_LEFT_BUFFER_BIT_SGIX = 0x00000001,
BACK_LEFT_BUFFER_BIT = 0x00000004,
FRONT_RIGHT_BUFFER_BIT = 0x00000002,
}
public enum GLXHyperpipeMisc : int
{
HYPERPIPE_PIPE_NAME_LENGTH_SGIX = 80,
}
public enum GLXErrorCode : int
{
BAD_CONTEXT = 5,
NO_EXTENSION = 3,
BAD_HYPERPIPE_SGIX = 92,
BAD_ENUM = 7,
BAD_SCREEN = 1,
BAD_VALUE = 6,
BAD_ATTRIBUTE = 2,
BAD_VISUAL = 4,
BAD_HYPERPIPE_CONFIG_SGIX = 91,
}
public enum GLXSyncType : int
{
SYNC_SWAP_SGIX = 0x00000001,
SYNC_FRAME_SGIX = 0x00000000,
}
public enum GLXDrawableTypeMask : int
{
WINDOW_BIT = 0x00000001,
PIXMAP_BIT = 0x00000002,
PBUFFER_BIT_SGIX = 0x00000004,
PBUFFER_BIT = 0x00000004,
WINDOW_BIT_SGIX = 0x00000001,
PIXMAP_BIT_SGIX = 0x00000002,
}
}
#endregion
#region GLX functions
[DllImport(_dll_name, EntryPoint = "glXCreateContext")]
internal static extern IntPtr CreateContext(IntPtr dpy, IntPtr vis, IntPtr shareList, bool direct);
internal static IntPtr CreateContext(IntPtr dpy, VisualInfo vis, IntPtr shareList, bool direct)
{
GCHandle h0 = GCHandle.Alloc(vis, GCHandleType.Pinned);
try
{
return CreateContext(dpy, h0.AddrOfPinnedObject(), shareList, direct);
}
finally
{
h0.Free();
}
}
[DllImport(_dll_name, EntryPoint = "glXDestroyContext")]
public static extern void DestroyContext(IntPtr dpy, IntPtr context);
[DllImport(_dll_name, EntryPoint = "glXMakeCurrent")]
public static extern bool MakeCurrent(IntPtr display, IntPtr drawable, IntPtr context);
[DllImport(_dll_name, EntryPoint = "glXSwapBuffers")]
public static extern void SwapBuffers(IntPtr display, IntPtr drawable);
[DllImport(_dll_name, EntryPoint = "glXGetProcAddress")]
public static extern IntPtr GetProcAddress([MarshalAs(UnmanagedType.LPTStr)] string procName);
#region glXChooseVisual
[DllImport(_dll_name, EntryPoint = "glXChooseVisual")]
internal extern static IntPtr ChooseVisual(IntPtr dpy, int screen, IntPtr attriblist);
internal static IntPtr ChooseVisual(IntPtr dpy, int screen, int[] attriblist)
{
GCHandle h0 = GCHandle.Alloc(attriblist, GCHandleType.Pinned);
try
{
return ChooseVisual(dpy, screen, h0.AddrOfPinnedObject());
}
finally
{
h0.Free();
}
}
#endregion
#endregion
}
}

View file

@ -0,0 +1,302 @@
#region --- License ---
/* Copyright (c) 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using OpenTK.OpenGL;
namespace OpenTK.Platform.X11
{
public class X11GLContext : OpenTK.Platform.IGLContext
{
private IntPtr x11context;
private IntPtr display;
private int screenNo;
private DisplayMode mode;// = new DisplayMode();
internal X11WindowInfo windowInfo = new X11WindowInfo();
private VisualInfo visualInfo;
//private IntPtr desktopResolution = IntPtr.Zero;
//private int depthBits;
//private int stencilBits;
// These have to be used by the X11GLControl.
internal IntPtr visual;
internal IntPtr colormap;
private bool disposed;
#region --- Public Constructor ---
private X11GLContext()
{
this.mode = new DisplayMode();
}
public X11GLContext(IWindowInfo info, DisplayMode mode)
{
X11WindowInfo xInfo = info as X11WindowInfo;
this.windowInfo.Window = xInfo.Window;
this.windowInfo.RootWindow = xInfo.RootWindow;
this.windowInfo.TopLevelWindow = xInfo.TopLevelWindow;
this.windowInfo.Display = xInfo.Display;
this.windowInfo.Screen = xInfo.Screen;
this.mode = mode;
}
public X11GLContext(
IntPtr handle,
IntPtr display,
IntPtr rootWindow,
int screenNo,
IntPtr handleToTopLevelControl,
ColorDepth color,
ColorDepth accum,
int depthBits,
int stencilBits,
int auxBits,
bool stereo,
bool doublebuffer
)
{
Trace.WriteLine("Creating opengl context (X11GLContext driver)");
Trace.Indent();
this.display = display;
this.screenNo = screenNo;
//this.depthBits = depthBits;
//this.stencilBits = stencilBits;
this.CreateVisual();
}
#endregion
#region --- IGLContext Members ---
#region public void SwapBuffers()
public void SwapBuffers()
{
Glx.SwapBuffers(windowInfo.Display, windowInfo.Window);
}
#endregion
#region public void MakeCurrent()
public void MakeCurrent()
{
Debug.Write(
String.Format(
"Making context {0} current on thread {1} (display: {2}, window: {3})... ",
x11context,
System.Threading.Thread.CurrentThread.ManagedThreadId,
windowInfo.Display,
windowInfo.Window
)
);
bool result = Glx.MakeCurrent(windowInfo.Display, windowInfo.Window, x11context);
if (!result)
{
Debug.WriteLine(String.Format("Failed to make context {0} current.", x11context));
// probably need to recreate context here.
throw new Exception(String.Format("Failed to make context {0} current.", x11context));
}
else
{
Debug.WriteLine("done!");
}
}
#endregion
public bool IsCurrent()
{
throw new NotImplementedException();
}
#region public IntPtr GetAddress(string function)
public IntPtr GetAddress(string function)
{
return Glx.GetProcAddress(function);
}
#endregion
public IEnumerable<DisplayMode> GetDisplayModes()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
#region --- IDisposable Members ---
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool manuallyCalled)
{
if (!disposed)
{
// Clean unmanaged resources:
Glx.DestroyContext(windowInfo.Display, x11context);
API.Free(visual);
if (manuallyCalled)
{
// Safe to clean managed resources, too
}
}
disposed = true;
}
~X11GLContext()
{
this.Dispose(false);
}
#endregion
#region public void CreateContext(X11GLContext shareContext, bool direct)
public void CreateContext(X11GLContext shareContext, bool direct)
{
Trace.WriteLine("Creating opengl context.");
Trace.Indent();
IntPtr shareHandle = shareContext != null ? shareContext.Handle : IntPtr.Zero;
Trace.WriteLine(
shareHandle == IntPtr.Zero ?
"Context is not shared." :
String.Format("Context is shared with context: {0}", shareHandle)
);
Trace.WriteLine(
direct ?
"Context is direct." :
"Context is indirect."
);
x11context = Glx.CreateContext(
windowInfo.Display,
visual,
shareHandle,
direct
);
Trace.WriteLine(String.Format("New opengl context created. (id: {0})", x11context));
Trace.Unindent();
//MakeCurrent();
}
#endregion
#region public void CreateVisual()
public void CreateVisual()
{
Trace.WriteLine("Creating visual.");
Trace.Indent();
ColorDepth color = new ColorDepth(24);
int depthBits = 16;
// Create the Visual
List<int> visualAttributes = new List<int>();
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RGBA);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RED_SIZE);
visualAttributes.Add((int)color.Red);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.GREEN_SIZE);
visualAttributes.Add((int)color.Green);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.BLUE_SIZE);
visualAttributes.Add((int)color.Blue);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
visualAttributes.Add((int)color.Alpha);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
visualAttributes.Add((int)depthBits);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
/*
List<int> visualAttributes = new List<int>();
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RGBA);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RED_SIZE);
visualAttributes.Add((int)mode.Color.Red);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.GREEN_SIZE);
visualAttributes.Add((int)mode.Color.Green);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.BLUE_SIZE);
visualAttributes.Add((int)mode.Color.Blue);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
visualAttributes.Add((int)mode.Color.Alpha);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
visualAttributes.Add((int)depthBits);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
*/
Trace.Write(
String.Format(
"Requesting visual: {0} ({1}{2}{3}{4})... ",
mode.ToString(),
mode.Color.Red,
mode.Color.Green,
mode.Color.Blue,
mode.Color.Alpha
)
);
visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, visualAttributes.ToArray());
if (visual == IntPtr.Zero)
{
throw new Exception("Requested visual not available.");
}
visualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo));
Trace.WriteLine(String.Format("done! (id: {0})", x11context));
Trace.Unindent();
}
#endregion
public IntPtr XVisual
{
get { return this.visual; }
}
public VisualInfo XVisualInfo
{
get { return this.visualInfo; }
}
public IntPtr XColormap
{
get { return colormap; }
}
public IntPtr Handle
{
get { return this.x11context; }
}
/*
public IntPtr ContainingWindow
{
get { return windowInfo.Window; }
internal set { windowInfo.Window = value; }
}
*/
}
}

View file

@ -0,0 +1,219 @@
#region --- License ---
/* Copyright (c) 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;
namespace OpenTK.Platform.X11
{
sealed class X11GLControl : IGLControl
{
X11WindowInfo info = new X11WindowInfo();
private Type xplatui;
X11GLContext glContext;
private bool quit;
private bool disposed;
#region --- Contructors ---
public X11GLControl(UserControl c, int width, int height, bool fullscreen)
{
Trace.WriteLine("Creating opengl control (X11GLControl driver)");
Trace.Indent();
c.ParentChanged += new EventHandler(c_ParentChanged);
if (c.ParentForm != null)
throw new Exception("I was stupid!");
if (c == null/* || c.TopLevelControl == null*/)
{
throw new Exception("Attempted to bind to non-existent control.");
}
info.Window = c.Handle;
Trace.WriteLine(
String.Format(
"Binding to control: {0}",
String.IsNullOrEmpty(c.Name) ? c.Text : c.Name
)
);
xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
Trace.WriteLine("Acquired System.Windows.Forms.XplatUIX11 type.");
if (xplatui != null)
{
info.Display = (IntPtr)xplatui.GetField("DisplayHandle",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic).GetValue(null);
info.RootWindow = (IntPtr)xplatui.GetField("RootWindow",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic).GetValue(null);
info.Screen = (int)xplatui.GetField("ScreenNo",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic).GetValue(null);
Trace.WriteLine(
String.Format(
"Screen: {0}, Display: {1}, Root Window: {2}, Control: {3}",
info.Screen,
info.Display,
info.RootWindow,
info.Window
)
);
glContext = new X11GLContext(info, new DisplayMode(
width, height, new ColorDepth(24), 16, 0, 0, 2, false, false, false, 0.0f)
);
glContext.CreateVisual();
xplatui.GetField(
"CustomVisual",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic).SetValue(
null,
glContext.XVisual
);
xplatui.GetField(
"CustomColormap",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic).SetValue(
null,
glContext.XColormap
);
glContext.CreateContext(null, true);
}
}
void c_ParentChanged(object sender, EventArgs e)
{
UserControl c = sender as UserControl;
Trace.WriteLine(
String.Format(
"TopLevel control is {0}",
c.TopLevelControl != null ? c.TopLevelControl.ToString() : "not available"
)
);
if (c.TopLevelControl == null)
{
info.TopLevelWindow = c.Handle;
throw new Exception("GLControl does not have a parent.");
}
else
{
info.TopLevelWindow = c.TopLevelControl.Handle;
}
Trace.WriteLine(String.Format("Mapping window to top level: {0}", info.TopLevelWindow));
API.MapRaised(info.Display, info.TopLevelWindow);
Trace.Unindent();
}
#endregion
#region --- IGLControl Members ---
public event CreateEvent Create;
private void OnCreate(object sender, EventArgs e)
{
if (this.Create != null)
this.Create(sender, e);
}
#region public bool Quit
public bool Quit
{
get { return quit; }
set
{
throw new NotImplementedException();
quit = value;
}
}
#endregion
public bool IsIdle
{
get
{
return API.Pending(info.Display) == 0;
}
}
public bool Fullscreen
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
public OpenTK.Platform.IGLContext Context
{
get
{
return glContext;
}
}
public void ProcessEvents()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
#region --- IDisposable Members ---
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool manuallyCalled)
{
if (!disposed)
{
// Clean unmanaged resources:
if (manuallyCalled)
{
// Clean managed resources, too
glContext.Dispose();
}
}
disposed = true;
}
~X11GLControl()
{
this.Dispose(false);
}
#endregion
}
}

View file

@ -0,0 +1,438 @@
#region --- License ---
/* Copyright (c) 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
//using OpenTK.OpenGL;
namespace OpenTK.Platform.X11
{
sealed class X11GLNative : OpenTK.Platform.INativeWindow, IDisposable
{
#region --- Private Fields ---
private X11GLContext glContext;
private X11WindowInfo windowInfo = new X11WindowInfo();
private IntPtr display;
private int screen;
private IntPtr rootWindow;
private IntPtr window;
private DisplayMode mode = new DisplayMode();
// Number of pending events.
private int pending = 0;
// C# ResizeEventArgs
private ResizeEventArgs resizeEventArgs = new ResizeEventArgs();
// Low level X11 resize request
private X11.Event xresize = new Event();
// This is never written in the code. If at some point it gets != 0,
// then memory corruption is taking place from the xresize struct.
// Event used for event loop.
private Event e = new Event();
private ConfigureNotifyEvent configure = new ConfigureNotifyEvent();
private ReparentNotifyEvent reparent = new ReparentNotifyEvent();
private ExposeEvent expose = new ExposeEvent();
private CreateWindowEvent createWindow = new CreateWindowEvent();
private DestroyWindowEvent destroyWindow = new DestroyWindowEvent();
// This is never written in the code. If at some point it gets != 0,
// then memory corruption is taking place from the xresize struct.
int memGuard = 0;
//private int width, height;
private bool disposed;
#endregion
#region --- Public Constructors ---
/// <summary>
/// Constructs a new X11GLNative window, with its associated context.
/// Safe defaults for visual, colormap, etc.
/// </summary>
public X11GLNative()
{
Trace.WriteLine("Creating GameWindow (X11GLNative driver)");
Trace.Indent();
// Set default (safe) DisplayMode.
mode.Width = 640;
mode.Height = 480;
mode.Color = new ColorDepth(24);
mode.DepthBits = 16;
mode.Buffers = 2;
Trace.WriteLine(String.Format("Display mode: {0}", mode));
windowInfo.Display = display = API.OpenDisplay(null); // null == default display
if (display == IntPtr.Zero)
{
throw new Exception("Could not open connection to X");
}
windowInfo.Screen = screen = API.DefaultScreen(display);
windowInfo.RootWindow = rootWindow = API.RootWindow(display, screen);
Trace.WriteLine(
String.Format(
"Display: {0}, Screen {1}, Root window: {2}",
windowInfo.Display,
windowInfo.Screen,
windowInfo.RootWindow
)
);
glContext = new X11GLContext(windowInfo, mode);
glContext.CreateVisual();
// Create a window on this display using the visual above
Trace.Write("Creating output window... ");
SetWindowAttributes wnd_attributes = new SetWindowAttributes();
wnd_attributes.background_pixel = 0;
wnd_attributes.border_pixel = 0;
wnd_attributes.colormap = glContext.XColormap;
//API.CreateColormap(display, rootWindow, glxVisualInfo.visual, 0/*AllocNone*/);
wnd_attributes.event_mask =
EventMask.StructureNotifyMask |
EventMask.ExposureMask |
EventMask.KeyPressMask;
CreateWindowMask cw_mask =
CreateWindowMask.CWBackPixel |
CreateWindowMask.CWBorderPixel |
CreateWindowMask.CWColormap |
CreateWindowMask.CWEventMask;
window = API.CreateWindow(
windowInfo.Display,
windowInfo.RootWindow,
0, 0,
640, 480,
0,
//glxVisualInfo.depth,
glContext.XVisualInfo.depth,
Constants.InputOutput,
//glxVisualInfo.visual,
glContext.XVisualInfo.visual,
cw_mask,
wnd_attributes
);
if (window == IntPtr.Zero)
{
throw new Exception("Could not create window.");
}
Trace.WriteLine("done! (id: " + window + ")");
// Set the window hints
/*
SizeHints hints = new SizeHints();
hints.x = 0;
hints.y = 0;
hints.width = 640;
hints.height = 480;
hints.flags = USSize | USPosition;
X11Api.SetNormalHints(display, window, hints);
X11Api.SetStandardProperties(
display,
window,
name,
name,
0, // None
null,
0,
hints
);
*/
//glContext.ContainingWindow = windowInfo.Window;
glContext.windowInfo.Window = window;
glContext.CreateContext(null, true);
API.MapRaised(display, window);
Trace.WriteLine("Mapped window.");
//glContext.MakeCurrent();
Trace.WriteLine("Our shiny new context is now current - ready to rock 'n' roll!");
Trace.Unindent();
}
#endregion
#region --- IGLWindow Members ---
#region public void ProcessEvents()
public void ProcessEvents()
{
// Process all pending events
while (true)
{
pending = API.Pending(display);
if (pending == 0)
return;
//API.NextEvent(display, e);
API.PeekEvent(display, e);
//API.NextEvent(display, eventPtr);
Debug.WriteLine(String.Format("Event: {0} ({1} pending)", e.Type, pending));
//Debug.WriteLine(String.Format("Event: {0} ({1} pending)", eventPtr, pending));
// Check whether memory was corrupted by the NextEvent call.
Debug.Assert(memGuard == 0, "memGuard2 tripped", String.Format("Guard: {0}", memGuard));
memGuard = 0;
// Respond to the event e
switch (e.Type)
{
case EventType.ReparentNotify:
API.NextEvent(display, reparent);
// Do nothing
break;
case EventType.CreateNotify:
API.NextEvent(display, createWindow);
// Set window width/height
mode.Width = createWindow.width;
mode.Height = createWindow.height;
this.OnCreate(EventArgs.Empty);
Debug.WriteLine(
String.Format("OnCreate fired: {0}x{1}", mode.Width, mode.Height)
);
break;
case EventType.DestroyNotify:
API.NextEvent(display, destroyWindow);
quit = true;
Debug.WriteLine("Window destroyed, shutting down.");
break;
case EventType.ConfigureNotify:
API.NextEvent(display, configure);
// If the window size changed, raise the C# Resize event.
if (configure.width != mode.Width ||
configure.height != mode.Height)
{
Debug.WriteLine(
String.Format(
"New res: {0}x{1}",
configure.width,
configure.height
)
);
resizeEventArgs.Width = configure.width;
resizeEventArgs.Height = configure.height;
this.OnResize(resizeEventArgs);
}
break;
default:
API.NextEvent(display, e);
Debug.WriteLine(String.Format("{0} event was not handled", e.Type));
break;
}
}
}
#endregion
#region public event CreateEvent Create;
public event CreateEvent Create;
private void OnCreate(EventArgs e)
{
if (this.Create != null)
{
this.Create(this, e);
}
}
#endregion
#region public bool Quit
private bool quit;
public bool Quit
{
get { return quit; }
set
{
if (value)
{
/*Event e = new Event();
X11Api.SendEvent(
display,
window,
false,
0,*/
//quit = true;
}
}
}
#endregion
#region public bool IsIdle
public bool IsIdle
{
get { throw new Exception("The method or operation is not implemented."); }
}
#endregion
#region public bool Fullscreen
public bool Fullscreen
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
#endregion
#region public IGLContext Context
public OpenTK.Platform.IGLContext Context
{
get { return glContext; }
}
#endregion
#endregion
#region --- IResizable Members ---
#region public int Width
public int Width
{
get
{
return mode.Width;
}
set
{/*
// Clear event struct
//Array.Clear(xresize.pad, 0, xresize.pad.Length);
// Set requested parameters
xresize.ResizeRequest.type = EventType.ResizeRequest;
xresize.ResizeRequest.display = this.display;
xresize.ResizeRequest.width = value;
xresize.ResizeRequest.height = mode.Width;
API.SendEvent(
this.display,
this.window,
false,
EventMask.StructureNotifyMask,
ref xresize
);*/
}
}
#endregion
#region public int Height
public int Height
{
get
{
return mode.Height;
}
set
{/*
// Clear event struct
//Array.Clear(xresize.pad, 0, xresize.pad.Length);
// Set requested parameters
xresize.ResizeRequest.type = EventType.ResizeRequest;
xresize.ResizeRequest.display = this.display;
xresize.ResizeRequest.width = mode.Width;
xresize.ResizeRequest.height = value;
API.SendEvent(
this.display,
this.window,
false,
EventMask.StructureNotifyMask,
ref xresize
);*/
}
}
#endregion
#region public event ResizeEvent Resize
public event ResizeEvent Resize;
private void OnResize(ResizeEventArgs e)
{
mode.Width = e.Width;
mode.Height = e.Height;
if (this.Resize != null)
{
this.Resize(this, e);
}
}
#endregion
#endregion
#region --- IDisposable Members ---
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool manuallyCalled)
{
if (!disposed)
{
API.DestroyWindow(display, window);
API.CloseDisplay(display);
if (manuallyCalled)
{
glContext.Dispose();
}
disposed = true;
}
}
~X11GLNative()
{
this.Dispose(false);
}
#endregion
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Platform.X11
{
public class X11WindowInfo : IWindowInfo
{
public IntPtr RootWindow;
public IntPtr Window;
public IntPtr TopLevelWindow;
public IntPtr Display;
public int Screen;
}
}

View file

@ -0,0 +1,35 @@
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 Framework")]
[assembly: AssemblyDescription("Create OpenGL applications in C#.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenTK.Framework")]
[assembly: AssemblyCopyright("Copyright © 2006-2007 Stefanos Apostolopoulos")]
[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("7652241e-158d-4eb1-85f4-ed40ee356791")]
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.3.8.0")]
[assembly: AssemblyFileVersion("0.3.8.0")]