From d393b923b29792def5a4d9878562e398dae40e1f Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 13 Nov 2009 08:37:45 +0100 Subject: Generalize crawl_view_buffer to also handle the tile buffers. Also make view.cc use crawl_view_geometry.tbuf for tiles drawing. --- crawl-ref/source/viewgeom.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'crawl-ref/source/viewgeom.h') diff --git a/crawl-ref/source/viewgeom.h b/crawl-ref/source/viewgeom.h index 6913849679..72e68ce3ec 100644 --- a/crawl-ref/source/viewgeom.h +++ b/crawl-ref/source/viewgeom.h @@ -1,19 +1,29 @@ #ifndef VIEWGEOM_H #define VIEWGEOM_H +template class crawl_view_buffer { public: - crawl_view_buffer(); - ~crawl_view_buffer(); - void size(const coord_def &size); - operator screen_buffer_t * () { return (buffer); } + crawl_view_buffer() : buffer(NULL) {} + ~crawl_view_buffer() { delete [] buffer; } + + void size(const coord_def &sz) + { + delete [] buffer; + buffer = new T[sz.x * sz.y * 2]; + } + + operator T * () { return (buffer); } - void draw(); private: - screen_buffer_t *buffer; + T *buffer; }; +#ifdef USE_TILE +typedef unsigned int tile_buffer_t; +#endif + struct crawl_view_geometry { public: @@ -28,7 +38,12 @@ public: coord_def mlistp; // Left-top pos of the monster list. coord_def mlistsz; // Size of the monster list. - crawl_view_buffer vbuf; // Buffer for drawing the main game map. + crawl_view_buffer vbuf; + // Buffer for drawing the main game map. +#ifdef USE_TILE + crawl_view_buffer tbuf; + // Tiles buffer. +#endif coord_def vgrdc; // What grid pos is at the centre of the view // usually you.pos(). -- cgit v1.2.3-54-g00ecf