New Paste :: Recent Pastes:: Add Line Numbers
sdl class by godecho
#ifndef SDLVIDEO_H_ #define SDLVIDEO_H_ class SDLVideo { public: ~SDLVideo(); static void init(); private: SDLVideo(); }; // SDLVideo #endif // SDLVIDEO_H_ // *********************************************************** #include "SDLVideo.h" #include "SDL.h" #include <cstdlib> // for exit() #include <iostream> SDLVideo::SDLVideo() { if(SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) { std::cerr << "InitSubSystem() failed. SDL Error: " << SDL_GetError() << std::endl; exit(1); } } SDLVideo::~SDLVideo() { SDL_Quit(); } void SDLVideo::init() { static SDLVideo sdlvideo; // Calls constructor the constructor once, and only once. }