]> git.tdb.fi Git - libs/gl.git/blobdiff - source/misc.h
Generalize VertexBuffer into Buffer with support for other types as well
[libs/gl.git] / source / misc.h
index 49c6cf5bd66a3e7728581142858c6726950226d5..7aa8aaf9e7fb6d41c3d4acc893b464d581675b51 100644 (file)
@@ -1,13 +1,50 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
 #ifndef MSP_GL_MISC_H_
 #define MSP_GL_MISC_H_
 
-#include <GL/gl.h>
+#include "gl.h"
 
 namespace Msp {
 namespace GL {
 
+void enable(GLenum);
+void disable(GLenum);
 void set(GLenum, bool);
 
+void get(GLenum, int &);
+int get_i(GLenum);
+
+class Bind
+{
+private:
+       struct Base
+       {
+               virtual ~Base() { }
+       };
+
+       template<typename T>
+       struct Binder: Base
+       {
+               const T &obj;
+
+               Binder(const T &o): obj(o) { obj.bind(); }
+               ~Binder() { obj.unbind(); }
+       };
+
+       Base *binder;
+
+public:
+       template<typename T>
+       Bind(const T &o): binder(new Binder<T>(o)) { }
+       ~Bind() { delete binder; }
+};
+
 } // namespace GL
 } // namespace Msp