summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/glwrapper.cc
diff options
context:
space:
mode:
authorIxtli <cg@325i.org>2010-03-12 06:56:44 +0900
committerEnne Walker <ennewalker@users.sourceforge.net>2010-04-24 10:19:44 -0400
commit96377c8e38ae1d751bc7cc2ff82fcfd36faf5e05 (patch)
tree1c64996c73d249fe757cff2a2c358d6246edb8b7 /crawl-ref/source/glwrapper.cc
parentdc2af3903aaf06dcb886af528decf017a3e0c1ce (diff)
downloadcrawl-ref-96377c8e38ae1d751bc7cc2ff82fcfd36faf5e05.tar.gz
crawl-ref-96377c8e38ae1d751bc7cc2ff82fcfd36faf5e05.zip
Made glwrapper use proper dynamic dispatch for modularity.
Diffstat (limited to 'crawl-ref/source/glwrapper.cc')
-rw-r--r--crawl-ref/source/glwrapper.cc83
1 files changed, 83 insertions, 0 deletions
diff --git a/crawl-ref/source/glwrapper.cc b/crawl-ref/source/glwrapper.cc
new file mode 100644
index 0000000000..f65cf5040e
--- /dev/null
+++ b/crawl-ref/source/glwrapper.cc
@@ -0,0 +1,83 @@
+#ifdef USE_TILE
+#include "glwrapper.h"
+
+#ifdef USE_GL
+#include "glwrapper-ogl.h"
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// GLPrimitive
+GLPrimitive::GLPrimitive(long unsigned int sz, size_t ct, unsigned int vs,
+ const void* v_pt, const void *c_pt, const void *t_pt) :
+ mode(GLW_QUADS),
+ vert_size(vs),
+ size(sz),
+ count(ct),
+ vert_pointer(v_pt),
+ colour_pointer(c_pt),
+ texture_pointer(t_pt),
+ pretranslate(NULL),
+ prescale(NULL)
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// GLState
+
+// Note: these defaults should match the OpenGL defaults
+GLState::GLState() :
+ array_vertex(false),
+ array_texcoord(false),
+ array_colour(false),
+ blend(false),
+ texture(false),
+ depthtest(false),
+ alphatest(false),
+ alpharef(0)
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// GLStateManager
+
+GLStateManager *glmanager = NULL;
+
+void GLStateManager::init()
+{
+ if (glmanager)
+ return;
+
+#ifdef USE_GL
+ glmanager = (GLStateManager *) new OGLStateManager();
+#endif
+}
+
+void GLStateManager::shutdown()
+{
+ if (!glmanager)
+ return;
+
+ delete glmanager;
+}
+
+#ifdef DEBUG
+bool GLStateManager::_valid(int num_verts, drawing_modes mode)
+{
+ switch( mode )
+ {
+ case GLW_QUADS:
+ case GLW_TRIANGLE_STRIP:
+ return (num_verts % 4 == 0);
+ case GLW_TRIANGLES:
+ return (num_verts % 3 == 0);
+ case GLW_LINES:
+ return (num_verts % 2 == 0);
+ case GLW_POINTS:
+ return (true);
+ default:
+ return (false);
+ }
+}
+#endif // DEBUG
+
+#endif // USE_TILE