SWE
/import/home/rettenbs/src/SWE/src/opengl/vbo.h
Go to the documentation of this file.
00001 
00027 #ifndef VBO_H
00028 #define VBO_H
00029 
00030 #include "tools/Logger.hh"
00031 
00032 #include <SDL/SDL_opengl.h>
00033 
00034 class VBO
00035 {
00036 private:
00038         GLuint name;
00039 
00040 public:
00041         VBO()
00042                 : name(0)
00043         {}
00044 
00048         void init();
00049 
00053         GLuint getName()
00054         {
00055                 return name;
00056         }
00057 
00058         void setBufferData(GLsizei size, const void* data,
00059                         GLenum target = GL_ARRAY_BUFFER,
00060                         GLenum usage = GL_STATIC_DRAW)
00061         {
00062                 glBindBuffer(target, name);
00063                 glBufferData(target, size, data, usage);
00064                 glBindBuffer(target, 0);
00065         }
00066 
00067         void bindBuffer(GLenum target = GL_ARRAY_BUFFER)
00068         {
00069                 glBindBuffer(target, name);
00070         }
00071 
00075         void finialize()
00076         {
00077                 if (name) {
00078                         glDeleteBuffers(1, &name);
00079                         name = 0;
00080                 }
00081         }
00082 
00083 private:
00084         // VBO Extension Function Pointers
00085         static PFNGLGENBUFFERSARBPROC glGenBuffers;                                     // VBO Name Generation Procedure
00086         static PFNGLBINDBUFFERARBPROC glBindBuffer;                                     // VBO Bind Procedure
00087         static PFNGLBUFFERDATAARBPROC glBufferData;                                     // VBO Data Loading Procedure
00088         static PFNGLDELETEBUFFERSARBPROC glDeleteBuffers;                       // VBO Deletion Procedure
00089 };
00090 
00091 #endif // VBO_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends