summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/glwrapper-ogl.h
diff options
context:
space:
mode:
authorIxtli <cg@325i.org>2010-04-26 20:13:41 +0900
committerEnne Walker <enne.walker@gmail.com>2010-05-14 18:18:51 -0400
commit371d8112277cbaff095280c797d8a565ac6fd84c (patch)
treea0470a33ff399888e8b7c93d1e1c99dc0e05a12e /crawl-ref/source/glwrapper-ogl.h
parent2458d5828e0a35e288d7b1c41d7f664a620cab77 (diff)
downloadcrawl-ref-371d8112277cbaff095280c797d8a565ac6fd84c.tar.gz
crawl-ref-371d8112277cbaff095280c797d8a565ac6fd84c.zip
Added GLShapeBuffer. Changed GLState, Manager.
Added convenience methods to GLState. Changed GLStateManager to check current state before using glEnable in case those commands are slow, as they are being called nearly ever draw. (Note: GLShapeBuffer is not currently used.) Signed-off-by: Enne Walker <enne.walker@gmail.com>
Diffstat (limited to 'crawl-ref/source/glwrapper-ogl.h')
-rw-r--r--crawl-ref/source/glwrapper-ogl.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/crawl-ref/source/glwrapper-ogl.h b/crawl-ref/source/glwrapper-ogl.h
index 24398898fb..7ae3774677 100644
--- a/crawl-ref/source/glwrapper-ogl.h
+++ b/crawl-ref/source/glwrapper-ogl.h
@@ -16,6 +16,7 @@ public:
// State Manipulation
virtual void set(const GLState& state);
+ virtual const GLState& get_state() const { return (current_state); }
virtual void pixelstore_unpack_alignment(unsigned int bpp);
virtual void reset_view_for_redraw(float x, float y);
virtual void reset_view_for_resize(coord_def &m_windowsz);
@@ -34,6 +35,40 @@ public:
virtual void bind_texture(unsigned int texture);
virtual void load_texture(unsigned char *pixels, unsigned int width,
unsigned int height, MipMapOptions mip_opt);
+protected:
+ GLState current_state;
+};
+
+class OGLShapeBuffer : public GLShapeBuffer
+{
+public:
+ OGLShapeBuffer(bool texture = false, bool colour = false,
+ drawing_modes prim = GLW_RECTANGLE);
+
+ // Accounting
+ virtual const char *print_statistics() const;
+ virtual unsigned int size() const;
+
+ // Add a rectangle
+ virtual void push(const GLWRect &rect);
+
+ // Draw the buffer
+ virtual void draw(GLW_3VF *pt = NULL, GLW_3VF *ps = NULL, bool flush = false);
+
+ // Manipulate state
+ virtual void clear();
+protected:
+ // Helper methods for pushing specific prim types
+ void push_rect(const GLWRect &rect);
+ void push_line(const GLWRect &rect);
+
+ drawing_modes prim_type;
+ bool texture_verts, colour_verts;
+
+ std::vector<GLW_3VF> position_buffer;
+ std::vector<GLW_2VF> texture_buffer;
+ std::vector<VColour> colour_buffer;
+ std::vector<unsigned short int> ind_buffer; //indicies
};
#endif // USE_GL