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

Revision 10627, 23.5 kB (checked in by robert, 5 years ago)

From Stephane Lamoliatte, "Here is a patch wich improves the support for geometry shaders in OpenSceneGraph.
It adds new PrimitiveSet? constants for the specific geometry shader primitive types :

  • LINES_ADJACENCY
  • LINE_STRIP_ADJACENCY
  • TRIANGLES_ADJACENCY
  • TRIANGLE_STRIP_ADJACENCY

It also adds some missing features to the glsl reader plug'in.
"

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