Eulerian Smoke Simulation on the GPU
include/VertexArrayObject.h
Go to the documentation of this file.
00001 #ifndef __VERTEX_ARRAY_OBJECT_H__
00002 #define __VERTEX_ARRAY_OBJECT_H__
00003 
00004 //---------------------------------------------------------------------
00007 //---------------------------------------------------------------------
00008 
00009 #include <map>
00010 #include "GLUtil.h"
00011 
00020 class VertexAttribute
00021 {
00022 public :
00024     int  m_attribIndex;
00026     GLuint m_bufferHandle;
00027 
00031   inline VertexAttribute(
00032                           int    _attribIndex,
00033                           GLuint _bufferHandle
00034                         ) :
00035                         m_attribIndex(_attribIndex),
00036                         m_bufferHandle(_bufferHandle){;}
00037 };
00038 
00046 class VertexArrayObject
00047 {
00048 public:
00050   VertexArrayObject();
00051 
00053   ~VertexArrayObject();
00054 
00056   inline GLuint getHandle() const {return m_handle;}
00057 
00059   void bind();
00061   void unbind();
00063   inline bool isBound() const {return m_isBound;}
00065   inline bool isAllocated() const {return m_isAllocated;}
00066 
00079   bool addVertexAttribute(
00080                           const char*   _attribName,
00081                           GLuint        _index,
00082                           GLint         _numComponents,
00083                           GLenum        _dataType,
00084                           GLsizeiptr    _dataSize,
00085                           const GLvoid* _data,
00086                           GLsizei       _byteStride   = 0,
00087                           GLenum        _bufferUsage  = GL_STATIC_DRAW,
00088                           GLenum        _bufferTarget = GL_ARRAY_BUFFER,
00089                           GLboolean     _normalized   = GL_FALSE
00090                          );
00093   bool removeVertexAttribute(
00094                               const char*   _attribName
00095                             );
00096 
00099   int getVertexAttributeIndex(
00100                               const char* _attribName
00101                              );
00104   GLuint getVertexAttributeBufferHandle(
00105                                         const char* _attribName
00106                                        );
00107 
00112   bool draw(
00113             GLenum  _primType,
00114             GLsizei _count,
00115             GLint   _startIndex = 0
00116            );
00117 
00123   bool drawIndexed(
00124                     GLenum        _primType,
00125                     GLsizei       _count,
00126                     GLenum        _indexDataType,
00127                     const GLvoid* _indices
00128                    );
00129 
00137   bool drawIndexedRange(
00138                         GLenum        _primType,
00139                         GLuint        _start,
00140                         GLuint        _end,
00141                         GLsizei       _count,
00142                         GLenum        _indexDataType,
00143                         const GLvoid* _indices
00144                        );
00145 
00146 private:
00148   GLuint m_handle;
00149 
00151   bool m_isBound;
00153   bool m_isAllocated;
00154 
00156   std::map<const char*, VertexAttribute*> m_vertexAttribs;
00158   typedef std::map<const char*, VertexAttribute*>::iterator VertexAttribIter;
00159 };
00160 
00161 #endif // __VERTEX_ARRAY_OBJECT_H__
 All Classes Files Functions Variables