root/OpenSceneGraph/trunk/include/osg/PrimitiveSet @ 12912

Revision 12912, 22.3 kB (checked in by robert, 2 years ago)

Added support for using GL_UNPACK_ROW_LENGTH in conjunction with texture's + osg::Image via new RowLength?
parameter in osg::Image. To support this Image::setData(..) now has a new optional rowLength parameter which
defaults to 0, which provides the original behaviour, Image::setRowLength(int) and int Image::getRowLength() are also provided.

With the introduction of RowLength? support in osg::Image it is now possible to create a sub image where
the t size of the image are smaller than the row length, useful for when you have a large image on the CPU
and which to use a small portion of it on the GPU. However, when these sub images are created the data
within the image is no longer contiguous so data access can no longer assume that all the data is in
one block. The new method Image::isDataContiguous() enables the user to check whether the data is contiguous,
and if not one can either access the data row by row using Image::data(column,row,image) accessor, or use the
new Image::DataIterator? for stepping through each block on memory assocatied with the image.

To support the possibility of non contiguous osg::Image usage of image objects has had to be updated to
check DataContiguous? and handle the case or use access via the DataIerator? or by row by row. To achieve
this a relatively large number of files has had to be modified, in particular the texture classes and
image plugins that doing writing.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_PRIMITIVESET
15#define OSG_PRIMITIVESET 1
16
17#include <osg/GL>
18#include <osg/Object>
19#include <osg/buffered_value>
20#include <osg/Vec2>
21#include <osg/Vec3>
22#include <osg/Vec4>
23#include <osg/Vec2d>
24#include <osg/Vec3d>
25#include <osg/Vec4d>
26#include <osg/MixinVector>
27#include <osg/GL2Extensions>
28
29#include <osg/BufferObject>
30
31#include <vector>
32
33namespace osg {
34
35typedef MixinVector<GLsizei> VectorGLsizei;
36typedef MixinVector<GLubyte> VectorGLubyte;
37typedef MixinVector<GLushort> VectorGLushort;
38typedef MixinVector<GLuint> VectorGLuint;
39
40class State;
41
42/** A \c PrimitiveFunctor is used (in conjunction with
43 *  <tt>osg::Drawable::accept (PrimitiveFunctor&)</tt>) to get access to the
44 *  primitives that compose the things drawn by OSG.
45 *  <p>If \c osg::Drawable::accept() is called with a \c PrimitiveFunctor
46 *  parameter, the \c Drawable will "pretend" it is drawing itself, but instead
47 *  of calling real OpenGL functions, it will call <tt>PrimitiveFunctor</tt>'s
48 *  member functions that "mimic" the OpenGL calls.
49 *  <p>Concrete subclasses of \c PrimitiveFunctor must implement these methods
50 *  so that they performs whatever they want.
51 */
52class PrimitiveFunctor
53{
54public:
55
56    virtual ~PrimitiveFunctor() {}
57
58    /** Sets the array of vertices used to describe the primitives. Somehow
59     *  mimics the OpenGL \c glVertexPointer() function.
60     */
61    virtual void setVertexArray(unsigned int count,const Vec2* vertices) = 0;
62
63    /** Sets the array of vertices used to describe the primitives. Somehow
64     *  mimics the OpenGL \c glVertexPointer() function.
65     */
66    virtual void setVertexArray(unsigned int count,const Vec3* vertices) = 0;
67
68    /** Sets the array of vertices used to describe the primitives. Somehow
69     *  mimics the OpenGL \c glVertexPointer() function.
70     */
71    virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0;
72
73    /** Sets the array of vertices used to describe the primitives. Somehow
74     *  mimics the OpenGL \c glVertexPointer() function.
75     */
76    virtual void setVertexArray(unsigned int count,const Vec2d* vertices) = 0;
77
78    /** Sets the array of vertices used to describe the primitives. Somehow
79     *  mimics the OpenGL \c glVertexPointer() function.
80     */
81    virtual void setVertexArray(unsigned int count,const Vec3d* vertices) = 0;
82
83    /** Sets the array of vertices used to describe the primitives. Somehow
84     *  mimics the OpenGL \c glVertexPointer() function.
85     */
86    virtual void setVertexArray(unsigned int count,const Vec4d* vertices) = 0;
87
88    /// Mimics the OpenGL \c glDrawArrays() function.
89    virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
90
91    /// Mimics the OpenGL \c glDrawElements() function.
92    virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0;
93
94    /// Mimics the OpenGL \c glDrawElements() function.
95    virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0;
96
97    /// Mimics the OpenGL \c glDrawElements() function.
98    virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) = 0;
99
100    /// Mimics the OpenGL \c glBegin() function.
101    virtual void begin(GLenum mode) = 0;
102
103    /// Mimics the OpenGL \c glVertex() "family of functions".
104    virtual void vertex(const Vec2& vert) = 0;
105
106    /// Mimics the OpenGL \c glVertex() "family of functions".
107    virtual void vertex(const Vec3& vert) = 0;
108
109    /// Mimics the OpenGL \c glVertex() "family of functions".
110    virtual void vertex(const Vec4& vert) = 0;
111
112    /// Mimics the OpenGL \c glVertex() "family of functions".
113    virtual void vertex(float x,float y) = 0;
114
115    /// Mimics the OpenGL \c glVertex() "family of functions".
116    virtual void vertex(float x,float y,float z) = 0;
117
118    /// Mimics the OpenGL \c glVertex() "family of functions".
119    virtual void vertex(float x,float y,float z,float w) = 0;
120
121    /// Mimics the OpenGL \c glEnd() function.
122    virtual void end() = 0;
123};
124
125class PrimitiveIndexFunctor
126{
127public:
128
129    virtual ~PrimitiveIndexFunctor() {}
130
131    virtual void setVertexArray(unsigned int count,const Vec2* vertices) = 0;
132    virtual void setVertexArray(unsigned int count,const Vec3* vertices) = 0;
133    virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0;
134
135    virtual void setVertexArray(unsigned int count,const Vec2d* vertices) = 0;
136    virtual void setVertexArray(unsigned int count,const Vec3d* vertices) = 0;
137    virtual void setVertexArray(unsigned int count,const Vec4d* vertices) = 0;
138
139    virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
140    virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0;
141    virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0;
142    virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) = 0;
143
144    virtual void begin(GLenum mode) = 0;
145    virtual void vertex(unsigned int pos) = 0;
146    virtual void end() = 0;
147};
148
149class DrawElements;
150
151class OSG_EXPORT PrimitiveSet : public BufferData
152{
153    public:
154   
155        enum Type
156        {
157            PrimitiveType,
158            DrawArraysPrimitiveType,
159            DrawArrayLengthsPrimitiveType,
160            DrawElementsUBytePrimitiveType,
161            DrawElementsUShortPrimitiveType,
162            DrawElementsUIntPrimitiveType
163        };
164
165        enum Mode
166        {
167            POINTS = GL_POINTS,
168            LINES = GL_LINES,
169            LINE_STRIP = GL_LINE_STRIP,
170            LINE_LOOP = GL_LINE_LOOP,
171            TRIANGLES = GL_TRIANGLES,
172            TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
173            TRIANGLE_FAN = GL_TRIANGLE_FAN,
174            QUADS = GL_QUADS,
175            QUAD_STRIP = GL_QUAD_STRIP,
176            POLYGON = GL_POLYGON,
177            LINES_ADJACENCY = GL_LINES_ADJACENCY_EXT,
178            LINE_STRIP_ADJACENCY = GL_LINE_STRIP_ADJACENCY_EXT,
179            TRIANGLES_ADJACENCY = GL_TRIANGLES_ADJACENCY_EXT,
180            TRIANGLE_STRIP_ADJACENCY = GL_TRIANGLE_STRIP_ADJACENCY_EXT,
181            PATCHES = GL_PATCHES
182        };
183
184        PrimitiveSet(Type primType=PrimitiveType,GLenum mode=0, int numInstances=0):
185            _primitiveType(primType),
186            _numInstances(numInstances),
187            _mode(mode) {}
188   
189        PrimitiveSet(const PrimitiveSet& prim,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
190            BufferData(prim,copyop),
191            _primitiveType(prim._primitiveType),
192            _numInstances(prim._numInstances),
193            _mode(prim._mode) {}
194
195        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const PrimitiveSet*>(obj)!=NULL; }
196        virtual const char* libraryName() const { return "osg"; }
197        virtual const char* className() const { return "PrimitiveSet"; }
198       
199        Type                    getType() const { return _primitiveType; }
200
201        virtual osg::PrimitiveSet* asPrimitiveSet() { return this; }
202        virtual const osg::PrimitiveSet* asPrimitiveSet() const { return this; }
203
204        virtual const GLvoid*   getDataPointer() const { return 0; }
205        virtual unsigned int    getTotalDataSize() const { return 0; }
206        virtual bool            supportsBufferObject() const { return false; }
207
208        virtual DrawElements* getDrawElements() { return 0; }
209        virtual const DrawElements* getDrawElements() const { return 0; }
210           
211        void setNumInstances(int n) { _numInstances = n; }
212        int getNumInstances() const { return _numInstances; }
213
214        void setMode(GLenum mode) { _mode = mode; }
215        GLenum getMode() const { return _mode; }
216
217        virtual void draw(State& state, bool useVertexBufferObjects) const = 0;
218       
219        virtual void accept(PrimitiveFunctor& functor) const = 0;
220        virtual void accept(PrimitiveIndexFunctor& functor) const = 0;
221       
222        virtual unsigned int index(unsigned int pos) const = 0;
223        virtual unsigned int getNumIndices() const = 0;
224        virtual void offsetIndices(int offset) = 0;
225
226        virtual unsigned int getNumPrimitives() const;
227
228        virtual void computeRange() const {}
229
230    protected:
231
232        virtual ~PrimitiveSet() {}
233
234        Type            _primitiveType;
235        int             _numInstances;
236        GLenum          _mode;
237};
238
239class OSG_EXPORT DrawArrays : public PrimitiveSet
240{
241    public:
242
243        DrawArrays(GLenum mode=0):
244            PrimitiveSet(DrawArraysPrimitiveType,mode),
245            _first(0),
246            _count(0) {}
247   
248        DrawArrays(GLenum mode, GLint first, GLsizei count, int numInstances=0):
249            PrimitiveSet(DrawArraysPrimitiveType, mode, numInstances),
250            _first(first),
251            _count(count) {}
252
253        DrawArrays(const DrawArrays& da,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
254            PrimitiveSet(da,copyop),
255            _first(da._first),
256            _count(da._count) {}
257
258        virtual Object* cloneType() const { return new DrawArrays(); }
259        virtual Object* clone(const CopyOp& copyop) const { return new DrawArrays(*this,copyop); }       
260        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawArrays*>(obj)!=NULL; }
261        virtual const char* libraryName() const { return "osg"; }
262        virtual const char* className() const { return "DrawArrays"; }
263       
264
265        void set(GLenum mode,GLint first, GLsizei count)
266        {
267            _mode = mode;
268            _first = first;
269            _count = count;
270        }
271
272        void setFirst(GLint first) { _first = first; }
273        GLint getFirst() const { return _first; }
274       
275        void setCount(GLsizei count) { _count = count; }
276        GLsizei getCount() const { return _count; }
277
278        virtual void draw(State& state, bool useVertexBufferObjects) const;
279       
280        virtual void accept(PrimitiveFunctor& functor) const;
281        virtual void accept(PrimitiveIndexFunctor& functor) const;
282       
283        virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(_count); }
284        virtual unsigned int index(unsigned int pos) const { return static_cast<unsigned int>(_first)+pos; }
285        virtual void offsetIndices(int offset) { _first += offset; }
286
287    protected:
288
289        virtual ~DrawArrays() {}
290
291        GLint   _first;
292        GLsizei _count;
293};
294
295class OSG_EXPORT DrawArrayLengths : public PrimitiveSet, public VectorGLsizei
296{
297    public:
298
299        typedef VectorGLsizei vector_type;
300
301        DrawArrayLengths(GLenum mode=0):
302            PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
303            _first(0) {}
304   
305        DrawArrayLengths(const DrawArrayLengths& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
306            PrimitiveSet(dal,copyop),
307            vector_type(dal),
308            _first(dal._first) {}
309
310        DrawArrayLengths(GLenum mode, GLint first, unsigned int no, GLsizei* ptr) :
311            PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
312            vector_type(ptr,ptr+no),
313            _first(first) {}
314
315        DrawArrayLengths(GLenum mode,GLint first, unsigned int no) :
316            PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
317            vector_type(no),
318            _first(first) {}
319
320        DrawArrayLengths(GLenum mode,GLint first) :
321            PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
322            vector_type(),
323            _first(first) {}
324
325
326        virtual Object* cloneType() const { return new DrawArrayLengths(); }
327        virtual Object* clone(const CopyOp& copyop) const { return new DrawArrayLengths(*this,copyop); }       
328        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawArrayLengths*>(obj)!=NULL; }
329        virtual const char* libraryName() const { return "osg"; }
330        virtual const char* className() const { return "DrawArrayLengths"; }
331       
332
333        void setFirst(GLint first) { _first = first; }
334        GLint getFirst() const { return _first; }
335       
336        virtual void draw(State& state, bool useVertexBufferObjects) const;
337       
338        virtual void accept(PrimitiveFunctor& functor) const;
339        virtual void accept(PrimitiveIndexFunctor& functor) const;
340       
341        virtual unsigned int getNumIndices() const;
342        virtual unsigned int index(unsigned int pos) const { return _first+pos; }
343        virtual void offsetIndices(int offset) { _first += offset; }
344
345        virtual unsigned int getNumPrimitives() const;
346
347    protected:
348
349        virtual ~DrawArrayLengths() {}
350
351        GLint   _first;
352};
353
354class DrawElements : public PrimitiveSet
355{
356    public:
357       
358        DrawElements(Type primType=PrimitiveType, GLenum mode=0, int numInstances=0):
359            PrimitiveSet(primType,mode, numInstances) {}
360   
361        DrawElements(const DrawElements& copy,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
362            PrimitiveSet(copy,copyop) {}
363
364
365        virtual DrawElements* getDrawElements() { return this; }
366        virtual const DrawElements* getDrawElements() const { return this; }
367
368        /** Set the ElementBufferObject.*/
369        inline void setElementBufferObject(osg::ElementBufferObject* ebo) { setBufferObject(ebo); }
370
371        /** Get the ElementBufferObject. If no EBO is assigned returns NULL*/
372        inline osg::ElementBufferObject* getElementBufferObject() { return dynamic_cast<osg::ElementBufferObject*>(_bufferObject.get()); }
373
374        /** Get the const ElementBufferObject. If no EBO is assigned returns NULL*/
375        inline const osg::ElementBufferObject* getElementBufferObject() const { return dynamic_cast<const osg::ElementBufferObject*>(_bufferObject.get()); }
376
377        virtual void reserveElements(unsigned int numIndices) = 0;
378        virtual void setElement(unsigned int, unsigned int) = 0;
379        virtual unsigned int getElement(unsigned int) = 0;
380        virtual void addElement(unsigned int) = 0;
381
382    protected:
383
384        virtual ~DrawElements() {}
385};
386
387class OSG_EXPORT DrawElementsUByte : public DrawElements, public VectorGLubyte
388{
389    public:
390   
391        typedef VectorGLubyte vector_type;
392
393        DrawElementsUByte(GLenum mode=0):
394            DrawElements(DrawElementsUBytePrimitiveType,mode) {}
395   
396        DrawElementsUByte(const DrawElementsUByte& array, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
397            DrawElements(array,copyop),
398            vector_type(array) {}
399
400        /**
401         * \param no Number of intended elements. This will be the size of the underlying vector.
402         */
403        DrawElementsUByte(GLenum mode, unsigned int no, const GLubyte* ptr, int numInstances=0) :
404            DrawElements(DrawElementsUBytePrimitiveType,mode,numInstances),
405            vector_type(ptr,ptr+no) {}
406
407        /**
408         * \param no Number of intended elements. This will be the size of the underlying vector.
409         */
410        DrawElementsUByte(GLenum mode, unsigned int no) :
411            DrawElements(DrawElementsUBytePrimitiveType,mode),
412            vector_type(no) {}
413
414        virtual Object* cloneType() const { return new DrawElementsUByte(); }
415        virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUByte(*this,copyop); }       
416        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUByte*>(obj)!=NULL; }
417        virtual const char* libraryName() const { return "osg"; }
418        virtual const char* className() const { return "DrawElementsUByte"; }
419
420        virtual const GLvoid*   getDataPointer() const { return empty()?0:&front(); }
421        virtual unsigned int    getTotalDataSize() const { return static_cast<unsigned int>(size()); }
422        virtual bool            supportsBufferObject() const { return false; }
423
424        virtual void draw(State& state, bool useVertexBufferObjects) const ;
425       
426        virtual void accept(PrimitiveFunctor& functor) const;
427        virtual void accept(PrimitiveIndexFunctor& functor) const;
428
429        virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
430        virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
431        virtual void offsetIndices(int offset);
432       
433        virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
434        virtual void setElement(unsigned int i, unsigned int v)  { (*this)[i] = v; }
435        virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
436        virtual void addElement(unsigned int v) { push_back(GLubyte(v)); }
437
438    protected:
439
440        virtual ~DrawElementsUByte();
441};
442
443
444class OSG_EXPORT DrawElementsUShort : public DrawElements, public VectorGLushort
445{
446    public:
447
448        typedef VectorGLushort vector_type;
449
450        DrawElementsUShort(GLenum mode=0):
451            DrawElements(DrawElementsUShortPrimitiveType,mode) {}
452   
453        DrawElementsUShort(const DrawElementsUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
454            DrawElements(array,copyop),
455            vector_type(array) {}
456
457        /**
458         * \param no Number of intended elements. This will be the size of the underlying vector.
459         */
460        DrawElementsUShort(GLenum mode, unsigned int no, const GLushort* ptr, int numInstances=0) :
461            DrawElements(DrawElementsUShortPrimitiveType,mode,numInstances),
462            vector_type(ptr,ptr+no) {}
463
464        /**
465         * \param no Number of intended elements. This will be the size of the underlying vector.
466         */
467        DrawElementsUShort(GLenum mode, unsigned int no) :
468            DrawElements(DrawElementsUShortPrimitiveType,mode),
469            vector_type(no) {}
470
471        template <class InputIterator>
472        DrawElementsUShort(GLenum mode, InputIterator first,InputIterator last) :
473            DrawElements(DrawElementsUShortPrimitiveType,mode),
474            vector_type(first,last) {}
475
476        virtual Object* cloneType() const { return new DrawElementsUShort(); }
477        virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUShort(*this,copyop); }       
478        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUShort*>(obj)!=NULL; }
479        virtual const char* libraryName() const { return "osg"; }
480        virtual const char* className() const { return "DrawElementsUShort"; }
481
482        virtual const GLvoid*   getDataPointer() const { return empty()?0:&front(); }
483        virtual unsigned int    getTotalDataSize() const { return 2u*static_cast<unsigned int>(size()); }
484        virtual bool            supportsBufferObject() const { return false; }
485
486        virtual void draw(State& state, bool useVertexBufferObjects) const;
487       
488        virtual void accept(PrimitiveFunctor& functor) const;
489        virtual void accept(PrimitiveIndexFunctor& functor) const;
490
491        virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
492        virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
493        virtual void offsetIndices(int offset);
494
495        virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
496        virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
497        virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
498        virtual void addElement(unsigned int v) { push_back(GLushort(v)); }
499
500    protected:
501
502        virtual ~DrawElementsUShort();
503};
504
505class OSG_EXPORT DrawElementsUInt : public DrawElements, public VectorGLuint
506{
507    public:
508
509        typedef VectorGLuint vector_type;
510
511        DrawElementsUInt(GLenum mode=0):
512            DrawElements(DrawElementsUIntPrimitiveType,mode) {}
513   
514        DrawElementsUInt(const DrawElementsUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
515            DrawElements(array,copyop),
516            vector_type(array) {}
517
518        /**
519         * \param mode One of osg::PrimitiveSet::Mode. Determines the type of primitives used.
520         * \param no Number of intended elements. This will be the size of the underlying vector.
521         */
522        DrawElementsUInt(GLenum mode, unsigned int no, const GLuint* ptr, int numInstances=0) :
523            DrawElements(DrawElementsUIntPrimitiveType,mode,numInstances),
524            vector_type(ptr,ptr+no) {}
525
526        /**
527         * \param no Number of intended elements. This will be the size of the underlying vector.
528         */
529        DrawElementsUInt(GLenum mode, unsigned int no) :
530            DrawElements(DrawElementsUIntPrimitiveType,mode),
531            vector_type(no) {}
532
533        template <class InputIterator>
534        DrawElementsUInt(GLenum mode, InputIterator first,InputIterator last) :
535            DrawElements(DrawElementsUIntPrimitiveType,mode),
536            vector_type(first,last) {}
537
538        virtual Object* cloneType() const { return new DrawElementsUInt(); }
539        virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUInt(*this,copyop); }       
540        virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUInt*>(obj)!=NULL; }
541        virtual const char* libraryName() const { return "osg"; }
542        virtual const char* className() const { return "DrawElementsUInt"; }
543
544        virtual const GLvoid*   getDataPointer() const { return empty()?0:&front(); }
545        virtual unsigned int    getTotalDataSize() const { return 4u*static_cast<unsigned int>(size()); }
546        virtual bool            supportsBufferObject() const { return false; }
547
548        virtual void draw(State& state, bool useVertexBufferObjects) const;
549       
550        virtual void accept(PrimitiveFunctor& functor) const;
551        virtual void accept(PrimitiveIndexFunctor& functor) const;
552
553        virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
554        virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
555        virtual void offsetIndices(int offset);
556
557        virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
558        virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
559        virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
560        virtual void addElement(unsigned int v) { push_back(GLuint(v)); }
561
562    protected:
563
564        virtual ~DrawElementsUInt();
565};
566
567}
568
569#endif
Note: See TracBrowser for help on using the browser.