Mercurial > otakunoraifu
diff window/system.cc @ 52:15a18fbe6f21
* Known bugs added to the README
* Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author | thib |
---|---|
date | Sat, 18 Apr 2009 18:35:39 +0000 |
parents | 223b71206888 |
children | d7cde171a1de |
line wrap: on
line diff
--- a/window/system.cc +++ b/window/system.cc @@ -25,84 +25,88 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include<SDL.h> -#include"system.h" -#include<iostream> -#include<stdio.h> +#include <SDL.h> +#include "system.h" +#include <iostream> +#include <stdio.h> using namespace std; // void SDL_SetEventFilter(SDL_EventFilter filter); // typedef int (*SDL_EventFilter)(const SDL_Event *event); namespace System { + Main* Main::instance = NULL; -Main* Main::instance = 0; + int Main::event_filter(const SDL_Event* event) { + return 1; /* throw all event */ + } -int Main::event_filter(const SDL_Event* event) { - return 1; /* throw all event */ -} + Main::Main(void) { + instance = this; + framerate = 20; + cursor = NULL; + } -Main::Main(void) { - instance = this; - framerate = 20; - cursor = 0; -} -Main::~Main() { - if (cursor) delete cursor; -} -void Main::Quit(void) { - is_exit = true; -} -void Main::EnableVideo(void) { - is_video_update = true; -} -void Main::DisableVideo(void) { - is_video_update = false; -} -bool Main::is_exit = false; -bool Main::is_video_update = true; + Main::~Main() { + if (cursor) delete cursor; + } + + void Main::Quit(void) { + is_exit = true; + } + + void Main::EnableVideo(void) { + is_video_update = true; + } + + void Main::DisableVideo(void) { + is_video_update = false; + } + + bool Main::is_exit = false; + bool Main::is_video_update = true; -void Main::Mainloop(void) { - SDL_SetEventFilter(&event_filter); - Uint32 old_time = 0; - while(!is_exit) { - Uint32 start_time = SDL_GetTicks(); - if (! event.Exec(start_time)) break; - if (start_time - old_time > 1000/framerate) { - if (is_video_update) root.ExecUpdate(); - event.Exec(Event::Time::FRAME_UPDATE); - cout.flush(); - old_time = start_time; - } + void Main::Mainloop(void) { + SDL_SetEventFilter(&event_filter); + Uint32 old_time = 0; + while(!is_exit) { + Uint32 start_time = SDL_GetTicks(); + if (! event.Exec(start_time)) break; + if (start_time - old_time > 1000/framerate) { + if (is_video_update) root.ExecUpdate(); + event.Exec(Event::Time::FRAME_UPDATE); + cout.flush(); + old_time = start_time; + } -// 問題: -// z 軸と xy 軸の相互干渉;高速化 -// 移動するウィジット描画の高速化 -// キャッシュ -// 文字列の一部のみ更新の高速化 -// 「階層 z で x なる領域無効化、y なる領域生成」で良い?>Expose -/* - Uint32 end_time = SDL_GetTicks(); - Uint32 delay = (end_time-start_time); - if(delay < 1000/framerate) SDL_Delay(1000/framerate - delay); - else SDL_Delay(0); -*/ - SDL_Delay(0); - }; -} + // 問題: + // z 軸と xy 軸の相互干渉;高速化 + // 移動するウィジット描画の高速化 + // キャッシュ + // 文字列の一部のみ更新の高速化 + // 「階層 z で x なる領域無効化、y なる領域生成」で良い?>Expose + /* + Uint32 end_time = SDL_GetTicks(); + Uint32 delay = (end_time-start_time); + if(delay < 1000/framerate) SDL_Delay(1000/framerate - delay); + else SDL_Delay(0); + */ + SDL_Delay(0); + } + } -void Main::SetCursor(Surface* s, const Rect& r) { - if (instance == 0) return; - if (instance->cursor) delete instance->cursor; - if (s == 0) { // カーソル消去 - instance->cursor = 0; - } else if (s == DEFAULT_MOUSECURSOR) { - instance->cursor = 0; - SDL_ShowCursor(SDL_ENABLE); - } else { - instance->cursor = new WidMouseCursor(instance->event, instance->root.root, s, r.lx, r.ty, r.width(), r.height()); - instance->cursor->show(); - SDL_ShowCursor(SDL_DISABLE); + void Main::SetCursor(Surface* s, const Rect& r) { + if (instance == 0) return; + if (instance->cursor) delete instance->cursor; + if (s == 0) { // カーソル消去 + instance->cursor = 0; + } else if (s == DEFAULT_MOUSECURSOR) { + instance->cursor = 0; + SDL_ShowCursor(SDL_ENABLE); + } else { + instance->cursor = new WidMouseCursor(instance->event, instance->root.root, s, r.lx, r.ty, r.width(), r.height()); + instance->cursor->show(); + SDL_ShowCursor(SDL_DISABLE); + } } } -}