Added Tao.OpenGl, Tao.OpenAl and Tao.Platform.Windows.SimpleOpenGlControl to OpenTK.Compatibility.

Added Tao Framework license information.
Updated and clarified license information.
This commit is contained in:
the_fiddler 2009-08-19 10:04:17 +00:00
parent c487a382e1
commit ad5d554091
15 changed files with 133125 additions and 2 deletions

View file

@ -14,7 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Third parties
The Open Toolkit library includes portions of the Mono class library, which are covered by the following license:
OpenTK.Platform.Windows and OpenTK.Platform.X11 include portions of the Mono class library. These portions are covered by the following license:
Copyright (c) 2004 Novell, Inc.
@ -26,7 +26,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Half-to-Single and Single-to-Half conversions are covered by the following license:
OpenTK.Compatibility offers the Tao namespace, which includes portions of the Tao Framework library. These portions are covered by the following license:
Copyright ©2003-2007 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.
OpenTK.Half offers Half-to-Single and Single-to-Half conversions based on OpenEXR source code, which is covered by the following license:
Copyright (c) 2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC. All rights reserved.

View file

@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4918
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace OpenTK.Compatibility.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenTK.Compatibility.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static System.Drawing.Bitmap TaoButton {
get {
object obj = ResourceManager.GetObject("TaoButton", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View file

@ -0,0 +1,124 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="TaoButton" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\TaoButton.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,247 @@
#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
namespace Tao.OpenAl
{
using System;
using System.Runtime.InteropServices;
internal static class Delegates
{
static Delegates()
{
}
/// <summary>
/// Creates a System.Delegate that can be used to call a dynamically exported OpenAL function.
/// </summary>
/// <param name="name">The function string for the OpenAL function</param>
/// <param name="signature">The signature of the OpenAL function.</param>
/// <returns>
/// A System.Delegate that can be used to call this OpenAL function or null
/// if the function is not available in the current OpenAL context.
/// </returns>
public static Delegate GetDelegateForExtensionMethod(string name, Type signature)
{
IntPtr address = Al.alGetProcAddress(name);
if (address == IntPtr.Zero)
{
return null;
}
else
{
return Marshal.GetDelegateForFunctionPointer(address, signature);
}
}
#region X-RAM
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void EAXSetBufferModeDelegate(int n, [Out] int* buffers, int value);
internal static EAXSetBufferModeDelegate EAXSetBufferMode = (EAXSetBufferModeDelegate)GetDelegateForExtensionMethod("EAXSetBufferMode", typeof(EAXSetBufferModeDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate int EAXGetBufferModeDelegate(int buffer, [Out] int* reserved);
internal static EAXGetBufferModeDelegate EAXGetBufferMode = (EAXGetBufferModeDelegate)GetDelegateForExtensionMethod("EAXGetBufferMode", typeof(EAXGetBufferModeDelegate));
#endregion
#region EFX_EXT
#region alEffect
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGenEffectsDelegate(int size, [Out] int* effects);
internal static alGenEffectsDelegate alGenEffects = (alGenEffectsDelegate)GetDelegateForExtensionMethod("alGenEffects", typeof(alGenEffectsDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alDeleteEffectsDelegate(int size, int* effects);
internal static alDeleteEffectsDelegate alDeleteEffects = (alDeleteEffectsDelegate)GetDelegateForExtensionMethod("alDeleteEffects", typeof(alDeleteEffectsDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate bool alIsEffectDelegate(int effect);
internal static alIsEffectDelegate alIsEffect = (alIsEffectDelegate)GetDelegateForExtensionMethod("alIsEffect", typeof(alIsEffectDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate void alEffectiDelegate(int effect, int param, int value);
internal static alEffectiDelegate alEffecti = (alEffectiDelegate)GetDelegateForExtensionMethod("alEffecti", typeof(alEffectiDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alEffectivDelegate(int effect, int param, int* value);
internal static alEffectivDelegate alEffectiv = (alEffectivDelegate)GetDelegateForExtensionMethod("alEffectiv", typeof(alEffectivDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate void alEffectfDelegate(int effect, int param, float value);
internal static alEffectfDelegate alEffectf = (alEffectfDelegate)GetDelegateForExtensionMethod("alEffectf", typeof(alEffectfDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alEffectfvDelegate(int effect, int param, float* value);
internal static alEffectfvDelegate alEffectfv = (alEffectfvDelegate)GetDelegateForExtensionMethod("alEffectfv", typeof(alEffectfvDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetEffectiDelegate(int effect, int param, [Out] int* value);
internal static alGetEffectiDelegate alGetEffecti = (alGetEffectiDelegate)GetDelegateForExtensionMethod("alGetEffecti", typeof(alGetEffectiDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetEffectivDelegate(int effect, int param, [Out] int* value);
internal static alGetEffectivDelegate alGetEffectiv = (alGetEffectivDelegate)GetDelegateForExtensionMethod("alGetEffectiv", typeof(alGetEffectivDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetEffectfDelegate(int effect, int param, [Out] float* value);
internal static alGetEffectfDelegate alGetEffectf = (alGetEffectfDelegate)GetDelegateForExtensionMethod("alGetEffectf", typeof(alGetEffectfDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetEffectfvDelegate(int effect, int param, [Out] float* value);
internal static alGetEffectfvDelegate alGetEffectfv = (alGetEffectfvDelegate)GetDelegateForExtensionMethod("alGetEffectfv", typeof(alGetEffectfvDelegate));
#endregion
#region alFilter
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGenFiltersDelegate(int size, [Out] int* Filters);
internal static alGenFiltersDelegate alGenFilters = (alGenFiltersDelegate)GetDelegateForExtensionMethod("alGenFilters", typeof(alGenFiltersDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alDeleteFiltersDelegate(int size, int* Filters);
internal static alDeleteFiltersDelegate alDeleteFilters = (alDeleteFiltersDelegate)GetDelegateForExtensionMethod("alDeleteFilters", typeof(alDeleteFiltersDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate bool alIsFilterDelegate(int Filter);
internal static alIsFilterDelegate alIsFilter = (alIsFilterDelegate)GetDelegateForExtensionMethod("alIsFilter", typeof(alIsFilterDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate void alFilteriDelegate(int Filter, int param, int value);
internal static alFilteriDelegate alFilteri = (alFilteriDelegate)GetDelegateForExtensionMethod("alFilteri", typeof(alFilteriDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alFilterivDelegate(int Filter, int param, int* value);
internal static alFilterivDelegate alFilteriv = (alFilterivDelegate)GetDelegateForExtensionMethod("alFilteriv", typeof(alFilterivDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate void alFilterfDelegate(int Filter, int param, float value);
internal static alFilterfDelegate alFilterf = (alFilterfDelegate)GetDelegateForExtensionMethod("alFilterf", typeof(alFilterfDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alFilterfvDelegate(int Filter, int param, float* value);
internal static alFilterfvDelegate alFilterfv = (alFilterfvDelegate)GetDelegateForExtensionMethod("alFilterfv", typeof(alFilterfvDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetFilteriDelegate(int Filter, int param, [Out] int* value);
internal static alGetFilteriDelegate alGetFilteri = (alGetFilteriDelegate)GetDelegateForExtensionMethod("alGetFilteri", typeof(alGetFilteriDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetFilterivDelegate(int Filter, int param, [Out] int* value);
internal static alGetFilterivDelegate alGetFilteriv = (alGetFilterivDelegate)GetDelegateForExtensionMethod("alGetFilteriv", typeof(alGetFilterivDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetFilterfDelegate(int Filter, int param, [Out] float* value);
internal static alGetFilterfDelegate alGetFilterf = (alGetFilterfDelegate)GetDelegateForExtensionMethod("alGetFilterf", typeof(alGetFilterfDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetFilterfvDelegate(int Filter, int param, [Out] float* value);
internal static alGetFilterfvDelegate alGetFilterfv = (alGetFilterfvDelegate)GetDelegateForExtensionMethod("alGetFilterfv", typeof(alGetFilterfvDelegate));
#endregion
#region alFilter
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGenAuxiliaryEffectSlotsDelegate(int size, [Out] int* AuxiliaryEffectSlots);
internal static alGenAuxiliaryEffectSlotsDelegate alGenAuxiliaryEffectSlots = (alGenAuxiliaryEffectSlotsDelegate)GetDelegateForExtensionMethod("alGenAuxiliaryEffectSlots", typeof(alGenAuxiliaryEffectSlotsDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alDeleteAuxiliaryEffectSlotsDelegate(int size, int* AuxiliaryEffectSlots);
internal static alDeleteAuxiliaryEffectSlotsDelegate alDeleteAuxiliaryEffectSlots = (alDeleteAuxiliaryEffectSlotsDelegate)GetDelegateForExtensionMethod("alDeleteAuxiliaryEffectSlots", typeof(alDeleteAuxiliaryEffectSlotsDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate bool alIsAuxiliaryEffectSlotDelegate(int AuxiliaryEffectSlot);
internal static alIsAuxiliaryEffectSlotDelegate alIsAuxiliaryEffectSlot = (alIsAuxiliaryEffectSlotDelegate)GetDelegateForExtensionMethod("alIsAuxiliaryEffectSlot", typeof(alIsAuxiliaryEffectSlotDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate void alAuxiliaryEffectSlotiDelegate(int AuxiliaryEffectSlot, int param, int value);
internal static alAuxiliaryEffectSlotiDelegate alAuxiliaryEffectSloti = (alAuxiliaryEffectSlotiDelegate)GetDelegateForExtensionMethod("alAuxiliaryEffectSloti", typeof(alAuxiliaryEffectSlotiDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alAuxiliaryEffectSlotivDelegate(int AuxiliaryEffectSlot, int param, int* value);
internal static alAuxiliaryEffectSlotivDelegate alAuxiliaryEffectSlotiv = (alAuxiliaryEffectSlotivDelegate)GetDelegateForExtensionMethod("alAuxiliaryEffectSlotiv", typeof(alAuxiliaryEffectSlotivDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal delegate void alAuxiliaryEffectSlotfDelegate(int AuxiliaryEffectSlot, int param, float value);
internal static alAuxiliaryEffectSlotfDelegate alAuxiliaryEffectSlotf = (alAuxiliaryEffectSlotfDelegate)GetDelegateForExtensionMethod("alAuxiliaryEffectSlotf", typeof(alAuxiliaryEffectSlotfDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alAuxiliaryEffectSlotfvDelegate(int AuxiliaryEffectSlot, int param, float* value);
internal static alAuxiliaryEffectSlotfvDelegate alAuxiliaryEffectSlotfv = (alAuxiliaryEffectSlotfvDelegate)GetDelegateForExtensionMethod("alAuxiliaryEffectSlotfv", typeof(alAuxiliaryEffectSlotfvDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetAuxiliaryEffectSlotiDelegate(int AuxiliaryEffectSlot, int param, [Out] int* value);
internal static alGetAuxiliaryEffectSlotiDelegate alGetAuxiliaryEffectSloti = (alGetAuxiliaryEffectSlotiDelegate)GetDelegateForExtensionMethod("alGetAuxiliaryEffectSloti", typeof(alGetAuxiliaryEffectSlotiDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetAuxiliaryEffectSlotivDelegate(int AuxiliaryEffectSlot, int param, [Out] int* value);
internal static alGetAuxiliaryEffectSlotivDelegate alGetAuxiliaryEffectSlotiv = (alGetAuxiliaryEffectSlotivDelegate)GetDelegateForExtensionMethod("alGetAuxiliaryEffectSlotiv", typeof(alGetAuxiliaryEffectSlotivDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetAuxiliaryEffectSlotfDelegate(int AuxiliaryEffectSlot, int param, [Out] float* value);
internal static alGetAuxiliaryEffectSlotfDelegate alGetAuxiliaryEffectSlotf = (alGetAuxiliaryEffectSlotfDelegate)GetDelegateForExtensionMethod("alGetAuxiliaryEffectSlotf", typeof(alGetAuxiliaryEffectSlotfDelegate));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate void alGetAuxiliaryEffectSlotfvDelegate(int AuxiliaryEffectSlot, int param, [Out] float* value);
internal static alGetAuxiliaryEffectSlotfvDelegate alGetAuxiliaryEffectSlotfv = (alGetAuxiliaryEffectSlotfvDelegate)GetDelegateForExtensionMethod("alGetAuxiliaryEffectSlotfv", typeof(alGetAuxiliaryEffectSlotfvDelegate));
#endregion
#endregion
}
}

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,737 @@
#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.IO;
using System.Security;
using System.Runtime.InteropServices;
using System.Text;
namespace Tao.OpenAl
{
#region Class Documentation
/// <summary>
/// OpenAL binding for .NET, implementing ALUT 1.1.
/// </summary>
/// <remarks>
/// ALUT is non-standard.
/// </remarks>
#endregion Class Documentation
[Obsolete("Use OpenTK.Audio.OpenAL instead.")]
public static class Alut
{
// --- Fields ---
#region Private Constants
#region string ALUT_NATIVE_LIBRARY
/// <summary>
/// Specifies OpenAl's native library archive.
/// </summary>
/// <remarks>
/// Specifies OpenAl32.dll everywhere; will be mapped via .config for mono.
/// </remarks>
private const string ALUT_NATIVE_LIBRARY = "alut.dll";
#endregion string ALUT_NATIVE_LIBRARY
#region CallingConvention CALLING_CONVENTION
/// <summary>
/// Specifies the calling convention.
/// </summary>
/// <remarks>
/// Specifies <see cref="CallingConvention.Cdecl" />.
/// </remarks>
private const CallingConvention CALLING_CONVENTION = CallingConvention.Cdecl;
#endregion CallingConvention CALLING_CONVENTION
#endregion Private Constants
#region Public OpenAL 1.1 Constants
/// <summary>
///
/// </summary>
public const int ALUT_API_MAJOR_VERSION = 1;
/// <summary>
///
/// </summary>
public const int ALUT_API_MINOR_VERSION = 1;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_NO_ERROR = 0;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_OUT_OF_MEMORY = 0x200;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_INVALID_ENUM = 0x201;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_INVALID_VALUE = 0x202;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_INVALID_OPERATION = 0x203;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_NO_CURRENT_CONTEXT = 0x204;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_AL_ERROR_ON_ENTRY = 0x205;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_ALC_ERROR_ON_ENTRY = 0x206;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_OPEN_DEVICE = 0x207;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_CLOSE_DEVICE = 0x208;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_CREATE_CONTEXT = 0x209;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_MAKE_CONTEXT_CURRENT = 0x20A;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_DESTROY_CONTEXT = 0x20B;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_GEN_BUFFERS = 0x20C;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_BUFFER_DATA = 0x20D;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_IO_ERROR = 0x20E;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_UNSUPPORTED_FILE_TYPE = 0x20F;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE = 0x210;
/// <summary>
///
/// </summary>
public const int ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA = 0x211;
/// <summary>
///
/// </summary>
public const int ALUT_WAVEFORM_SINE = 0x100;
/// <summary>
///
/// </summary>
public const int ALUT_WAVEFORM_SQUARE = 0x101;
/// <summary>
///
/// </summary>
public const int ALUT_WAVEFORM_SAWTOOTH = 0x102;
/// <summary>
///
/// </summary>
public const int ALUT_WAVEFORM_WHITENOISE = 0x103;
/// <summary>
///
/// </summary>
public const int ALUT_WAVEFORM_IMPULSE = 0x104;
/// <summary>
///
/// </summary>
public const int ALUT_LOADER_BUFFER = 0x300;
/// <summary>
///
/// </summary>
public const int ALUT_LOADER_MEMORY = 0x301;
#endregion Public OpenAL 1.1 Constants
// --- Public Methods ---
/// <summary>
///
/// </summary>
/// <param name="argcp"></param>
/// <param name="argv"></param>
/// <returns></returns>
// ALUT_API ALboolean ALUT_APIENTRY alutInit (int *argcp, char **argv);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutInit(int[] argcp, string[] argv);
/// <summary>
///
/// </summary>
/// <returns></returns>
public static int alutInit()
{
return alutInit(null, null);
}
/// <summary>
///
/// </summary>
/// <param name="argcp"></param>
/// <param name="argv"></param>
/// <returns></returns>
// ALUT_API ALboolean ALUT_APIENTRY alutInitWithoutContext (int *argcp, char **argv);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutInitWithoutContext(int[] argcp, string[] argv);
/// <summary>
///
/// </summary>
// ALUT_API ALboolean ALUT_APIENTRY alutExit (void);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutExit();
/// <summary>
///
/// </summary>
// ALUT_API ALenum ALUT_APIENTRY alutGetError (void);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutGetError();
/// <summary>
///
/// </summary>
/// <returns></returns>
// ALUT_API const char *ALUT_APIENTRY alutGetErrorString (ALenum error);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern string alutGetErrorString(int error);
/// <summary>
///
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFile (const char *fileName);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutCreateBufferFromFile(string fileName);
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/// <param name="length"></param>
/// <returns></returns>
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferFromFileImage (const ALvoid *data, ALsizei length);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutCreateBufferFromFileImage(IntPtr data, int length);
/// <summary>
///
/// </summary>
/// <returns></returns>
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferHelloWorld (void);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutCreateBufferHelloWorld();
/// <summary>
///
/// </summary>
/// <param name="waveshape"></param>
/// <param name="frequency"></param>
/// <param name="phase"></param>
/// <param name="duration"></param>
/// <returns></returns>
// ALUT_API ALuint ALUT_APIENTRY alutCreateBufferWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutCreateBufferWaveform(int waveshape, float frequency, float phase, float duration);
/// <summary>
///
/// </summary>
/// <param name="fileName"></param>
/// <param name="format"></param>
/// <param name="size"></param>
/// <param name="frequency"></param>
/// <returns></returns>
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFile (const char *fileName, ALenum *format, ALsizei *size, ALfloat *frequency);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern IntPtr alutLoadMemoryFromFile(string fileName, out int format, out int size, out float frequency);
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/// <param name="length"></param>
/// <param name="format"></param>
/// <param name="size"></param>
/// <param name="frequency"></param>
/// <returns></returns>
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryFromFileImage (const ALvoid *data, ALsizei length, ALenum *format, ALsizei *size, ALfloat *frequency);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern IntPtr alutLoadMemoryFromFileImage(IntPtr data, int length, out int format, out int size, out float frequency);
/// <summary>
///
/// </summary>
/// <param name="format"></param>
/// <param name="size"></param>
/// <param name="frequency"></param>
/// <returns></returns>
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryHelloWorld (ALenum *format, ALsizei *size, ALfloat *frequency);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern IntPtr alutLoadMemoryHelloWorld(out int format, out int size, out float frequency);
/// <summary>
///
/// </summary>
/// <param name="waveshape"></param>
/// <param name="frequency"></param>
/// <param name="phase"></param>
/// <param name="duration"></param>
/// <param name="format"></param>
/// <param name="size"></param>
/// <param name="freq"></param>
/// <returns></returns>
// ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum *format, ALsizei *size, ALfloat *freq);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern IntPtr alutLoadMemoryWaveform(int waveshape, float frequency, float phase, float duration, out int format, out int size, out float freq);
/// <summary>
///
/// </summary>
/// <param name="loader"></param>
/// <returns></returns>
// ALUT_API const char *ALUT_APIENTRY alutGetMIMETypes (ALenum loader);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern string alutGetMIMETypes(int loader);
/// <summary>
///
/// </summary>
/// <returns></returns>
// ALUT_API ALint ALUT_APIENTRY alutGetMajorVersion (void);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutGetMajorVersion();
/// <summary>
///
/// </summary>
/// <returns></returns>
// ALUT_API ALint ALUT_APIENTRY alutGetMinorVersion (void);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutGetMinorVersion();
/// <summary>
///
/// </summary>
/// <param name="duration"></param>
/// <returns></returns>
// ALUT_API ALboolean ALUT_APIENTRY alutSleep (ALfloat duration);
[DllImport(ALUT_NATIVE_LIBRARY, CallingConvention=CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
public static extern int alutSleep(float duration);
#region DEPRECATED
// #region InitializeAlut()
// /// <summary>
// /// Initializes OpenAL device and context.
// /// </summary>
// private static void InitializeAlut()
// {
//#if WIN32
// IntPtr device = Alc.alcOpenDevice("DirectSound3D");
//#else
//IntPtr device = Alc.alcOpenDevice(null);
//#endif
// IntPtr context = Alc.alcCreateContext(device, IntPtr.Zero);
// Alc.alcMakeContextCurrent(context);
// }
// #endregion InitializeAlut()
//
// #region ReadWavFile(Stream stream, out int format, out byte[] data, out int size, out int frequency, out int loop)
// /// <summary>
// /// Reads a WAV file.
// /// </summary>
// /// <param name="stream">
// /// The stream to be read.
// /// </param>
// /// <param name="format">
// /// The format of the WAV file.
// /// </param>
// /// <param name="data">
// /// The WAV file data.
// /// </param>
// /// <param name="size">
// /// The size of the WAV file data.
// /// </param>
// /// <param name="frequency">
// /// The frequency of the WAV file.
// /// </param>
// /// <param name="loop">
// /// Does the WAV file loop?
// /// </param>
// private static void ReadWavFile(Stream stream, out int format, out byte[] data, out int size, out int frequency, out int loop)
// {
// bool success = true;
// format = Al.AL_FORMAT_MONO16;
// data = null;
// size = 0;
// frequency = 22050;
// loop = Al.AL_FALSE;
//
// BinaryReader reader = new BinaryReader(stream, System.Text.Encoding.ASCII);
//
// try
// {
// WavFileHeader fileHeader = new WavFileHeader();
// WavChunkHeader chunkHeader = new WavChunkHeader();
// WavFormatChunk formatChunk = new WavFormatChunk();
//
// // Read WAV file header
// fileHeader.Id = reader.ReadChars(4);
// fileHeader.Length = reader.ReadInt32();
// fileHeader.Type = reader.ReadChars(4);
//
// if(new string(fileHeader.Id) != "RIFF" && fileHeader.Length <= 0 && new string(fileHeader.Type) != "WAVE")
// {
// success = false;
// }
// else
// {
// while(fileHeader.Length > 8)
// {
// // Read WAV chunk header
// chunkHeader.Id = reader.ReadChars(4);
// chunkHeader.Length = reader.ReadInt32();
//
// // Determine chunk action
// if(new string(chunkHeader.Id) == "fmt ")
// {
// // Read WAV format header
// formatChunk.Format = reader.ReadInt16();
// formatChunk.Channels = reader.ReadInt16();
// formatChunk.SamplesPerSecond = reader.ReadInt32();
// formatChunk.BytesPerSecond = reader.ReadInt32();
// formatChunk.BytesPerSample = reader.ReadInt16();
// formatChunk.BitsPerSample = reader.ReadInt16();
//
// if(chunkHeader.Length > 16)
// {
// formatChunk.ExtraBytesLength = reader.ReadInt16();
// formatChunk.ExtraBytes = reader.ReadBytes(formatChunk.ExtraBytesLength);
// }
// else
// {
// formatChunk.ExtraBytesLength = 0;
// formatChunk.ExtraBytes = null;
// }
//
// if(formatChunk.Format == 0x0001)
// {
// if(formatChunk.Channels == 1)
// {
// if(formatChunk.BitsPerSample == 8)
// {
// format = Al.AL_FORMAT_MONO8;
// }
// else
// {
// format = Al.AL_FORMAT_MONO16;
// }
// }
// else
// {
// if(formatChunk.BitsPerSample == 8)
// {
// format = Al.AL_FORMAT_STEREO8;
// }
// else
// {
// format = Al.AL_FORMAT_STEREO16;
// }
// }
// }
// frequency = formatChunk.SamplesPerSecond;
// }
// else if(new string(chunkHeader.Id) == "data")
// {
// if(formatChunk.Format == 0x0001)
// {
// size = chunkHeader.Length - 8;
// data = reader.ReadBytes(size);
// }
// }
// else
// {
// if(chunkHeader.Length <= fileHeader.Length && chunkHeader.Length > 0)
// {
// reader.ReadBytes(chunkHeader.Length);
// }
// }
//
// if(chunkHeader.Length <= fileHeader.Length && chunkHeader.Length > 0)
// {
// fileHeader.Length -= chunkHeader.Length;
// }
// else
// {
// fileHeader.Length = 0;
// }
// }
// }
// success = true;
// }
// catch
// {
// success = false;
// }
// finally
// {
// reader.Close();
// }
//
// if(!success)
// {
// format = -1;
// data = null;
// size = -1;
// frequency = -1;
// loop = -1;
// }
// }
// #endregion ReadWavFile(string fileName, out int format, out byte[] data, out int size, out int frequency, out int loop)
// #region alutExit()
// /// <summary>
// /// Destroys OpenAL context and device.
// /// </summary>
// // ALUTAPI ALvoid ALUTAPIENTRY alutExit(ALvoid);
// public static void alutExit()
// {
// IntPtr context = Alc.alcGetCurrentContext();
// IntPtr device = Alc.alcGetContextsDevice(context);
// Alc.alcMakeContextCurrent(IntPtr.Zero);
// Alc.alcDestroyContext(context);
// Alc.alcCloseDevice(device);
// context = IntPtr.Zero;
// device = IntPtr.Zero;
// }
// #endregion alutExit()
// #region alutInit()
// /// <summary>
// /// Initializes an OpenAL device and context.
// /// </summary>
// // ALUTAPI ALvoid ALUTAPIENTRY alutInit(ALint *argc, ALbyte **argv);
// public static void alutInit()
// {
// InitializeAlut();
// }
// #endregion alutInit()
//
// #region alutInit(int argc, StringBuilder argv)
// /// <summary>
// /// Initializes an OpenAL device and context.
// /// </summary>
// /// <param name="argc">
// /// Number of commandline arguments.
// /// </param>
// /// <param name="argv">
// /// The commandline arguments.
// /// </param>
// // ALUTAPI ALvoid ALUTAPIENTRY alutInit(ALint *argc, ALbyte **argv);
// public static void alutInit(int argc, StringBuilder argv)
// {
// InitializeAlut();
// }
// #endregion alutInit(int argc, StringBuilder argv)
// #region Private Structs
// #region WavFileHeader
// /// <summary>
// /// WAV file header.
// /// </summary>
// // 12 bytes total
// [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
// private struct WavFileHeader
// {
// [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
// public char[] Id;
// public int Length;
// [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
// public char[] Type;
// }
// #endregion WavFileHeader
//
// #region WavChunkHeader
// /// <summary>
// /// WAV chunk header.
// /// </summary>
// // 8 bytes total
// [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
// private struct WavChunkHeader
// {
// [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)]
// public char[] Id;
// public int Length;
// }
// #endregion WavChunkHeader
//
// #region WavFormatChunk
// /// <summary>
// /// WAV format chunk.
// /// </summary>
// // 16 bytes total
// [StructLayout(LayoutKind.Sequential)]
// private struct WavFormatChunk
// {
// public short Format;
// public short Channels;
// public int SamplesPerSecond;
// public int BytesPerSecond;
// public short BytesPerSample;
// public short BitsPerSample;
// public short ExtraBytesLength;
// public byte[] ExtraBytes;
// }
// #endregion WavFormatChunk
// #endregion Private Structs
// #region alutLoadWAVFile(string fileName, out int format, out byte[] data, out int size, out int frequency, out int loop)
// /// <summary>
// /// Loads a WAV file.
// /// </summary>
// /// <param name="fileName">
// /// The filename to be loaded.
// /// </param>
// /// <param name="format">
// /// The format of the WAV file.
// /// </param>
// /// <param name="data">
// /// The WAV file data.
// /// </param>
// /// <param name="size">
// /// The size of the WAV file data.
// /// </param>
// /// <param name="frequency">
// /// The WAV file frequency.
// /// </param>
// /// <param name="loop">
// /// Does the WAV file loop?
// /// </param>
// // ALUTAPI ALvoid ALUTAPIENTRY alutLoadWAVFile(ALbyte *file, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop);
// public static void alutLoadWAVFile(string fileName, out int format, out byte[] data, out int size, out int frequency, out int loop)
// {
// if(File.Exists(fileName))
// {
// FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
// ReadWavFile(stream, out format, out data, out size, out frequency, out loop);
// stream.Close();
// stream = null;
// }
// else
// {
// format = -1;
// data = null;
// size = -1;
// frequency = -1;
// loop = -1;
// }
// }
// #endregion alutLoadWAVFile(string fileName, out int format, out byte[] data, out int size, out int frequency, out int loop)
//
// #region alutLoadWAVMemory([In] byte[] memory, out int format, out byte[] data, out int size, out int frequency, out int loop)
// /// <summary>
// /// Loads a WAV file from memory.
// /// </summary>
// /// <param name="memory">
// /// The WAV memory to be loaded.
// /// </param>
// /// <param name="format">
// /// The format of the WAV file.
// /// </param>
// /// <param name="data">
// /// The WAV file data.
// /// </param>
// /// <param name="size">
// /// The size of the WAV file data.
// /// </param>
// /// <param name="frequency">
// /// The WAV file frequency.
// /// </param>
// /// <param name="loop">
// /// Does the WAV file loop?
// /// </param>
// // ALUTAPI ALvoid ALUTAPIENTRY alutLoadWAVMemory(ALbyte *memory, ALenum *format, ALvoid **data, ALsizei *size, ALsizei *freq, ALboolean *loop);
// public static void alutLoadWAVMemory([In] byte[] memory, out int format, out byte[] data, out int size, out int frequency, out int loop)
// {
// if(memory != null)
// {
// MemoryStream stream = new MemoryStream(memory, 0, memory.Length);
// ReadWavFile(stream, out format, out data, out size, out frequency, out loop);
// stream.Close();
// stream = null;
// }
// else
// {
// format = -1;
// data = null;
// size = -1;
// frequency = -1;
// loop = -1;
// }
// }
// #endregion alutLoadWAVMemory([In] byte[] memory, out int format, out byte[] data, out int size, out int frequency, out int loop)
//
// #region alutUnloadWAV(int format, out byte[] data, int size, int frequency)
// /// <summary>
// /// Unloads a WAV file.
// /// </summary>
// /// <param name="format">
// /// The format of the WAV file.
// /// </param>
// /// <param name="data">
// /// The data of the WAV file.
// /// </param>
// /// <param name="size">
// /// The size of the WAV file's data.
// /// </param>
// /// <param name="frequency">
// /// The frequency of the WAV file.
// /// </param>
// // ALUTAPI ALvoid ALUTAPIENTRY alutUnloadWAV(ALenum format, ALvoid *data, ALsizei size, ALsizei freq);
// public static void alutUnloadWAV(int format, out byte[] data, int size, int frequency)
// {
// data = null;
// }
// #endregion alutUnloadWAV(int format, out byte[] data, int size, int frequency)
#endregion DEPRECATED
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

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,555 @@
#region License
/*
MIT License
Copyright ©2003-2007 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
#region --- Using Directives ---
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Diagnostics;
using System.Reflection.Emit;
using System.IO;
#endregion
namespace Tao.OpenGl
{
/// <summary>
/// OpenGL binding for .NET, implementing OpenGL 2.1, plus extensions.
/// </summary>
/// <remarks>
/// <para>
/// This class 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>
/// We rely 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, we 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 to have more control on extension loading, 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 function using the Gl.GetDelegate method.
/// </para>
/// <para>
/// <see href="http://opengl.org/registry/"/>
/// <seealso cref="Gl.IsExtensionSupported"/>
/// <seealso cref="Gl.GetDelegate"/>
/// <seealso cref="Gl.ReloadFunctions"/>
/// </para>
/// </remarks>
[Obsolete("Use OpenTK.Graphics.OpenGL instead.")]
public static partial class Gl
{
#region --- Fields ---
static StringBuilder sb = new StringBuilder();
static object gl_lock = new object();
internal const string Library = "opengl32.dll";
//private static Dictionary<string, bool> AvailableExtensions = new Dictionary<string, bool>();
private static SortedList<string, bool> AvailableExtensions = new SortedList<string, bool>();
private static bool rebuildExtensionList;
private static Type glClass;
private static Type delegatesClass;
private static Type importsClass;
private static FieldInfo[] delegates;
#endregion
#region --- Static Constructor ---
static Gl()
{
glClass = typeof(Gl);
delegatesClass = glClass.GetNestedType("Delegates", BindingFlags.Static | BindingFlags.NonPublic);
importsClass = glClass.GetNestedType("Imports", BindingFlags.Static | BindingFlags.NonPublic);
// 'Touch' Imports class to force initialization. We don't want anything yet, just to have
// this class ready.
if (Imports.FunctionMap != null) { }
ReloadFunctions();
}
#endregion
#region --- Methods ---
#region internal static partial class Imports
/// <summary>
/// Contains DllImports for the core OpenGL functions.
/// </summary>
internal static partial class Imports
{
/// <summary>
/// Build a string->MethodInfo map to speed up extension loading.
/// </summary>
internal static SortedList<string, MethodInfo> FunctionMap; // This is faster than either Dictionary or SortedDictionary
static Imports()
{
MethodInfo[] methods = importsClass.GetMethods(BindingFlags.Static | BindingFlags.NonPublic);
FunctionMap = new SortedList<string, MethodInfo>(methods.Length);
foreach (MethodInfo m in methods)
FunctionMap.Add(m.Name, m);
}
}
#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)
{
if (rebuildExtensionList)
BuildExtensionList();
lock (gl_lock)
{
sb.Remove(0, sb.Length);
if (!name.StartsWith("GL_"))
sb.Append("gl_");
sb.Append(name.ToLower());
// Search the cache for the string.
return AvailableExtensions.ContainsKey(sb.ToString());
}
}
#endregion
#region public static Delegate GetDelegate(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 GetDelegate(string name, Type signature)
{
MethodInfo m;
return GetExtensionDelegate(name, signature) ??
(Imports.FunctionMap.TryGetValue((name.Substring(2)), out m) ?
Delegate.CreateDelegate(signature, m) : null);
}
#endregion
#region public static void ReloadFunctions()
/// <summary>
/// Loads all OpenGL functions (core and extensions).
/// </summary>
/// <remarks>
/// <para>
/// This function will be automatically called the first time you use any opengl function. There is
/// </para>
/// <para>
/// Call this function manually whenever you need to update OpenGL entry points.
/// This need may arise if you change the pixelformat/visual, or in case you cannot
/// (or do not want) to use the automatic initialization of the GL class.
/// </para>
/// </remarks>
public static void ReloadFunctions()
{
// Using reflection is more than 3 times faster than directly loading delegates on the first
// run, probably due to code generation overhead. Subsequent runs are faster with direct loading
// than with reflection, but the first time is more significant.
if (delegates == null)
delegates = delegatesClass.GetFields(BindingFlags.Static | BindingFlags.NonPublic);
foreach (FieldInfo f in delegates)
f.SetValue(null, GetDelegate(f.Name, f.FieldType));
rebuildExtensionList = true;
}
static void set(object d, Delegate value)
{
d = value;
}
#endregion
#region public static bool ReloadFunction(string function)
/// <summary>
/// Tries to reload the given OpenGL function (core or extension).
/// </summary>
/// <param name="function">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 returns true if the given OpenGL function is supported, false otherwise.
/// </para>
/// <para>
/// To query for supported extensions use the IsExtensionSupported() function instead.
/// </para>
/// </remarks>
public static bool Load(string function)
{
FieldInfo f = delegatesClass.GetField(function, BindingFlags.Static | BindingFlags.NonPublic);
if (f == null)
return false;
Delegate old = f.GetValue(null) as Delegate;
Delegate @new = GetDelegate(f.Name, f.FieldType);
if (old.Target != @new.Target)
{
f.SetValue(null, @new);
rebuildExtensionList = true;
}
return @new != null;
}
#endregion
#region private static void BuildExtensionList()
/// <summary>
/// Builds a cache of all supported extensions.
/// </summary>
private static void BuildExtensionList()
{
// Assumes there is an opengl context current.
AvailableExtensions.Clear();
string version_string = Gl.glGetString(Gl.GL_VERSION);
if (String.IsNullOrEmpty(version_string))
throw new ApplicationException("Failed to retrieve OpenGL version. Is there an opengl context current?");
string version;
// Most drivers return the version in the 3 first characters of the version string,
// (e.g. on Ati X1950 with Catalyst 7.10 -> "2.0.6956 Release"). However, Mesa seems
// to do something strange: "1.4 (2.1 Mesa 7.0.1).".
// We'll do some trickery to get the second version number (2.1), but this may break on
// some implementations...
// This works on Ati, Mesa, Nvidia, but I'd like someone to test on Intel, too.
if (version_string.ToLower().Contains("mesa"))
{
int index = version_string.IndexOf('(');
if (index != -1)
version = version_string.Substring(index + 1, 3);
else
version = version_string.TrimStart(' ');
}
else
version = version_string.TrimStart(' ');
// Ugh, this look ugly.
if (version.StartsWith("1.2"))
{
AvailableExtensions.Add("gl_version_1_1", true);
AvailableExtensions.Add("gl_version_1_2", true);
}
else if (version.StartsWith("1.3"))
{
AvailableExtensions.Add("gl_version_1_1", true);
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_1", true);
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_1", true);
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_1", true);
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_1", true);
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.glGetString(Gl.GL_EXTENSIONS);
if (String.IsNullOrEmpty(extension_string))
return; // no extensions are available
string[] extensions = extension_string.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string ext in extensions)
AvailableExtensions.Add(ext.ToLower(), true);
rebuildExtensionList = false;
}
#endregion
#endregion
#region --- GetProcAddress ---
private static IGetProcAddress getProcAddress;
internal interface IGetProcAddress
{
IntPtr GetProcAddress(string function);
}
internal class GetProcAddressWindows : IGetProcAddress
{
[System.Runtime.InteropServices.DllImport(Library, EntryPoint = "wglGetProcAddress", ExactSpelling = true)]
private static extern IntPtr wglGetProcAddress(String lpszProc);
public IntPtr GetProcAddress(string function)
{
return wglGetProcAddress(function);
}
}
internal class GetProcAddressX11 : IGetProcAddress
{
[DllImport(Library, EntryPoint = "glXGetProcAddress")]
private static extern IntPtr glxGetProcAddress([MarshalAs(UnmanagedType.LPTStr)] string procName);
public IntPtr GetProcAddress(string function)
{
return glxGetProcAddress(function);
}
}
internal class GetProcAddressOSX : IGetProcAddress
{
private const string Library = "libdl.dylib";
[DllImport(Library, EntryPoint = "NSIsSymbolNameDefined")]
private static extern bool NSIsSymbolNameDefined(string s);
[DllImport(Library, EntryPoint = "NSLookupAndBindSymbol")]
private static extern IntPtr NSLookupAndBindSymbol(string s);
[DllImport(Library, EntryPoint = "NSAddressOfSymbol")]
private static extern IntPtr NSAddressOfSymbol(IntPtr symbol);
public IntPtr GetProcAddress(string function)
{
string fname = "_" + function;
if (!NSIsSymbolNameDefined(fname))
return IntPtr.Zero;
IntPtr symbol = NSLookupAndBindSymbol(fname);
if (symbol != IntPtr.Zero)
symbol = NSAddressOfSymbol(symbol);
return symbol;
}
}
#region private static IntPtr GetAddress(string function)
/// <summary>
/// Retrieves the entry point for a dynamically exported OpenGL function.
/// </summary>
/// <param name="function">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"/>
/// </remarks>
private static IntPtr GetAddress(string function)
{
if (getProcAddress == null)
{
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT ||
System.Environment.OSVersion.Platform == PlatformID.Win32S ||
System.Environment.OSVersion.Platform == PlatformID.Win32Windows ||
System.Environment.OSVersion.Platform == PlatformID.WinCE)
{
getProcAddress = new GetProcAddressWindows();
}
else if (System.Environment.OSVersion.Platform == PlatformID.Unix ||
System.Environment.OSVersion.Platform == (PlatformID)4)
{
// Distinguish between Unix and Mac OS X kernels.
switch (DetectUnixKernel())
{
case "Unix":
case "Linux":
getProcAddress = new GetProcAddressX11();
break;
case "Darwin":
getProcAddress = new GetProcAddressOSX();
break;
default:
throw new PlatformNotSupportedException(
DetectUnixKernel() + ": Unknown Unix platform - cannot load extensions. Please report a bug at http://taoframework.com");
}
}
else
{
throw new PlatformNotSupportedException(
"Extension loading is only supported under Mac OS X, Unix/X11 and Windows. We are sorry for the inconvience.");
}
}
return getProcAddress.GetProcAddress(function);
}
#endregion
#region private static string DetectUnixKernel()
/// <summary>
/// Executes "uname" which returns a string representing the name of the
/// underlying Unix kernel.
/// </summary>
/// <returns>"Unix", "Linux", "Darwin" or null.</returns>
/// <remarks>Source code from "Mono: A Developer's Notebook"</remarks>
private static string DetectUnixKernel()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "-s";
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
foreach (string unameprog in new string[] { "/usr/bin/uname", "/bin/uname", "uname" })
{
try
{
startInfo.FileName = unameprog;
Process uname = Process.Start(startInfo);
StreamReader stdout = uname.StandardOutput;
return stdout.ReadLine().Trim();
}
catch (System.IO.FileNotFoundException)
{
// The requested executable doesn't exist, try next one.
continue;
}
catch (System.ComponentModel.Win32Exception)
{
continue;
}
}
return null;
}
#endregion
#region internal static Delegate GetExtensionDelegate(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>
internal static Delegate GetExtensionDelegate(string name, Type signature)
{
IntPtr address = GetAddress(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
#endregion
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,486 @@
#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.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using OpenTK.Graphics.OpenGL;
namespace Tao.Platform.Windows
{
/// <summary>
/// Provides a simple OpenGL control allowing quick development of Windows.Forms-based
/// OpenGL applications. Relies on OpenTK.GLControl for cross-platform compatibility.
/// </summary>
[Obsolete("Use OpenTK.GLControl instead.")]
public class SimpleOpenGlControl : OpenTK.GLControl
{
#region Fields
private IContainer components; // Required for designer support
private bool autoCheckErrors = false; // Should we provide glGetError()?
private bool autoFinish = false; // Should we provide a glFinish()?
private bool autoMakeCurrent = true; // Should we automatically make the rendering context current?
private bool autoSwapBuffers = true; // Should we automatically swap buffers?
private byte accumBits = 0; // Accumulation buffer bits
private byte colorBits = 32; // Color buffer bits
private byte depthBits = 16; // Depth buffer bits
private byte stencilBits = 0; // Stencil buffer bits
private ErrorCode errorCode = ErrorCode.NoError; // The GL error code
private int logScaleX = 96; // DPI Resolution in X dir
private int logScaleY = 96; // DPI Resolution in Y dir
#endregion
#region Constructors
#region SimpleOpenGlControl()
/// <summary>
/// Constructor. Creates contexts and sets properties.
/// </summary>
public SimpleOpenGlControl()
{
InitializeStyles();
InitializeComponent();
InitializeBackground();
}
#endregion SimpleOpenGlControl()
#endregion
#region Public Members
#region DestroyContexts()
/// <summary>
///
/// </summary>
public void DestroyContexts()
{
Context.Dispose();
}
#endregion DestroyContexts()
#region Draw()
/// <summary>
/// Sends an see cref="UserControl.Invalidate" command to this control, thus
/// forcing a redraw to occur.
/// </summary>
public void Draw()
{
this.Invalidate();
}
#endregion Draw()
#region InitializeContexts()
/// <summary>
/// Creates the OpenGL contexts.
/// </summary>
public void InitializeContexts()
{
// No need to do anything, handled by the GLControl.
}
#endregion InitializeContexts()
#region LogScaleX
/// <summary>
/// Gets the number of logical pixels or dots per inch (dpi) in X-direction
/// </summary>
[Category("OpenGL Properties"), Description("Logical pixels per inch in X-direction.")]
public int LogScaleX
{
get
{
return logScaleX;
}
}
#endregion
#region LogScaleY
/// <summary>
/// Gets the number of logical pixels or dots per inch (dpi) in Y-direction
/// </summary>
[Category("OpenGL Properties"), Description("Logical pixels per inch in Y-direction.")]
public int LogScaleY
{
get
{
return logScaleY;
}
}
#endregion
#region AccumBits
/// <summary>
/// Gets and sets the OpenGL control's accumulation buffer depth.
/// </summary>
[Category("OpenGL Properties"), Description("Accumulation buffer depth in bits.")]
public byte AccumBits
{
get
{
return accumBits;
}
set
{
accumBits = value;
}
}
#endregion
#region ColorBits
/// <summary>
/// Gets and sets the OpenGL control's color buffer depth.
/// </summary>
[Category("OpenGL Properties"), Description("Color buffer depth in bits.")]
public byte ColorBits
{
get
{
return colorBits;
}
set
{
colorBits = value;
}
}
#endregion
#region DepthBits
/// <summary>
/// Gets and sets the OpenGL control's depth buffer (Z-buffer) depth.
/// </summary>
[Category("OpenGL Properties"), Description("Depth buffer (Z-buffer) depth in bits.")]
public byte DepthBits
{
get
{
return depthBits;
}
set
{
depthBits = value;
}
}
#endregion
#region StencilBits
/// <summary>
/// Gets and sets the OpenGL control's stencil buffer depth.
/// </summary>
[Category("OpenGL Properties"), Description("Stencil buffer depth in bits.")]
public byte StencilBits
{
get
{
return stencilBits;
}
set
{
stencilBits = value;
}
}
#endregion
#region AutoCheckErrors
/// <summary>
/// Gets and sets the OpenGL control's automatic sending of a glGetError command
/// after drawing.
/// </summary>
[Category("OpenGL Properties"), Description("Automatically send a glGetError command after drawing?")]
public bool AutoCheckErrors
{
get
{
return autoCheckErrors;
}
set
{
autoCheckErrors = value;
}
}
#endregion
#region AutoFinish
/// <summary>
/// Gets and sets the OpenGL control's automatic sending of a glFinish command
/// after drawing.
/// </summary>
[Category("OpenGL Properties"), Description("Automatically send a glFinish command after drawing?")]
public bool AutoFinish
{
get
{
return autoFinish;
}
set
{
autoFinish = value;
}
}
#endregion
#region AutoMakeCurrent
/// <summary>
/// Gets and sets the OpenGL control's automatic forcing of the rendering context to
/// be current before drawing.
/// </summary>
[Category("OpenGL Properties"), Description("Automatically make the rendering context current before drawing?")]
public bool AutoMakeCurrent
{
get
{
return autoMakeCurrent;
}
set
{
autoMakeCurrent = value;
}
}
#endregion
#region AutoSwapBuffers
/// <summary>
/// Gets and sets the OpenGL control's automatic sending of a SwapBuffers command
/// after drawing.
/// </summary>
[Category("OpenGL Properties"), Description("Automatically send a SwapBuffers command after drawing?")]
public bool AutoSwapBuffers
{
get
{
return autoSwapBuffers;
}
set
{
autoSwapBuffers = value;
}
}
#endregion
#endregion
#region Protected Members
#region OnPaint
/// <summary>
/// Paints the control.
/// </summary>
/// <param name="e">The paint event arguments.</param>
protected override void OnPaint(PaintEventArgs e)
{
if (this.DesignMode)
{
e.Graphics.Clear(this.BackColor);
if (this.BackgroundImage != null)
e.Graphics.DrawImage(this.BackgroundImage, this.ClientRectangle, 0, 0, this.BackgroundImage.Width, this.BackgroundImage.Height, GraphicsUnit.Pixel);
e.Graphics.Flush();
return;
}
if (autoMakeCurrent)
{
MakeCurrent();
}
base.OnPaint(e);
if (autoFinish)
{
GL.Finish();
}
if (autoCheckErrors)
{
errorCode = GL.GetError();
if (errorCode != ErrorCode.NoError)
{
switch (errorCode)
{
case ErrorCode.InvalidEnum:
MessageBox.Show("GL_INVALID_ENUM - An unacceptable value has been specified for an enumerated argument. The offending function has been ignored.", "OpenGL Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case ErrorCode.InvalidValue:
MessageBox.Show("GL_INVALID_VALUE - A numeric argument is out of range. The offending function has been ignored.", "OpenGL Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case ErrorCode.InvalidOperation:
MessageBox.Show("GL_INVALID_OPERATION - The specified operation is not allowed in the current state. The offending function has been ignored.", "OpenGL Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case ErrorCode.StackOverflow:
MessageBox.Show("GL_STACK_OVERFLOW - This function would cause a stack overflow. The offending function has been ignored.", "OpenGL Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case ErrorCode.StackUnderflow:
MessageBox.Show("GL_STACK_UNDERFLOW - This function would cause a stack underflow. The offending function has been ignored.", "OpenGL Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
case ErrorCode.OutOfMemory:
MessageBox.Show("GL_OUT_OF_MEMORY - There is not enough memory left to execute the function. The state of OpenGL has been left undefined.", "OpenGL Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
default:
MessageBox.Show("Unknown GL error. This should never happen.", "OpenGL Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
break;
}
}
}
if (autoSwapBuffers)
{
SwapBuffers();
}
}
#endregion
#region CreateParams
/// <summary>
/// Overrides the control's class style parameters.
/// </summary>
protected override CreateParams CreateParams
{
get
{
Int32 CS_VREDRAW = 0x1;
Int32 CS_HREDRAW = 0x2;
Int32 CS_OWNDC = 0x20;
CreateParams cp = base.CreateParams;
cp.ClassStyle = cp.ClassStyle | CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
return cp;
}
}
#endregion
#endregion
#region Private Members
#region InitializeBackground
/// <summary>
/// Loads the bitmap from the assembly's manifest resource.
/// </summary>
private void InitializeBackground()
{
try
{
this.BackgroundImage = OpenTK.Compatibility.Properties.Resources.TaoButton;
}
catch (Exception)
{
this.BackgroundImage = null;
}
}
#endregion
#region InitializeComponent
/// <summary>
/// Required for designer support.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
//
// SimpleOpenGlControl
//
this.BackColor = System.Drawing.Color.Black;
this.Size = new System.Drawing.Size(50, 50);
}
#endregion
#region InitializeStyles
/// <summary>
/// Initializes the control's styles.
/// </summary>
private void InitializeStyles()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, false);
this.SetStyle(ControlStyles.Opaque, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.UserPaint, true);
}
#endregion
#endregion
#region IDisposable Members
#region Dispose(bool disposing)
/// <summary>
/// Disposes the control.
/// </summary>
/// <param name="disposing">Was the disposed manually called?</param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
DestroyContexts();
base.Dispose(disposing);
}
#endregion Dispose(bool disposing)
#endregion
}
}