]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/openal_test1.cxx
do not yet add the relative sound position to the absolute position, it's generating...
[simgear.git] / simgear / sound / openal_test1.cxx
index e94391e3cf283558a6246e6b9b6eba3648589707..94e3e4510303d2b0a6cc1daac69244f9131f55ea 100644 (file)
@@ -14,12 +14,18 @@ static unsigned int sleep(unsigned int secs) { return 0; }
 # include <OpenAL/al.h>
 # include <OpenAL/alc.h>
 # include <OpenAL/alut.h>
+#elif defined(OPENALSDK)
+# include <al.h>
+# include <alc.h>
+# include <AL/alut.h> 
 #else
 # include <AL/al.h>
 # include <AL/alc.h>
 # include <AL/alut.h>
 #endif
 
+#define AUDIOFILE      SRC_DIR"/jet.wav"
+
 #include <simgear/debug/logstream.hxx>
 
 static void print_openal_error( ALuint error ) {
@@ -95,11 +101,11 @@ int main( int argc, char *argv[] ) {
     ALfloat source_vel[3];
 
     // configuration values
-    ALenum format;
-    ALsizei size;
-    ALvoid* data;
-    ALsizei freq;
-    ALboolean loop;
+//    ALenum format;
+//    ALsizei size;
+//    ALvoid* data;
+//    ALsizei freq;
+    ALboolean loop = false;
 
     source_pos[0] = 0.0; source_pos[1] = 0.0; source_pos[2] = 0.0;
     source_vel[0] = 0.0; source_vel[1] = 0.0; source_vel[2] = 0.0;
@@ -115,11 +121,19 @@ int main( int argc, char *argv[] ) {
     }
 
     // Load the sample file
-#if defined (__APPLE__)
-    alutLoadWAVFile( (ALbyte *)"jet.wav", &format, &data, &size, &freq );
+#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
+
+  buffer = alutCreateBufferFromFile(AUDIOFILE);
+  if (buffer == AL_NONE) {
+    SG_LOG( SG_GENERAL, SG_ALERT, "Failed to buffer data.");
+  }
+
 #else
-    alutLoadWAVFile( (ALbyte *)"jet.wav", &format, &data, &size, &freq, &loop );
-#endif
+# if defined (__APPLE__)
+    alutLoadWAVFile( (ALbyte *)AUDIOFILE, &format, &data, &size, &freq );
+# else
+    alutLoadWAVFile( (ALbyte *)AUDIOFILE, &format, &data, &size, &freq, &loop );
+# endif
     if (alGetError() != AL_NO_ERROR) {
         SG_LOG( SG_GENERAL, SG_ALERT, "Failed to load wav file.");
     }
@@ -131,6 +145,7 @@ int main( int argc, char *argv[] ) {
     }
 
     alutUnloadWAV( format, data, size, freq );
+#endif
 
     alGenSources(1, &source);
     if (alGetError() != AL_NO_ERROR) {