]> git.mxchange.org Git - simgear.git/commitdiff
Make sure it works with the lates version of OpenAL.
authorehofman <ehofman>
Mon, 4 Jul 2005 09:20:11 +0000 (09:20 +0000)
committerehofman <ehofman>
Mon, 4 Jul 2005 09:20:11 +0000 (09:20 +0000)
simgear/sound/openal_test1.cxx

index 5d56bc9e83222ae9df692ad0faa3b61a876b108d..e94391e3cf283558a6246e6b9b6eba3648589707 100644 (file)
@@ -12,9 +12,11 @@ static unsigned int sleep(unsigned int secs) { return 0; }
 # define AL_ILLEGAL_ENUM AL_INVALID_ENUM
 # define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION
 # include <OpenAL/al.h>
+# include <OpenAL/alc.h>
 # include <OpenAL/alut.h>
 #else
 # include <AL/al.h>
+# include <AL/alc.h>
 # include <AL/alut.h>
 #endif
 
@@ -39,10 +41,16 @@ static void print_openal_error( ALuint error ) {
 
 int main( int argc, char *argv[] ) {
     // initialize OpenAL
-    alutInit( 0, NULL );
-    alGetError();
-    if ( alGetError() != AL_NO_ERROR) {
-       SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
+    ALCdevice *dev;
+    ALCcontext *context;
+
+    // initialize OpenAL
+    if ( (dev = alcOpenDevice( NULL )) != NULL
+            && ( context = alcCreateContext( dev, NULL )) != NULL ) {
+        alcMakeContextCurrent( context );
+    } else {
+        context = 0;
+        SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
     }
 
     // Position of the listener.