X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FMoof%2FBackend.cc;fp=src%2FMoof%2FBackend.cc;h=0000000000000000000000000000000000000000;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hp=95f4dc3415c777f1cd0ba676bf102edca26282af;hpb=299af4f2047e767e5d79501c26444473bda64c64;p=chaz%2Fyoink diff --git a/src/Moof/Backend.cc b/src/Moof/Backend.cc deleted file mode 100644 index 95f4dc3..0000000 --- a/src/Moof/Backend.cc +++ /dev/null @@ -1,94 +0,0 @@ - -/*] Copyright (c) 2009-2010, Charles McGarvey [************************** -**] All rights reserved. -* -* vi:ts=4 sw=4 tw=75 -* -* Distributable under the terms and conditions of the 2-clause BSD license; -* see the file COPYING for a complete text of the license. -* -**************************************************************************/ - -#include -#include "fastevents.h" - -#include "Backend.hh" -#include "Error.hh" -#include "Log.hh" - - -namespace Mf { - - -struct Impl -{ - static Error error; - static int retainCount; -}; - -Error Impl::error(Error::UNINITIALIZED); -int Impl::retainCount = 0; - - -Backend::Backend() -{ - if (Impl::retainCount++ == 0) - { -#if defined(_WIN32) - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) -#else - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) != 0) -#endif - { - const char* error = SDL_GetError(); - Impl::error.init(Error::SDL_INIT, error); - return; // fatal - } - else - { - char name[128]; - SDL_VideoDriverName(name, sizeof(name)); - logInfo << "initialized SDL; using video driver `" - << name << "'" << std::endl; - } - - if (FE_Init() != 0) - { - const char* error = FE_GetError(); - Impl::error.init(Error::FASTEVENTS_INIT, error); - return; // fatal - } - - Impl::error.init(Error::NONE); - } -} - -Backend::Backend(const Backend& backend) -{ - ++Impl::retainCount; -} - -Backend::~Backend() -{ - if (--Impl::retainCount == 0) - { - FE_Quit(); - SDL_Quit(); - - Impl::error.reset(); - } -} - -bool Backend::isInitialized() -{ - return Impl::error.code() == Error::NONE; -} - -const Error& Backend::getError() -{ - return Impl::error; -} - - -} // namespace Mf -