mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
Add experimental constructor of SDLSystem
This commit is contained in:
parent
e080389709
commit
6b213984c6
|
@ -1,6 +1,46 @@
|
|||
#include "SDLSystem.h"
|
||||
#include "_caster.h"
|
||||
#include "begin_code.h"
|
||||
// private
|
||||
void SDLSystem::_init(Uint32 sdl_flag, Uint32 img_flag, Uint32 mix_flag, bool init_ttf) throw (ErrorViewer)
|
||||
{
|
||||
int ret=SDL_Init(sdl_flag);
|
||||
if(ret!=0)
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
}
|
||||
|
||||
Uint32 uret=0;
|
||||
uret=IMG_Init(img_flag);
|
||||
if(uret!=img_flag) /// IMG_Init returns its parameter on success.
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
}
|
||||
|
||||
uret=Mix_Init(mix_flag);
|
||||
if(uret!=mix_flag) /// Mix_Init returns its parameter on success.
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if(init_ttf)
|
||||
{
|
||||
ret=TTF_Init();
|
||||
if(ret!=0)
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDLSystem::SDLSystem(const std::initializer_list<SDLInitFlag>& flag_sdl,
|
||||
const std::initializer_list<IMGInitFlag>& flag_img,
|
||||
const std::initializer_list<MixInitFlag>& flag_mix,
|
||||
|
@ -22,42 +62,29 @@ SDLSystem::SDLSystem(const std::initializer_list<SDLInitFlag>& flag_sdl,
|
|||
mix_flag |= _internal::getIntFromMixInitFlag(v);
|
||||
}
|
||||
|
||||
int ret=SDL_Init(sdl_flag);
|
||||
if(ret!=0)
|
||||
try
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
_init(sdl_flag,img_flag,mix_flag,init_ttf);
|
||||
}
|
||||
|
||||
ret=IMG_Init(img_flag);
|
||||
if(ret!=img_flag) /// IMG_Init returns its parameter on success.
|
||||
catch(ErrorViewer& e)
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
}
|
||||
|
||||
ret=Mix_Init(mix_flag);
|
||||
if(ret!=mix_flag) /// Mix_Init returns its parameter on success.
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if(init_ttf)
|
||||
{
|
||||
ret=TTF_Init();
|
||||
if(ret!=0)
|
||||
{
|
||||
ErrorViewer e;
|
||||
e.fetch();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDLSystem::SDLSystem(Uint32 sdl_flag, Uint32 img_flag, Uint32 mix_flag, bool init_ttf) throw (ErrorViewer)
|
||||
{
|
||||
try
|
||||
{
|
||||
_init(sdl_flag,img_flag,mix_flag,init_ttf);
|
||||
}
|
||||
catch(ErrorViewer& e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SDLSystem::~SDLSystem()
|
||||
{
|
||||
if(TTF_WasInit())
|
||||
|
|
|
@ -19,6 +19,8 @@ public:
|
|||
const std::initializer_list<IMGInitFlag>& flag_img = {IMGInitFlag::JPG,IMGInitFlag::PNG} ,
|
||||
const std::initializer_list<MixInitFlag>& flag_mix = {MixInitFlag::MP3} ,
|
||||
bool init_ttf = true ) throw (ErrorViewer);
|
||||
/// Experimental Constructor
|
||||
SDLSystem(Uint32 sdl_flag, Uint32 img_flag, Uint32 mix_flag, bool init_ttf) throw (ErrorViewer);
|
||||
~SDLSystem();
|
||||
|
||||
static void Delay(int ms);
|
||||
|
@ -66,5 +68,9 @@ public:
|
|||
static std::string GetExternal();
|
||||
static void* GetJNIEnv();
|
||||
};
|
||||
|
||||
private:
|
||||
void _init(Uint32,Uint32,Uint32,bool) throw (ErrorViewer);
|
||||
void _quit();
|
||||
};
|
||||
#include "end_code.h"
|
||||
|
|
Loading…
Reference in New Issue
Block a user