Jump to content
  • Advertisement
Sign in to follow this  
ade-the-heat

dInput and openAL problem

This topic is 4906 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use DirectInput for mouse/keyboard and OpenAL for sound. I have the following problem: In my game - I check the keyboard and mouse - if correct button/key then = play a fire bullet sound: Note that both options call the same function. In addition both options work correctly - I can see things get shot and = die using the mouse and the keyboard. However, the mouse option results in a choppy barely audible sound, = whereas the keypress results in a perfect sound. Obviously I'd like both to work ! Note that both keypress and mouse are recognised correctly and apart from the sound they both work well. I downloaded the latest directx sdk and that made no difference either. (if you're bored you can download the game and openal at www.3drock.co.uk ~ 40 seconds) Thanks Ade
//mouse
OnMouseDownL(float x, float y)
(
gameWorld->player->FireBullet()
}


//key
OnKeyDown(int nVirtKey)
{
case VK_NUMPAD1:
case DIK_M:
gameWorld->player->FireBullet();
break;

...
}


Player::FireBullet()
{
....
if ((bulletTime > 0.1f) && (bulletsRemaining>0))
{
  bulletTime=3D0.0f;
  bulletsRemaining--;
  sound->FireMachineGun();
...
...
//check for collisions etc
}


//OPENAL sound-
COpenALSound::FireMachineGun()
{
//now play it
ALuint ret =3D AL_NONE;
ALint value;
//check to see if source is currently playing if so then don't play =
again.
(void)alGetSourcei(PlayerSrc[SOUND_SRC_GUN], AL_SOURCE_STATE, &value);
if (value !=3D AL_PLAYING)
{
   //ie don't start it if it's already playing
   ret=3DPlay(PlayerSrc[SOUND_SRC_GUN]);
}
return ret;
}




Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!