diff options
author | pixel <pixel> | 2003-01-21 01:50:58 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-01-21 01:50:58 +0000 |
commit | cbb8340d3b139596e94f2caa3ca51577d8fa3d0e (patch) | |
tree | b31bd1948b461e6f4bbd87394bede1ec2285f464 /lib | |
parent | f953fad0ce8c3358659fb63e99e0798bc20c392e (diff) |
Fixed a bit the SDL code...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/engine.cc | 38 | ||||
-rw-r--r-- | lib/glbase.cc | 1 |
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/engine.cc b/lib/engine.cc index 84014c7..d065346 100644 --- a/lib/engine.cc +++ b/lib/engine.cc @@ -13,6 +13,8 @@ int mogltk::engine::setup() throw(GeneralException) { throw GeneralException(_("Unable to start SDL base system")); } atexit(SDL_Quit); + + SDL_ShowCursor(0); inited = 1; @@ -87,3 +89,39 @@ SDL_RWops * mogltk::engine::RWFromHandle(Handle * h) throw (GeneralException) { } return r; } + +void mogltk::engine::pollevents() { + SDL_Event event; + + while(true) { + SDL_WaitEvent(&event); + switch(event.type) { + case SDL_VIDEOEXPOSE: + printm(M_INFO, "Needs to redraw\n"); + return; + case SDL_MOUSEMOTION: + printm(M_INFO, "Mouse has gone over the screen - (%i, %i)\n", event.motion.x, event.motion.y); + break; + case SDL_QUIT: + printm(M_INFO, "Quit requested\n"); + exit(0); + break; + case SDL_ACTIVEEVENT: + switch (event.active.state) { + case SDL_APPMOUSEFOCUS: + printm(M_INFO, String("Application ") + (event.active.gain ? "gained" : "loosed") + " mouse focus\n"); + break; + case SDL_APPINPUTFOCUS: + printm(M_INFO, String("Application ") + (event.active.gain ? "gained" : "loosed") + " input focus\n"); + break; + case SDL_APPACTIVE: + printm(M_INFO, String("Application was ") + (event.active.gain ? "restored" : "iconified")); + break; + } + break; + default: + printm(M_INFO, "Unknow event: %i\n", event.type); + break; + } + } +} diff --git a/lib/glbase.cc b/lib/glbase.cc index 0db56db..346421f 100644 --- a/lib/glbase.cc +++ b/lib/glbase.cc @@ -120,6 +120,7 @@ void mogltk::glbase::Leave2DMode(void) { void mogltk::glbase::Flip() { SDL_GL_SwapBuffers(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + mogltk::engine::pollevents(); } bool mogltk::glbase::is2D() { |