X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmisc.h;h=7aa8aaf9e7fb6d41c3d4acc893b464d581675b51;hb=ac7c744dfb6e87481eea7081b84c5ae2f585ee7b;hp=071875cd43805db5db7f230849d1e2060c2972ca;hpb=bdf2568e247af858c4a1ca8004d97f13fe9b8cb0;p=libs%2Fgl.git diff --git a/source/misc.h b/source/misc.h index 071875cd..7aa8aaf9 100644 --- a/source/misc.h +++ b/source/misc.h @@ -8,7 +8,7 @@ Distributed under the LGPL #ifndef MSP_GL_MISC_H_ #define MSP_GL_MISC_H_ -#include +#include "gl.h" namespace Msp { namespace GL { @@ -17,6 +17,34 @@ 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 + struct Binder: Base + { + const T &obj; + + Binder(const T &o): obj(o) { obj.bind(); } + ~Binder() { obj.unbind(); } + }; + + Base *binder; + +public: + template + Bind(const T &o): binder(new Binder(o)) { } + ~Bind() { delete binder; } +}; + } // namespace GL } // namespace Msp