| 1 | #ifndef __GL_OBJECT_H__ |
| 2 | #define __GL_OBJECT_H__ |
| 3 | |
| 4 | #include <GL/gl.h> |
| 5 | |
| 6 | class GLObject |
| 7 | { |
| 8 | public: |
| 9 | GLObject(void) |
| 10 | { |
| 11 | this->objectID = 0; |
| 12 | } |
| 13 | |
| 14 | virtual ~GLObject(void) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | GLuint ObjectID(void) const |
| 19 | { |
| 20 | return this->objectID; |
| 21 | } |
| 22 | |
| 23 | bool ValidObject(void) const |
| 24 | { |
| 25 | return (this->objectID != 0); |
| 26 | } |
| 27 | |
| 28 | virtual void Gen(void) = 0; |
| 29 | virtual void Del(void) = 0; |
| 30 | |
| 31 | protected: |
| 32 | GLuint objectID; |
| 33 | }; |
| 34 | |
| 35 | class Bindable |
| 36 | { |
| 37 | public: |
| 38 | Bindable(void) |
| 39 | { |
| 40 | this->bound = false; |
| 41 | } |
| 42 | |
| 43 | void Bind(void) |
| 44 | { |
| 45 | this->bound = true; |
| 46 | this->DoBind(); |
| 47 | } |
| 48 | |
| 49 | void Unbind(void) |
| 50 | { |
| 51 | this->DoUnbind(); |
| 52 | this->bound = false; |
| 53 | } |
| 54 | |
| 55 | bool IsBound(void) const |
| 56 | { |
| 57 | return this->bound; |
| 58 | } |
| 59 | |
| 60 | protected: |
| 61 | bool bound; |
| 62 | |
| 63 | virtual void DoBind(void) = 0; |
| 64 | virtual void DoUnbind(void) = 0; |
| 65 | }; |
| 66 | |
| 67 | #endif __GL_OBJECT_H__ |