-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSDLWrapper.cpp
More file actions
58 lines (43 loc) · 899 Bytes
/
Copy pathSDLWrapper.cpp
File metadata and controls
58 lines (43 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "SDLWrapper.h"
#include "ProjectLogger.h"
CSDLWrapper* CSDLWrapper::m_pThis = NULL;
CSDLWrapper* CSDLWrapper::GetInstance()
{
if(m_pThis == NULL)
{
m_pThis = new CSDLWrapper();
}
return m_pThis;
}
CSDLWrapper::CSDLWrapper()
{
}
void CSDLWrapper::Init(eInitType eType)
{
m_eInitType = eType;
if(m_eInitType == eAudioOnly)
{
SDL_Init(SDL_INIT_AUDIO);
}
if(m_eInitType == eAudioOnly)
{
/* Same setup as before */
int audio_rate = 22050;
Uint16 audio_format = AUDIO_S16;
int audio_channels = 2;
int audio_buffers = 4096;
if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers))
{
CProjectLogger::GetInstance()->Log("Cannot open audio");
exit(1);
}
}
}
CSDLWrapper::~CSDLWrapper()
{
if(m_eInitType == eAudioOnly)
{
Mix_CloseAudio();
}
SDL_Quit();
}