From 6980d1d1465c11f3afaf2e0c29503990ad3fb906 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Mon, 8 Dec 2008 03:22:46 +0000 Subject: Tiles performance improvements. redraw() is not needlessly done three times as often as it should. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7776 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/delay.cc | 5 +++++ crawl-ref/source/libgui.cc | 2 +- crawl-ref/source/tilesdl.cc | 14 ++++++++++++++ crawl-ref/source/tilesdl.h | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index bc9c19376b..b12f293868 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -1517,6 +1517,11 @@ static command_type _get_running_command() if (is_resting()) { you.running.rest(); + +#ifdef USE_TILE + tiles.redraw(); +#endif + if (!is_resting() && you.running.hp == you.hp && you.running.mp == you.magic_points) { diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc index 87839a9c78..e934d5ee64 100644 --- a/crawl-ref/source/libgui.cc +++ b/crawl-ref/source/libgui.cc @@ -343,7 +343,7 @@ void delay(int ms) void update_screen() { - tiles.redraw(); + tiles.set_need_redraw(); } int kbhit() diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index ccc34e7813..1cc27c12a2 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -79,6 +79,7 @@ TilesFramework::TilesFramework() : m_viewsc(0, 0), m_context(NULL), m_fullscreen(false), + m_need_redraw(false), m_active_layer(LAYER_CRT), m_buttons_held(0), m_key_mod(0), @@ -591,6 +592,12 @@ int TilesFramework::getch_ck() unsigned int res = std::max(30, Options.tile_tooltip_ms); SDL_SetTimer(res, &_timer_callback); + if (m_need_redraw) + { + redraw(); + last_redraw_tick = SDL_GetTicks(); + } + while (!key) { unsigned int ticks = 0; @@ -944,6 +951,8 @@ void TilesFramework::cgotoxy(int x, int y, int region) void TilesFramework::redraw() { + m_need_redraw = false; + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); @@ -1274,3 +1283,8 @@ void TilesFramework::clear_overlays() { m_region_tile->clear_overlays(); } + +void TilesFramework::set_need_redraw() +{ + m_need_redraw = true; +} diff --git a/crawl-ref/source/tilesdl.h b/crawl-ref/source/tilesdl.h index 735189c95b..258ea5b3a3 100644 --- a/crawl-ref/source/tilesdl.h +++ b/crawl-ref/source/tilesdl.h @@ -106,6 +106,7 @@ public: void clear_minimap(); void update_inventory(); + void set_need_redraw(); void redraw(); void place_cursor(cursor_type type, const coord_def &gc); @@ -134,6 +135,7 @@ protected: SDL_Surface* m_context; bool m_fullscreen; + bool m_need_redraw; enum LayerID { -- cgit v1.2.3-54-g00ecf