From c819a2d9b7e8cfaad392992e937f64fff6b83521 Mon Sep 17 00:00:00 2001 From: the_fiddler <the_fiddler@ebc5dd9b-fb1d-0410-b6f8-d24c324e9604> Date: Thu, 17 Jan 2008 14:06:31 +0000 Subject: [PATCH] Update the Alc.CreateContext function. --- Source/OpenTK/OpenAL/AlcFunctions.cs | 29 ++++++++++++++++++++++++---- Source/OpenTK/OpenAL/AlcTokens.cs | 10 +++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Source/OpenTK/OpenAL/AlcFunctions.cs b/Source/OpenTK/OpenAL/AlcFunctions.cs index 1a0fe2a1..fa4bf2e9 100644 --- a/Source/OpenTK/OpenAL/AlcFunctions.cs +++ b/Source/OpenTK/OpenAL/AlcFunctions.cs @@ -81,14 +81,35 @@ namespace OpenTK.OpenAL #region Context Management + #region CreateContext + /// <summary>This function creates a context using a specified device.</summary> /// <param name="device">a pointer to a device</param> /// <param name="attrlist">a pointer to a set of attributes: ALC_FREQUENCY, ALC_MONO_SOURCES, ALC_REFRESH, ALC_STEREO_SOURCES, ALC_SYNC</param> /// <returns>Returns a pointer to the new context (NULL on failure). The attribute list can be NULL, or a zero terminated list of integer pairs composed of valid ALC attribute tokens and requested values.</returns> - [DllImport(Alc.Lib, EntryPoint = "alcCreateContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] - public static extern IntPtr CreateContext([In] IntPtr device, [In] IntPtr attrlist); + [DllImport(Alc.Lib, EntryPoint = "alcCreateContext", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity] + [CLSCompliant(false)] + unsafe public static extern IntPtr CreateContext([In] IntPtr device, [In] int* attrlist); // ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist ); + /// <summary>This function creates a context using a specified device.</summary> + /// <param name="device">a pointer to a device</param> + /// <param name="attrlist">an array of a set of attributes: ALC_FREQUENCY, ALC_MONO_SOURCES, ALC_REFRESH, ALC_STEREO_SOURCES, ALC_SYNC</param> + /// <returns>Returns a pointer to the new context (NULL on failure).</returns> + /// <remarks>The attribute list can be NULL, or a zero terminated list of integer pairs composed of valid ALC attribute tokens and requested values.</remarks> + public static IntPtr CreateContext(IntPtr device, int[] attriblist) + { + unsafe + { + fixed (int* attriblist_ptr = attriblist) + { + return CreateContext(device, attriblist_ptr); + } + } + } + + #endregion + /// <summary>This function makes a specified context the current context.</summary> /// <param name="context">A pointer to the new context.</param> /// <returns>Returns True on success, or False on failure.</returns> @@ -217,7 +238,7 @@ namespace OpenTK.OpenAL /// <param name="device">a pointer to the device to be queried.</param> /// <param name="param">an attribute to be retrieved: ALC_DEVICE_SPECIFIER, ALC_CAPTURE_DEVICE_SPECIFIER, ALC_ALL_DEVICES_SPECIFIER</param> /// <returns>A List of strings containing the names of the Devices.</returns> - public static List<string> GetString(IntPtr device, Enums.AlcGetStringList param) + public static IList<string> GetString(IntPtr device, Enums.AlcGetStringList param) { List<string> result = new List<string>(); IntPtr t = GetStringPrivate(AL.Null, (Enums.AlcGetString)Enums.AlcGetStringList.DeviceSpecifier); @@ -239,7 +260,7 @@ namespace OpenTK.OpenAL } } while (true); - return result; + return (IList<string>)result; } /// <summary>This function returns integers related to the context.</summary> diff --git a/Source/OpenTK/OpenAL/AlcTokens.cs b/Source/OpenTK/OpenAL/AlcTokens.cs index b7d42cd5..8bbffbb5 100644 --- a/Source/OpenTK/OpenAL/AlcTokens.cs +++ b/Source/OpenTK/OpenAL/AlcTokens.cs @@ -14,19 +14,19 @@ namespace OpenTK.OpenAL.Enums public enum AlcContextAttributes : int { - ///<summary>followed by <int> Hz</summary> + ///<summary>Followed by System.Int32 Hz</summary> Frequency = 0x1007, - ///<summary>followed by <int> Hz</summary> + ///<summary>Followed by System.Int32 Hz</summary> Refresh = 0x1008, - ///<summary>followed by AlBoolean.True, or AlBoolean.False</summary> + ///<summary>Followed by AlBoolean.True, or AlBoolean.False</summary> Sync = 0x1009, - ///<summary>followed by <int> Num of requested Mono (3D) Sources</summary> + ///<summary>Followed by System.Int32 Num of requested Mono (3D) Sources</summary> MonoSources = 0x1010, - ///<summary>followed by <int> Num of requested Stereo Sources</summary> + ///<summary>Followed by System.Int32 Num of requested Stereo Sources</summary> StereoSources = 0x1011, }