SDL++
C++wrapperfortheSDLlibrary.

event/EventLoop.h

Go to the documentation of this file.
00001 
00021 #ifndef SDL_EVENT_EVENTLOOP_H
00022 #define SDL_EVENT_EVENTLOOP_H
00023 
00024 #include "sdlpp/event/Dispatcher.h"
00025 #include "sdlpp/event/Queue.h"
00026 
00027 namespace sdl {
00028 namespace event {
00033     struct EventLoop {
00042         template<class Dispatcher>
00043         static void run (Dispatcher& dispatcher, unsigned int frameDelay) {
00044             Queue& queue = Queue::instance ();
00045             unsigned int start = SDL_GetTicks ();
00046             while (SDL_GetTicks () - start < frameDelay) {
00047                 if (!queue.empty ()) {
00048                     SDL_Event event = queue.pop ();
00049                     dispatcher (&event);
00050                 }
00051             }
00052         }; 
00053     }; //EventLoop
00054 }; //event
00055 }; //sdl
00056 
00057 #endif //SDL_EVENT_EVENTLOOP_H
00058 
 All Classes Namespaces Files Functions Variables Typedefs