Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Vbo.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/gl/gl.h"
26 #include "cinder/TriMesh.h"
27 
28 #include <vector>
29 #include <utility>
30 
31 namespace cinder { namespace gl {
32 
33 class Vbo {
34  public:
35  Vbo() {}
36  Vbo( GLenum aTarget );
37 
38  void bind();
39  void unbind();
40 
41  void bufferData( size_t size, const void *data, GLenum usage );
42  void bufferSubData( ptrdiff_t offset, size_t size, const void *data );
43 
44  uint8_t* map( GLenum access );
45  void unmap();
46 
47  GLenum getTarget() const { return mObj->mTarget; }
48  GLuint getId() const { return mObj->mId; }
49 
50  protected:
51  struct Obj {
52  Obj( GLenum aTarget );
53  ~Obj();
54 
57  };
58 
59  std::shared_ptr<Obj> mObj;
60 
61  public:
63  typedef std::shared_ptr<Obj> Vbo::*unspecified_bool_type;
65  operator unspecified_bool_type() const { return ( mObj.get() == 0 ) ? 0 : &Vbo::mObj; }
66  void reset() { mObj.reset(); }
68 };
69 
70 class VboMesh;
71 typedef std::shared_ptr<VboMesh> VboMeshRef;
72 
73 class VboMesh {
74  public:
75  enum { NONE, STATIC, DYNAMIC };
77  enum { ATTR_MAX_TEXTURE_UNIT = 3 };
78 
79  struct Layout {
80  Layout() { initAttributes(); }
81 
83  bool isDefaults() const { for( int a = 0; a < ATTR_TOTAL; ++a ) if( mAttributes[a] != NONE ) return false; return true; }
84 
85  bool hasNormals() const { return hasDynamicNormals() || hasStaticNormals(); }
86  bool hasStaticNormals() const { return mAttributes[ATTR_NORMALS] == STATIC; }
87  bool hasDynamicNormals() const { return mAttributes[ATTR_NORMALS] == DYNAMIC; }
90 
91  bool hasColorsRGB() const { return hasDynamicColorsRGB() || hasStaticColorsRGB(); }
96 
97  bool hasColorsRGBA() const { return hasDynamicColorsRGBA() || hasStaticColorsRGBA(); }
102 
103  bool hasTexCoords2d( size_t unit = 0 ) const { return hasDynamicTexCoords2d( unit ) || hasStaticTexCoords2d( unit ); }
104  bool hasStaticTexCoords2d( size_t unit = 0 ) const { return mAttributes[ATTR_TEXCOORDS2D_0 + unit] == STATIC; }
105  bool hasDynamicTexCoords2d( size_t unit = 0 ) const { return mAttributes[ATTR_TEXCOORDS2D_0 + unit] == DYNAMIC; }
109  bool hasStaticTexCoords() const;
111  bool hasDynamicTexCoords() const;
113  bool hasTexCoords( size_t unit ) const { return ( mAttributes[ATTR_TEXCOORDS2D_0 + unit] != NONE ) || ( mAttributes[ATTR_TEXCOORDS3D_0 + unit] != NONE ); }
114 
115  bool hasTexCoords3d( size_t unit = 0 ) const { return hasDynamicTexCoords3d( unit ) || hasStaticTexCoords3d( unit ); }
116  bool hasStaticTexCoords3d( size_t unit = 0 ) const { return mAttributes[ATTR_TEXCOORDS3D_0 + unit] == STATIC; }
117  bool hasDynamicTexCoords3d( size_t unit = 0 ) const { return mAttributes[ATTR_TEXCOORDS3D_0 + unit] == DYNAMIC; }
120 
121  bool hasIndices() const { return hasStaticIndices() || hasDynamicIndices(); }
122  bool hasStaticIndices() const { return mAttributes[ATTR_INDICES] == STATIC; }
123  bool hasDynamicIndices() const { return mAttributes[ATTR_INDICES] == DYNAMIC; }
126 
127  bool hasPositions() const { return hasStaticPositions() || hasDynamicPositions(); }
132 
137  void addDynamicCustomFloat() { mCustomDynamic.push_back( std::make_pair( CUSTOM_ATTR_FLOAT, 0 ) ); }
138  void addDynamicCustomVec2f() { mCustomDynamic.push_back( std::make_pair( CUSTOM_ATTR_FLOAT2, 0 ) ); }
139  void addDynamicCustomVec3f() { mCustomDynamic.push_back( std::make_pair( CUSTOM_ATTR_FLOAT3, 0 ) ); }
140  void addDynamicCustomVec4f() { mCustomDynamic.push_back( std::make_pair( CUSTOM_ATTR_FLOAT4, 0 ) ); }
141 
143  std::vector<std::pair<CustomAttr,size_t> > mCustomDynamic, mCustomStatic; // pair of <types,offset>
144 
145  private:
146  void initAttributes() { for( int a = 0; a < ATTR_TOTAL; ++a ) mAttributes[a] = NONE; }
147  };
148 
150 
151  protected:
152  struct Obj {
154 
163  std::vector<GLint> mCustomStaticLocations;
164  std::vector<GLint> mCustomDynamicLocations;
165  };
166 
167  public:
168  class VertexIter;
169 
170  VboMesh() {}
171  explicit VboMesh( const TriMesh &triMesh, Layout layout = Layout() );
172  explicit VboMesh( const TriMesh2d &triMesh, Layout layout = Layout() );
173  /*** Creates a VboMesh with \a numVertices vertices and \a numIndices indices. Dynamic data is stored interleaved and static data is planar. **/
174  VboMesh( size_t numVertices, size_t numIndices, Layout layout, GLenum primitiveType );
175  /*** Creates a VboMesh with \a numVertices vertices and \a numIndices indices. Accepts pointers to preexisting buffers, which may be NULL to request allocation **/
176  VboMesh( size_t numVertices, size_t numIndices, Layout layout, GLenum primitiveType, Vbo *indexBuffer, Vbo *staticBuffer, Vbo *dynamicBuffer );
177 
178  static VboMeshRef create( const TriMesh &triMesh, Layout layout = Layout() ) { return std::shared_ptr<VboMesh>( new VboMesh( triMesh, layout ) ); }
179  static VboMeshRef create( const TriMesh2d &triMesh, Layout layout = Layout() ) { return std::shared_ptr<VboMesh>( new VboMesh( triMesh, layout ) ); }
180  static VboMeshRef create( size_t numVertices, size_t numIndices, Layout layout, GLenum primitiveType ) { return std::shared_ptr<VboMesh>( new VboMesh( numVertices, numIndices, layout, primitiveType ) ); }
181  static VboMeshRef create( size_t numVertices, size_t numIndices, Layout layout, GLenum primitiveType, Vbo *indexBuffer, Vbo *staticBuffer, Vbo *dynamicBuffer )
182  { return std::shared_ptr<VboMesh>( new VboMesh( numVertices, numIndices, layout, primitiveType, indexBuffer, staticBuffer, dynamicBuffer ) ); }
183 
184 
185  size_t getNumIndices() const { return mObj->mNumIndices; }
186  size_t getNumVertices() const { return mObj->mNumVertices; }
187  GLenum getPrimitiveType() const { return mObj->mPrimitiveType; }
188 
189  const Layout& getLayout() const { return mObj->mLayout; }
190 
191  void bindIndexBuffer() const;
192  void enableClientStates() const;
193  void disableClientStates() const;
194  void bindAllData() const;
195  static void unbindBuffers();
196 
197  void bufferIndices( const std::vector<uint32_t> &indices );
198  void bufferPositions( const std::vector<Vec3f> &positions );
199  void bufferPositions( const Vec3f *positions, size_t count );
200  void bufferNormals( const std::vector<Vec3f> &normals );
201  void bufferTexCoords2d( size_t unit, const std::vector<Vec2f> &texCoords );
202  void bufferTexCoords3d( size_t unit, const std::vector<Vec3f> &texCoords );
203  void bufferColorsRGB( const std::vector<Color> &colors );
204  void bufferColorsRGBA( const std::vector<ColorA> &colors );
205  class VertexIter mapVertexBuffer();
206 
207  Vbo& getIndexVbo() const { return mObj->mBuffers[INDEX_BUFFER]; }
208  Vbo& getStaticVbo() const { return mObj->mBuffers[STATIC_BUFFER]; }
209  Vbo& getDynamicVbo() const { return mObj->mBuffers[DYNAMIC_BUFFER]; }
210 
211  void setCustomStaticLocation( size_t internalIndex, GLuint location ) { mObj->mCustomStaticLocations[internalIndex] = location; }
212  void setCustomDynamicLocation( size_t internalIndex, GLuint location ) { mObj->mCustomDynamicLocations[internalIndex] = location; }
213 
214  size_t getTexCoordOffset( size_t unit ) const { return mObj->mTexCoordOffset[unit]; }
215  void setTexCoordOffset( size_t unit, size_t aTexCoordOffset ) { mObj->mTexCoordOffset[unit] = aTexCoordOffset; }
216 
218  typedef std::shared_ptr<Obj> VboMesh::*unspecified_bool_type;
220  operator unspecified_bool_type() const { return ( mObj.get() == 0 ) ? 0 : &VboMesh::mObj; }
221  void reset() { mObj.reset(); }
223 
224  class VertexIter {
225  public:
226  VertexIter( const VboMesh &mesh );
227 
228  void setPosition( const Vec3f &v ) { *(reinterpret_cast<Vec3f*>( &mPtr[mPositionOffset] )) = v; }
229  void setPosition( float x, float y, float z ) { *(reinterpret_cast<Vec3f*>( &mPtr[mPositionOffset] )) = Vec3f( x, y, z ); }
230  void setNormal( const Vec3f &n ) { *(reinterpret_cast<Vec3f*>( &mPtr[mNormalOffset] )) = n; }
231  void setColorRGB( const Color &n ) { *(reinterpret_cast<Color*>( &mPtr[mColorRGBOffset] )) = n; }
232  void setColorRGBA( const ColorA &n ) { *(reinterpret_cast<ColorA*>( &mPtr[mColorRGBAOffset] )) = n; }
233  void setTexCoord2d0( const Vec2f &t ) { *(reinterpret_cast<Vec2f*>( &mPtr[mTexCoordOffset[0]] )) = t; }
234  void setTexCoord3d0( const Vec3f &t ) { *(reinterpret_cast<Vec3f*>( &mPtr[mTexCoordOffset[0]] )) = t; }
235  void setTexCoord2d1( const Vec2f &t ) { *(reinterpret_cast<Vec2f*>( &mPtr[mTexCoordOffset[1]] )) = t; }
236  void setTexCoord3d1( const Vec3f &t ) { *(reinterpret_cast<Vec3f*>( &mPtr[mTexCoordOffset[1]] )) = t; }
237  void setTexCoord2d2( const Vec2f &t ) { *(reinterpret_cast<Vec2f*>( &mPtr[mTexCoordOffset[2]] )) = t; }
238  void setTexCoord3d2( const Vec3f &t ) { *(reinterpret_cast<Vec3f*>( &mPtr[mTexCoordOffset[2]] )) = t; }
239  void setCustomFloat( size_t index, float v ) { *(reinterpret_cast<float*>( &mPtr[mObj->mCustomOffsets[index]] )) = v; }
240  void setCustomVec2f( size_t index, const Vec2f &v ) { *(reinterpret_cast<Vec2f*>( &mPtr[mObj->mCustomOffsets[index]] )) = v; }
241  void setCustomVec3f( size_t index, const Vec3f &v ) { *(reinterpret_cast<Vec3f*>( &mPtr[mObj->mCustomOffsets[index]] )) = v; }
242  void setCustomVec4f( size_t index, const Vec4f &v ) { *(reinterpret_cast<Vec4f*>( &mPtr[mObj->mCustomOffsets[index]] )) = v; }
243 
244  void operator++() { mPtr += mStride; }
245  bool isDone() const { return mPtr >= mDataEnd; }
246 
248  size_t getIndex() const { return ( mPtr - mData ) / mStride; }
250  size_t getStride() const { return mStride; }
252  void* getPointer() const { return reinterpret_cast<void*>( mPtr ); }
254  Vec3f* getPositionPointer() const { return reinterpret_cast<Vec3f*>( &mPtr[mPositionOffset] ); }
255 
256 // VertexIter( const VertexIter &other ) { set( other ); }
257 // VertexIter& operator=( const VertexIter &other ) { set( other ); return *this; }
258 
259  protected:
260  void set( const VertexIter &other );
261 
262  struct Obj {
263  public:
264  Obj( const VboMesh &mesh );
265  ~Obj();
266 
267  uint8_t *mData, *mDataEnd;
268  std::vector<size_t> mCustomOffsets;
270  };
271 
272  std::shared_ptr<Obj> mObj;
273  uint8_t *mPtr;
274  uint8_t *mData, *mDataEnd; // we cache these from the Obj to reduce dereferencing
278  uint8_t mStride;
279  };
280 
281  protected:
282  void initializeBuffers( bool staticDataPlanar );
283 
284  std::shared_ptr<Obj> mObj;
285 };
286 
287 class VboExc : public std::exception {
288  public:
289  virtual const char* what() const throw() { return "OpenGL Vbo exception"; }
290 };
291 
292 class VboInvalidTargetExc : public VboExc {
293  public:
294  virtual const char* what() const throw() { return "OpenGL Vbo exception: Invalid Target"; }
295 };
296 
297 class VboFailedMapExc : public VboExc {
298  public:
299  virtual const char* what() const throw() { return "OpenGL Vbo exception: Map failure"; }
300 };
301 
302 class VboFailedUnmapExc : public VboExc {
303  public:
304  virtual const char* what() const throw() { return "OpenGL Vbo exception: Unmap failure"; }
305 };
306 
307 } } // namespace cinder::gl
void setTexCoord3d0(const Vec3f &t)
Definition: Vbo.h:234
size_t mColorRGBAOffset
Definition: Vbo.h:276
void bufferPositions(const std::vector< Vec3f > &positions)
Definition: Vbo.cpp:582
Vbo()
Definition: Vbo.h:35
size_t getStride() const
Definition: Vbo.h:250
virtual const char * what() const
Definition: Vbo.h:304
GLenum GLint GLint y
Definition: GLee.h:987
void setStaticPositions()
Definition: Vbo.h:130
virtual const char * what() const
Definition: Vbo.h:299
std::shared_ptr< Obj > mObj
Definition: Vbo.h:272
CustomAttr
Definition: Vbo.h:133
void setNormal(const Vec3f &n)
Definition: Vbo.h:230
void operator++()
Definition: Vbo.h:244
GLuint getId() const
Definition: Vbo.h:48
void addDynamicCustomVec3f()
Definition: Vbo.h:139
void setStaticTexCoords3d(size_t unit=0)
Definition: Vbo.h:118
void setColorRGB(const Color &n)
Definition: Vbo.h:231
void setDynamicTexCoords3d(size_t unit=0)
Definition: Vbo.h:119
void setDynamicColorsRGBA()
Definition: Vbo.h:101
void setCustomDynamicLocation(size_t internalIndex, GLuint location)
Definition: Vbo.h:212
virtual const char * what() const
Definition: Vbo.h:294
bool hasStaticTexCoords2d(size_t unit=0) const
Definition: Vbo.h:104
size_t getIndex() const
Definition: Vbo.h:248
void setDynamicIndices()
Definition: Vbo.h:125
Vbo & getStaticVbo() const
Definition: Vbo.h:208
uint8_t * mDataEnd
Definition: Vbo.h:267
void reset()
Emulates shared_ptr-like behavior.
Definition: Vbo.h:221
Definition: Vbo.h:75
void setStaticColorsRGBA()
Definition: Vbo.h:100
uint8_t * mPtr
Definition: Vbo.h:273
size_t mStaticStride
Definition: Vbo.h:160
static void unbindBuffers()
Definition: Vbo.cpp:571
size_t getNumIndices() const
Definition: Vbo.h:185
std::shared_ptr< Obj > mObj
Definition: Vbo.h:59
virtual const char * what() const
Definition: Vbo.h:289
uint8_t * map(GLenum access)
Definition: Vbo.cpp:73
Layout mLayout
Definition: Vbo.h:162
size_t mNumVertices
Definition: Vbo.h:153
GLuint index
Definition: GLee.h:2259
GLuint mId
Definition: Vbo.h:56
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:1011
std::shared_ptr< VboMesh > VboMeshRef
Definition: gl.h:65
void bufferNormals(const std::vector< Vec3f > &normals)
Definition: Vbo.cpp:606
static GLenum sCustomAttrTypes[TOTAL_CUSTOM_ATTR_TYPES]
Definition: Vbo.h:136
bool hasColorsRGBA() const
Definition: Vbo.h:97
VertexIter(const VboMesh &mesh)
Definition: Vbo.cpp:721
~Obj()
Definition: Vbo.cpp:41
uint8_t * mData
Definition: Vbo.h:274
uint8_t * mDataEnd
Definition: Vbo.h:274
bool isDone() const
Definition: Vbo.h:245
void setDynamicNormals()
Definition: Vbo.h:89
void bufferColorsRGBA(const std::vector< ColorA > &colors)
Definition: Vbo.cpp:682
bool hasTexCoords2d(size_t unit=0) const
Definition: Vbo.h:103
bool hasDynamicTexCoords3d(size_t unit=0) const
Definition: Vbo.h:117
static VboMeshRef create(size_t numVertices, size_t numIndices, Layout layout, GLenum primitiveType)
Definition: Vbo.h:180
size_t mPositionOffset
Definition: Vbo.h:275
bool hasStaticColorsRGBA() const
Definition: Vbo.h:98
Definition: Vbo.h:292
void setCustomVec2f(size_t index, const Vec2f &v)
Definition: Vbo.h:240
size_t mColorRGBOffset
Definition: Vbo.h:158
void addDynamicCustomVec4f()
Definition: Vbo.h:140
size_t mNumIndices
Definition: Vbo.h:153
size_t mNormalOffset
Definition: Vbo.h:157
std::vector< std::pair< CustomAttr, size_t > > mCustomDynamic
Definition: Vbo.h:143
Definition: Vbo.h:79
void bind()
Definition: Vbo.cpp:51
void addDynamicCustomVec2f()
Definition: Vbo.h:138
bool hasIndices() const
Definition: Vbo.h:121
void setStaticIndices()
Definition: Vbo.h:124
unsigned int GLuint
Definition: gldx.h:55
void * getPointer() const
Definition: Vbo.h:252
Vec3< float > Vec3f
Definition: Vector.h:1317
bool hasDynamicIndices() const
Definition: Vbo.h:123
Vbo mBuffers[TOTAL_BUFFERS]
Definition: Vbo.h:155
uint8_t * mData
Definition: Vbo.h:267
bool hasStaticIndices() const
Definition: Vbo.h:122
std::shared_ptr< Obj > mObj
Definition: Vbo.h:284
size_t mTexCoordOffset[ATTR_MAX_TEXTURE_UNIT+1]
Definition: Vbo.h:159
void setDynamicPositions()
Definition: Vbo.h:131
Vbo & getDynamicVbo() const
Definition: Vbo.h:209
Obj(const VboMesh &mesh)
Definition: Vbo.cpp:739
Definition: Vbo.h:73
~Obj()
Definition: Vbo.cpp:751
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: GLee.h:963
void setDynamicColorsRGB()
Definition: Vbo.h:95
bool hasStaticColorsRGB() const
Definition: Vbo.h:92
GLenum mPrimitiveType
Definition: Vbo.h:161
void addDynamicCustomFloat()
Definition: Vbo.h:137
size_t mNormalOffset
Definition: Vbo.h:275
Definition: Vbo.h:75
GLintptr GLsizeiptr GLbitfield access
Definition: GLee.h:5533
GLenum mTarget
Definition: Vbo.h:55
void bufferIndices(const std::vector< uint32_t > &indices)
Definition: Vbo.cpp:577
GLenum GLint x
Definition: GLee.h:987
Definition: Vbo.h:297
GLintptr offset
Definition: GLee.h:2095
GLuint GLuint GLsizei count
Definition: GLee.h:963
GLenum GLsizei n
Definition: GLee.h:5780
void setTexCoord3d2(const Vec3f &t)
Definition: Vbo.h:238
uint8_t mStride
Definition: Vbo.h:278
bool hasStaticNormals() const
Definition: Vbo.h:86
VboMesh()
Definition: Vbo.h:170
Layout()
Definition: Vbo.h:80
int mAttributes[ATTR_TOTAL]
Definition: Vbo.h:142
GLenum getPrimitiveType() const
Definition: Vbo.h:187
size_t mPositionOffset
Definition: Vbo.h:156
void setCustomFloat(size_t index, float v)
Definition: Vbo.h:239
bool hasPositions() const
Definition: Vbo.h:127
static VboMeshRef create(const TriMesh &triMesh, Layout layout=Layout())
Definition: Vbo.h:178
bool hasDynamicTexCoords2d(size_t unit=0) const
Definition: Vbo.h:105
GLenum getTarget() const
Definition: Vbo.h:47
bool hasDynamicTexCoords() const
Definition: Vbo.cpp:97
static int sCustomAttrSizes[TOTAL_CUSTOM_ATTR_TYPES]
Definition: Vbo.h:134
const GLdouble * v
Definition: GLee.h:1384
bool hasStaticTexCoords3d(size_t unit=0) const
Definition: Vbo.h:116
void setColorRGBA(const ColorA &n)
Definition: Vbo.h:232
void setStaticColorsRGB()
Definition: Vbo.h:94
bool hasDynamicColorsRGB() const
Definition: Vbo.h:93
Definition: Vbo.h:51
GLdouble GLdouble z
Definition: GLee.h:1911
std::vector< size_t > mCustomOffsets
Definition: Vbo.h:268
bool hasTexCoords3d(size_t unit=0) const
Definition: Vbo.h:115
void setTexCoord3d1(const Vec3f &t)
Definition: Vbo.h:236
void initializeBuffers(bool staticDataPlanar)
Definition: Vbo.cpp:285
bool hasNormals() const
Definition: Vbo.h:85
static VboMeshRef create(size_t numVertices, size_t numIndices, Layout layout, GLenum primitiveType, Vbo *indexBuffer, Vbo *staticBuffer, Vbo *dynamicBuffer)
Definition: Vbo.h:181
bool hasDynamicColorsRGBA() const
Definition: Vbo.h:99
std::vector< GLint > mCustomDynamicLocations
Definition: Vbo.h:164
bool hasDynamicNormals() const
Definition: Vbo.h:87
bool hasStaticTexCoords() const
Definition: Vbo.cpp:88
void reset()
Emulates shared_ptr-like behavior.
Definition: Vbo.h:66
void setPosition(float x, float y, float z)
Definition: Vbo.h:229
Vbo & getIndexVbo() const
Definition: Vbo.h:207
void setCustomVec4f(size_t index, const Vec4f &v)
Definition: Vbo.h:242
void bindAllData() const
Definition: Vbo.cpp:511
void bindIndexBuffer() const
Definition: Vbo.cpp:566
void setTexCoordOffset(size_t unit, size_t aTexCoordOffset)
Definition: Vbo.h:215
std::shared_ptr< Obj > Vbo::* unspecified_bool_type
Emulates shared_ptr-like behavior.
Definition: Vbo.h:64
bool hasDynamicPositions() const
Definition: Vbo.h:129
Obj(GLenum aTarget)
Definition: Vbo.cpp:35
std::vector< std::pair< CustomAttr, size_t > > mCustomStatic
Definition: Vbo.h:143
void unbind()
Definition: Vbo.cpp:56
GLboolean GLboolean GLboolean GLboolean a
Definition: GLee.h:2964
size_t mTexCoordOffset[ATTR_MAX_TEXTURE_UNIT+1]
Definition: Vbo.h:277
void bufferColorsRGB(const std::vector< Color > &colors)
Definition: Vbo.cpp:663
Definition: Vbo.h:33
void setTexCoord2d1(const Vec2f &t)
Definition: Vbo.h:235
std::shared_ptr< Obj > VboMesh::* unspecified_bool_type
Emulates shared_ptr-like behavior.
Definition: Vbo.h:219
size_t getTexCoordOffset(size_t unit) const
Definition: Vbo.h:214
int GLint
Definition: gldx.h:51
GLsizeiptr const GLvoid GLenum usage
Definition: GLee.h:2089
std::vector< GLint > mCustomStaticLocations
Definition: Vbo.h:163
void enableClientStates() const
Definition: Vbo.cpp:451
bool hasColorsRGB() const
Definition: Vbo.h:91
Definition: Vbo.h:287
const Layout & getLayout() const
Definition: Vbo.h:189
void setDynamicTexCoords2d(size_t unit=0)
Definition: Vbo.h:107
void set(const VertexIter &other)
Definition: Vbo.cpp:706
Vec3f * getPositionPointer() const
Definition: Vbo.h:254
void setTexCoord2d2(const Vec2f &t)
Definition: Vbo.h:237
Definition: Vbo.h:152
bool hasStaticPositions() const
Definition: Vbo.h:128
void bufferTexCoords3d(size_t unit, const std::vector< Vec3f > &texCoords)
Definition: Vbo.cpp:644
bool hasTexCoords(size_t unit) const
Definition: Vbo.h:113
Definition: Vbo.h:302
static VboMeshRef create(const TriMesh2d &triMesh, Layout layout=Layout())
Definition: Vbo.h:179
void setStaticNormals()
Definition: Vbo.h:88
void setCustomVec3f(size_t index, const Vec3f &v)
Definition: Vbo.h:241
size_t getNumVertices() const
Definition: Vbo.h:186
size_t mDynamicStride
Definition: Vbo.h:160
GLint location
Definition: GLee.h:2373
void bufferSubData(ptrdiff_t offset, size_t size, const void *data)
Definition: Vbo.cpp:67
bool isDefaults() const
Definition: Vbo.h:83
GLdouble GLdouble t
Definition: GLee.h:1426
Definition: TriMesh.h:167
void disableClientStates() const
Definition: Vbo.cpp:486
static GLint sCustomAttrNumComponents[TOTAL_CUSTOM_ATTR_TYPES]
Definition: Vbo.h:135
void setStaticTexCoords2d(size_t unit=0)
Definition: Vbo.h:106
void bufferData(size_t size, const void *data, GLenum usage)
Definition: Vbo.cpp:61
GLsizeiptr size
Definition: GLee.h:2089
unsigned int GLenum
Definition: gldx.h:46
size_t mColorRGBAOffset
Definition: Vbo.h:158
Definition: TriMesh.h:66
class VertexIter mapVertexBuffer()
Definition: Vbo.cpp:701
Definition: Vbo.h:224
Vbo mVbo
Definition: Vbo.h:269
Definition: Vbo.h:75
void setCustomStaticLocation(size_t internalIndex, GLuint location)
Definition: Vbo.h:211
void setTexCoord2d0(const Vec2f &t)
Definition: Vbo.h:233
void setPosition(const Vec3f &v)
Definition: Vbo.h:228
void bufferTexCoords2d(size_t unit, const std::vector< Vec2f > &texCoords)
Definition: Vbo.cpp:625
void unmap()
Definition: Vbo.cpp:79
size_t mColorRGBOffset
Definition: Vbo.h:276