summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/viewgeom.h
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-13 08:37:45 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-13 13:06:23 +0100
commitd393b923b29792def5a4d9878562e398dae40e1f (patch)
treecde07fa544e2d8e7c2c76481e720f79273ee3d3f /crawl-ref/source/viewgeom.h
parent81545efb573b06f41595f812f94f2233857346b5 (diff)
downloadcrawl-ref-d393b923b29792def5a4d9878562e398dae40e1f.tar.gz
crawl-ref-d393b923b29792def5a4d9878562e398dae40e1f.zip
Generalize crawl_view_buffer to also handle the tile buffers.
Also make view.cc use crawl_view_geometry.tbuf for tiles drawing.
Diffstat (limited to 'crawl-ref/source/viewgeom.h')
-rw-r--r--crawl-ref/source/viewgeom.h29
1 files changed, 22 insertions, 7 deletions
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<typename T>
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<screen_buffer_t> vbuf;
+ // Buffer for drawing the main game map.
+#ifdef USE_TILE
+ crawl_view_buffer<tile_buffer_t> tbuf;
+ // Tiles buffer.
+#endif
coord_def vgrdc; // What grid pos is at the centre of the view
// usually you.pos().