Graphics: Added font rendering functions Graphics::DrawText and Graphics::StringImage.

FileHandler: Added support for wav
Audio: Added support to play back a sound with XAudio2. We can't delete sounds until we make our own system to keep track of available voices.
LoginScreen scene: Upped framerate from 15fps to tickless, and added new logic to clone the scrolling text at the bottom. All of it.
This commit is contained in:
Fatbag 2012-04-20 19:37:08 -05:00
parent 64a5c0a425
commit 06f13d50ac
14 changed files with 429 additions and 162 deletions

View file

@ -49,6 +49,65 @@ int Initialize(){
return 0;
}
PlayableSound_t * LoadSound(const Sound_t * Sound){
const WAVEFORMATEX wfx = {
WAVE_FORMAT_PCM, //wFormatTag
Sound->Channels, //nChannels
Sound->SamplingRate, //nSamplesPerSec
((Sound->Channels * Sound->BitDepth) >> 3) * Sound->SamplingRate, //nAvgBytesPerSec
((Sound->Channels * Sound->BitDepth) >> 3), //nBlockAlign
Sound->BitDepth, //wBitsPerSample;
0 //cbSize
};
const XAUDIO2_BUFFER buffer = {
0, //Flags
Sound->Duration * wfx.nBlockAlign, //AudioBytes
Sound->Data, //pAudioData
0, //PlayBegin
0, //PlayLength
0, //LoopBegin
0, //LoopLength
XAUDIO2_LOOP_INFINITE, //LoopCount
NULL, //pContext
};
IXAudio2SourceVoice* pSourceVoice;
if(FAILED(pXAudio2->CreateSourceVoice(&pSourceVoice, &wfx)))
return NULL;
if(FAILED(pSourceVoice->SubmitSourceBuffer(&buffer)))
return NULL;
PlayableSound_t * PlayableSound = (PlayableSound_t*) malloc(sizeof(PlayableSound_t));
if(!PlayableSound)
return NULL;
PlayableSound->pSourceVoice = pSourceVoice;
PlayableSound->Playing = false;
PlayableSound->Data = Sound->Data;
return PlayableSound;
}
bool PlaySound(PlayableSound_t * Sound){
if(!Sound->Playing && !FAILED(Sound->pSourceVoice->Start(0))){
Sound->Playing = true;
return true;
}
return false;
}
bool StopSound(PlayableSound_t * Sound){
int success = false;
if(Sound->Playing && !FAILED(Sound->pSourceVoice->Stop(0)))
success = true;
Sound->Playing = false;
return success;
}
void DeleteSound(PlayableSound_t * Sound){
StopSound(Sound);
//Sound->pSourceVoice->Release();
}
void Shutdown(){
if(MasterVoice){
MasterVoice->DestroyVoice();