X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmisc.h;h=11cb3a60fdc24f9d94e713f89f17cdd9bd351ca6;hb=c6c4fc39952e372eba1f44f2bc504428140f3d0e;hp=e9ed91bfa672b300214a69afe06c680b12993bae;hpb=efe80f5a696b4a3be2378dc6d635c89676afa12d;p=libs%2Fgl.git diff --git a/source/misc.h b/source/misc.h index e9ed91bf..11cb3a60 100644 --- a/source/misc.h +++ b/source/misc.h @@ -17,9 +17,37 @@ void enable(GLenum); void disable(GLenum); void set(GLenum, bool); +///Deprecated (can't properly pass an array through a reference) void get(GLenum, int &); + +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