X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fbackend.cc;fp=src%2Fmoof%2Fbackend.cc;h=fa3ad3102ab546a9cc630f49ff3d4a8a2fcb046b;hp=2dd199d216c846d11b0517f87c4e9a9fcc762d46;hb=574af38ed616d1adfa5e6ce35f67cda1f707f89d;hpb=6c9943707d4f33035830eba0587a61a34eaecbc2 diff --git a/src/moof/backend.cc b/src/moof/backend.cc index 2dd199d..fa3ad31 100644 --- a/src/moof/backend.cc +++ b/src/moof/backend.cc @@ -1,13 +1,15 @@ -/*] Copyright (c) 2009-2010, Charles McGarvey [************************** +/*] Copyright (c) 2009-2011, 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. * -**************************************************************************/ +*****************************************************************************/ + +#if HAVE_CONFIG_H +#include "config.h" +#endif #include @@ -21,21 +23,13 @@ namespace moof { -struct impl -{ - static bool is_initialized; - static int retain_count; -}; - -bool impl::is_initialized = false; -int impl::retain_count = 0; - +static int retain_count = 0; backend::backend() { - if (impl::retain_count++ == 0) + if (retain_count++ == 0) { -#if defined(_WIN32) +#if PLATFORM_WIN32 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) #else if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) != 0) @@ -47,45 +41,40 @@ backend::backend() { char name[128]; SDL_VideoDriverName(name, sizeof(name)); - log_info << "initialized SDL; using video driver `" - << name << "'" << std::endl; + log_info << "initialized SDL; using video driver `" << + name << "'" << std::endl; } - if (FE_Init() != 0) { throw std::runtime_error(FE_GetError()); } } - - impl::is_initialized = true; } backend::backend(const backend& backend) { - ++impl::retain_count; + ++retain_count; } -backend& backend::operator=(const backend& backend) +backend& backend::operator = (const backend& backend) { - ++impl::retain_count; + ++retain_count; return *this; } backend::~backend() { - if (--impl::retain_count == 0) + if (--retain_count == 0) { log_info("shutting down SDL..."); FE_Quit(); SDL_Quit(); - - impl::is_initialized = false; } } bool backend::is_initialized() { - return impl::is_initialized; + return 0 < retain_count; }