internal static bool Initialize() {
Deinitialize();
switch (Interface.CurrentOptions.SoundRange) {
case Interface.SoundRange.Low:
OuterRadiusFactorMinimum = 2.0;
OuterRadiusFactorMaximum = 8.0;
OuterRadiusFactorMaximumSpeed = 1.0;
break;
case Interface.SoundRange.Medium:
OuterRadiusFactorMinimum = 4.0;
OuterRadiusFactorMaximum = 16.0;
OuterRadiusFactorMaximumSpeed = 2.0;
break;
case Interface.SoundRange.High:
OuterRadiusFactorMinimum = 6.0;
OuterRadiusFactorMaximum = 24.0;
OuterRadiusFactorMaximumSpeed = 3.0;
break;
}
OuterRadiusFactor = Math.Sqrt(OuterRadiusFactorMinimum * OuterRadiusFactorMaximum);
OuterRadiusFactorSpeed = 0.0;
OpenAlDevice = Alc.OpenDevice(null);
if (OpenAlDevice != IntPtr.Zero)
{
OpenAlContext = Alc.CreateContext(OpenAlDevice, (int[])null);
if (OpenAlContext != ContextHandle.Zero) {
Alc.MakeContextCurrent(OpenAlContext);
try {
AL.SpeedOfSound(343.0f);
} catch {
MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_version"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
AL.DistanceModel(ALDistanceModel.None);
return true;
}
Alc.CloseDevice(OpenAlDevice);
OpenAlDevice = IntPtr.Zero;
MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_context"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
return false;
}
OpenAlContext = ContextHandle.Zero;
MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_device"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
return false;
}