#pragma comment(lib, "OpenAL32.lib")
#pragma comment(lib, "ALut.lib")
#pragma comment(lib, "winmm.lib")
#include <windows.h>
#include <mmsystem.h>
#include <al/al.h>
#include <al/alc.h>
#include <al/alut.h>
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
ALuint iBuffer;
ALuint iSource;
ALint state;
alGenBuffers(1, &iBuffer);
ALsizei size, freq;
ALenum format;
ALvoid* data;
ALboolean loop;
alutLoadWAVFile("25shotgun25.wav", &format, &data, &size, &freq, &loop);
alBufferData(iBuffer, format, data, size, freq);
alutUnloadWAV(format, data, size, freq);
alGenSources(1, &iSource);
alSourcei(iSource, AL_BUFFER, iBuffer);
MessageBox(0, "alSourcePlay", "Message", MB_OK);
alSourcePlay(iSource);
alGetSourcei(iSource, AL_SOURCE_STATE, &state);
while(state == AL_PLAYING)
{
alGetSourcei(iSource, AL_SOURCE_STATE, &state);
}
MessageBox(0, "PlaySound", "Message", MB_OK);
PlaySound("25shotgun25.wav", NULL, SND_SYNC);
alDeleteSources(1, &iSource);
MessageBox(0, "The End!", "Message", MB_OK);
return 0;
}
PLZ help
Why doesn't this openAL work! It's almost exactly the same as the sample - the sample works, this doesn't. Its been bugging me for over 3 days now! The PlaySound code works, but openAL part doesn't play the sound for some reason!
BIG thanks to anyone, anyone who can solve this!
How does it fail? What do the al... functions return? What debugging have you actually tried?
This is the 4th part of a 4 part debugging scheme I drew - the original openAL comes from my game engine (I was on a roll until this crap!), the 2nd was checking the error codes - nothing comes up, openAL says everything is fine, the 3rd I though my file, "25shotgun25.wav" might be corrupted, so I plugged that name into the samples and it worked just fine. So here I am, the 4th step, testing openAL as a separate system, not distracted by DirectInput or OpenGL.
Now I'm at the point of desperation - I can't think of much more debugging to do. If this fails and I never get it working, my Game Engine is as good as trash.
PS-I'm not the master debugger, so these "steps" may seem a little weird and out of order.
Now I'm at the point of desperation - I can't think of much more debugging to do. If this fails and I never get it working, my Game Engine is as good as trash.
PS-I'm not the master debugger, so these "steps" may seem a little weird and out of order.
1) you should check return codes. They often give you some informations about what's wrong.
2) Since PlaySound works, this is not a path problem, so the problem lies in your openal code - almost exactly the same != the same.
Regards,
2) Since PlaySound works, this is not a path problem, so the problem lies in your openal code - almost exactly the same != the same.
Regards,
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement