From c819a2d9b7e8cfaad392992e937f64fff6b83521 Mon Sep 17 00:00:00 2001 From: the_fiddler 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 + /// This function creates a context using a specified device. /// a pointer to a device /// a pointer to a set of attributes: ALC_FREQUENCY, ALC_MONO_SOURCES, ALC_REFRESH, ALC_STEREO_SOURCES, ALC_SYNC /// 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. - [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 ); + /// This function creates a context using a specified device. + /// a pointer to a device + /// an array of a set of attributes: ALC_FREQUENCY, ALC_MONO_SOURCES, ALC_REFRESH, ALC_STEREO_SOURCES, ALC_SYNC + /// 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. + public static IntPtr CreateContext(IntPtr device, int[] attriblist) + { + unsafe + { + fixed (int* attriblist_ptr = attriblist) + { + return CreateContext(device, attriblist_ptr); + } + } + } + + #endregion + /// This function makes a specified context the current context. /// A pointer to the new context. /// Returns True on success, or False on failure. @@ -217,7 +238,7 @@ namespace OpenTK.OpenAL /// a pointer to the device to be queried. /// an attribute to be retrieved: ALC_DEVICE_SPECIFIER, ALC_CAPTURE_DEVICE_SPECIFIER, ALC_ALL_DEVICES_SPECIFIER /// A List of strings containing the names of the Devices. - public static List GetString(IntPtr device, Enums.AlcGetStringList param) + public static IList GetString(IntPtr device, Enums.AlcGetStringList param) { List result = new List(); IntPtr t = GetStringPrivate(AL.Null, (Enums.AlcGetString)Enums.AlcGetStringList.DeviceSpecifier); @@ -239,7 +260,7 @@ namespace OpenTK.OpenAL } } while (true); - return result; + return (IList)result; } /// This function returns integers related to the context. 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 { - ///followed by Hz + ///Followed by System.Int32 Hz Frequency = 0x1007, - ///followed by Hz + ///Followed by System.Int32 Hz Refresh = 0x1008, - ///followed by AlBoolean.True, or AlBoolean.False + ///Followed by AlBoolean.True, or AlBoolean.False Sync = 0x1009, - ///followed by Num of requested Mono (3D) Sources + ///Followed by System.Int32 Num of requested Mono (3D) Sources MonoSources = 0x1010, - ///followed by Num of requested Stereo Sources + ///Followed by System.Int32 Num of requested Stereo Sources StereoSources = 0x1011, }