#include #include #include #include #include "App.h" #include "Scene.h" #include "MainRenderer.h" #include "ScriptingEngine.h" #include "StdinListener.h" bool App::isCreated = false; //====================================================================================================================== // parseCommandLineArgs = //====================================================================================================================== void App::parseCommandLineArgs(int argc, char* argv[]) { for(int i=1; iformat, 255, 0, 255); SDL_SetColorKey(iconImage, SDL_SRCCOLORKEY, colorkey); //SDL_WM_SetIcon(iconImage, NULL); SDL_SetWindowIcon(windowId, iconImage); } INFO("SDL window initialization ends"); } //====================================================================================================================== // togleFullScreen = //====================================================================================================================== void App::togleFullScreen() { //SDL_WM_ToggleFullScreen(mainSurf); SDL_SetWindowFullscreen(windowId, fullScreenFlag); fullScreenFlag = !fullScreenFlag; } //====================================================================================================================== // swapBuffers = //====================================================================================================================== void App::swapBuffers() { //SDL_GL_SwapBuffers(); SDL_GL_SwapWindow(windowId); } //====================================================================================================================== // quit = //====================================================================================================================== void App::quit(int code) { SDL_FreeSurface(iconImage); SDL_GL_DeleteContext(glContext); SDL_DestroyWindow(windowId); SDL_Quit(); exit(code); } //====================================================================================================================== // waitForNextFrame = //====================================================================================================================== void App::waitForNextFrame() { uint now = SDL_GetTicks(); if(now - time < timerTick) { // the new time after the SDL_Delay will be... time += timerTick; // sleep a little SDL_Delay(time - now); } else time = now; } //====================================================================================================================== // printAppInfo = //====================================================================================================================== #if !defined(REVISION) #define REVISION "unknown" #endif void App::printAppInfo() { stringstream msg; msg << "App info: debugging "; #if DEBUG_ENABLED == 1 msg << "on, "; #else msg << "off, "; #endif msg << "platform "; #if defined(PLATFORM_LINUX) msg << "Linux, "; #elif defined(PLATFORM_WIN) msg << "Windows, "; #else #error "See file" #endif msg << "GLEW " << glewGetString(GLEW_VERSION) << ", "; const SDL_version* v = SDL_Linked_Version(); msg << "SDL " << int(v->major) << '.' << int(v->minor) << '.' << int(v->patch) << ", "; msg << "build date " __DATE__ << ", "; msg << "rev " << REVISION; INFO(msg.str()); } //====================================================================================================================== // getDesktopWidth = //====================================================================================================================== uint App::getDesktopWidth() const { SDL_DisplayMode mode; SDL_GetDesktopDisplayMode(&mode); return mode.w; } //====================================================================================================================== // getDesktopHeight = //====================================================================================================================== uint App::getDesktopHeight() const { SDL_DisplayMode mode; SDL_GetDesktopDisplayMode(&mode); return mode.h; } //====================================================================================================================== // getTicks = //====================================================================================================================== uint App::getTicks() { return SDL_GetTicks(); }