diff --git a/Engine.cc b/Engine.cc index 38e59a8..2e4e216 100644 --- a/Engine.cc +++ b/Engine.cc @@ -2,6 +2,7 @@ #include "ag.h" #include "anaglym.h" #include "Engine.h" +#include "Video.h" #include "sdl_keymap.h" #include #include /* exit() */ @@ -24,7 +25,8 @@ Engine * g_engine; SDL_Event Engine::userEvent; -Engine::Engine(const string & path) +Engine::Engine(const string & path, Video & video) + : m_video(video) { m_next_object_index = 1; m_eye[0] = 0; @@ -312,11 +314,26 @@ void Engine::run() switch (event.type) { case SDL_KEYDOWN: - if (event.key.keysym.sym == SDLK_ESCAPE) + switch (event.key.keysym.sym) { - goto RET; + case SDLK_ESCAPE: + goto RET; + case SDLK_F1: + m_video.toggleFullScreen(); + break; + case SDLK_F2: + SDL_ShowCursor( + SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE + ? SDL_DISABLE + : SDL_ENABLE); + SDL_WM_GrabInput( + SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON + ? SDL_GRAB_OFF + : SDL_GRAB_ON); + break; + default: + key_down_event(event.key.keysym.sym); } - key_down_event(event.key.keysym.sym); break; case SDL_KEYUP: key_up_event(event.key.keysym.sym); diff --git a/Engine.h b/Engine.h index e4a4af6..7898ed8 100644 --- a/Engine.h +++ b/Engine.h @@ -9,6 +9,7 @@ #include "OdeWorld/OdeWorld.h" #include "TextureCache/TextureCache.h" #include "wfobj/WFObj.h" +#include "Video.h" class Engine { @@ -78,7 +79,7 @@ class Engine Engine * m_engine; }; - Engine(const std::string & path); + Engine(const std::string & path, Video & video); ~Engine(); std::string locateResource(const std::string & shortname); @@ -130,6 +131,7 @@ class Engine void checkForFunctionFull(const std::string & lua_fn_name, const std::string & event_name, bool & presentFlag); + Video & m_video; TextureCache m_textureCache; EngineFileLoader * m_fileLoader; lua_State * m_luaState; diff --git a/Video.h b/Video.h index 501c927..db33b07 100644 --- a/Video.h +++ b/Video.h @@ -14,6 +14,7 @@ class Video void stop(); int getDefaultWidth() { return m_defaultWidth; } int getDefaultHeight() { return m_defaultHeight; } + void toggleFullScreen() { SDL_WM_ToggleFullScreen(m_surface); } protected: int m_defaultWidth; diff --git a/anaglym.cc b/anaglym.cc index 0bdfd5a..d1891f4 100644 --- a/anaglym.cc +++ b/anaglym.cc @@ -72,7 +72,7 @@ int main(int argc, char * argv[]) Video video; video.start(width, height, fullscreen, grab_input); - g_engine = new Engine(argv[0]); + g_engine = new Engine(argv[0], video); if (g_engine->load(program)) g_engine->run(); delete g_engine;