]> git.tdb.fi Git - libs/gl.git/blob - source/misc.h
Generalize VertexBuffer into Buffer with support for other types as well
[libs/gl.git] / source / misc.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_MISC_H_
9 #define MSP_GL_MISC_H_
10
11 #include "gl.h"
12
13 namespace Msp {
14 namespace GL {
15
16 void enable(GLenum);
17 void disable(GLenum);
18 void set(GLenum, bool);
19
20 void get(GLenum, int &);
21 int get_i(GLenum);
22
23 class Bind
24 {
25 private:
26         struct Base
27         {
28                 virtual ~Base() { }
29         };
30
31         template<typename T>
32         struct Binder: Base
33         {
34                 const T &obj;
35
36                 Binder(const T &o): obj(o) { obj.bind(); }
37                 ~Binder() { obj.unbind(); }
38         };
39
40         Base *binder;
41
42 public:
43         template<typename T>
44         Bind(const T &o): binder(new Binder<T>(o)) { }
45         ~Bind() { delete binder; }
46 };
47
48 } // namespace GL
49 } // namespace Msp
50
51 #endif