[Openal] Re: compiling using g++
Paul Tawk
p_tawk at yahoo.com
Wed Oct 25 12:53:18 PDT 2006
I have a file main.cpp in which i copied a file from the OpenAL tutorial for linux. I use the linux shell and the g++ compiler, but maybe i shoud link the openAL files when compiling.
I tried the statment:
g++ -Wall -D__LINUX_OSS__ -o main main.cpp
what additional commands should i include in my statment?
best regards
Below is the ccode i used in main.cpp
#include <conio.h>
#include <time.h>
#include <stdlib.h> #include <al/al.h>
#include <al/alc.h>
#include <al/alu.h>
#include <al/alut.c>
// Buffers hold sound data.
ALuint Buffer;
// Sources are points of emitting sound.
ALuint Source;
// Position of the source sound.
ALfloat SourcePos[] = { 0.0, 0.0, 0.0 };
// Velocity of the source sound.
ALfloat SourceVel[] = { 0.0, 0.0, 0.1 };
// Position of the listener.
ALfloat ListenerPos[] = { 0.0, 0.0, 0.0 };
// Velocity of the listener.
ALfloat ListenerVel[] = { 0.0, 0.0, 0.0 };
// Orientation of the listener. (first 3 elements are "at", second 3 are "up")
ALfloat ListenerOri[] = { 0.0, 0.0, -1.0, 0.0, 1.0, 0.0 };
ALboolean LoadALData() { // Variables to load into. ALenum format; ALsizei size; ALvoid* data; ALsizei freq; ALboolean loop; // Load wav data into a buffer. alGenBuffers(1, &Buffer); if (alGetError() != AL_NO_ERROR) return AL_FALSE; alutLoadWAVFile("wavdata/Footsteps.wav", &format, &data, &size, &freq, &loop); alBufferData(Buffer, format, data, size, freq); alutUnloadWAV(format, data, size, freq); // Bind buffer with a source. alGenSources(1, &Source); if (alGetError() != AL_NO_ERROR) return AL_FALSE; alSourcei (Source, AL_BUFFER, Buffer ); alSourcef (Source, AL_PITCH, 1.0f ); alSourcef (Source, AL_GAIN, 1.0f ); alSourcefv(Source, AL_POSITION, SourcePos); alSourcefv(Source, AL_VELOCITY, SourceVel); alSourcei (Source, AL_LOOPING, AL_TRUE ); // Do an error check and return. if (alGetError() !=
AL_NO_ERROR) return AL_FALSE; return AL_TRUE; }
void SetListenerValues() { alListenerfv(AL_POSITION, ListenerPos); alListenerfv(AL_VELOCITY, ListenerVel); alListenerfv(AL_ORIENTATION, ListenerOri); } void KillALData() { alDeleteBuffers(1, &Buffer); alDeleteSources(1, &Source); alutExit(); }
int main(int argc, char *argv[]) { // Initialize OpenAL and clear the error bit. alutInit(NULL,0); alGetError(); // Load the wav data. if (LoadALData() == AL_FALSE) return 0; SetListenerValues(); // Setup an exit procedure. atexit(KillALData); // Begin the source playing. alSourcePlay(Source); // Loop ALint time = 0; ALint elapse = 0; while (!kbhit()) { elapse += clock() - time; time += elapse; if (elapse > 50) { elapse = 0; SourcePos[0] += SourceVel[0]; SourcePos[1] += SourceVel[1]; SourcePos[2] += SourceVel[2]; alSourcefv(Source, AL_POSITION, SourcePos); } } return 0; }
---------------------------------
How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://opensource.creative.com/pipermail/openal/attachments/20061025/4393aa51/attachment.html
More information about the Openal
mailing list