Add sound

This commit is contained in:
Rob Loach 2017-06-27 22:01:33 -04:00
parent fbbffabbf2
commit 6285b85801
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A
5 changed files with 46 additions and 0 deletions

View File

@ -24,6 +24,7 @@ Application* Application::getInstance() {
void Application::quit(void) {
filesystem.unload();
sound.unload();
image.unload();
// Tell SDL to quit.
SDL_Quit();
@ -57,6 +58,7 @@ bool Application::load(const std::string& file) {
keyboard.load();
graphics.load();
image.load();
sound.load();
filesystem.load(file);
// ChaiScript.

View File

@ -17,6 +17,7 @@ public:
chaigame::graphics graphics;
chaigame::image image;
chaigame::system system;
chaigame::sound sound;
void quit(void);
bool load(const std::string& file);

View File

@ -6,7 +6,9 @@
#include "image.h"
#include "keyboard.h"
#include "script.h"
#include "sound.h"
#include "system.h"
#include "sound.h"
#include "src/Image.h"
#include "src/ImageData.h"

26
chaigame/sound.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <SDL.h>
//#include <SDL_mixer.h>
#include "sound.h"
namespace chaigame {
bool sound::load() {
/*int flags = MIX_INIT_OGG;// | MIX_INIT_MOD;
int initted = Mix_Init(flags);
if (initted&flags != flags) {
printf("Mix_Init: Failed to init required ogg and mod support!\n");
printf("Mix_Init: %s\n", Mix_GetError());
return false;
}
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1) {
printf("Mix_OpenAudio: %s\n", Mix_GetError());
return false;
}*/
return true;
}
bool sound::unload() {
//Mix_Quit();
}
}

15
chaigame/sound.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef _SOUND_H_INCLUDED_
#define _SOUND_H_INCLUDED_
#include <SDL.h>
#include <SDL_mixer.h>
namespace chaigame {
class sound {
public:
bool load();
bool unload();
};
}
#endif