2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2003-01-22 00:45:36 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2003-01-22 00:45:36 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-01-22 00:45:36 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2004-09-28 17:14:04 +08:00
|
|
|
#ifndef OSG_PRIMITIVESET
|
|
|
|
#define OSG_PRIMITIVESET 1
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
#include <osg/GL>
|
|
|
|
#include <osg/Object>
|
|
|
|
#include <osg/buffered_value>
|
|
|
|
#include <osg/Vec2>
|
|
|
|
#include <osg/Vec3>
|
|
|
|
#include <osg/Vec4>
|
2007-12-04 22:46:46 +08:00
|
|
|
#include <osg/Vec2d>
|
|
|
|
#include <osg/Vec3d>
|
|
|
|
#include <osg/Vec4d>
|
2008-06-20 04:38:38 +08:00
|
|
|
#include <osg/MixinVector>
|
2005-02-09 18:39:45 +08:00
|
|
|
|
2007-04-26 02:50:11 +08:00
|
|
|
#include <osg/BufferObject>
|
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
#include <vector>
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2016-01-22 17:47:49 +08:00
|
|
|
#define OSG_HAS_MULTIDRAWARRAYS
|
|
|
|
|
2002-06-27 18:50:19 +08:00
|
|
|
namespace osg {
|
|
|
|
|
2008-06-20 04:38:38 +08:00
|
|
|
typedef MixinVector<GLsizei> VectorGLsizei;
|
|
|
|
typedef MixinVector<GLubyte> VectorGLubyte;
|
|
|
|
typedef MixinVector<GLushort> VectorGLushort;
|
|
|
|
typedef MixinVector<GLuint> VectorGLuint;
|
2005-12-02 08:25:40 +08:00
|
|
|
|
2006-06-26 17:56:52 +08:00
|
|
|
class State;
|
|
|
|
|
|
|
|
/** A \c PrimitiveFunctor is used (in conjunction with
|
|
|
|
* <tt>osg::Drawable::accept (PrimitiveFunctor&)</tt>) to get access to the
|
|
|
|
* primitives that compose the things drawn by OSG.
|
|
|
|
* <p>If \c osg::Drawable::accept() is called with a \c PrimitiveFunctor
|
|
|
|
* parameter, the \c Drawable will "pretend" it is drawing itself, but instead
|
|
|
|
* of calling real OpenGL functions, it will call <tt>PrimitiveFunctor</tt>'s
|
|
|
|
* member functions that "mimic" the OpenGL calls.
|
|
|
|
* <p>Concrete subclasses of \c PrimitiveFunctor must implement these methods
|
|
|
|
* so that they performs whatever they want.
|
|
|
|
*/
|
2005-02-09 18:39:45 +08:00
|
|
|
class PrimitiveFunctor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~PrimitiveFunctor() {}
|
|
|
|
|
2006-06-26 17:56:52 +08:00
|
|
|
/** Sets the array of vertices used to describe the primitives. Somehow
|
|
|
|
* mimics the OpenGL \c glVertexPointer() function.
|
|
|
|
*/
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void setVertexArray(unsigned int count,const Vec2* vertices) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/** Sets the array of vertices used to describe the primitives. Somehow
|
|
|
|
* mimics the OpenGL \c glVertexPointer() function.
|
|
|
|
*/
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void setVertexArray(unsigned int count,const Vec3* vertices) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/** Sets the array of vertices used to describe the primitives. Somehow
|
|
|
|
* mimics the OpenGL \c glVertexPointer() function.
|
|
|
|
*/
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0;
|
|
|
|
|
2007-12-04 22:46:46 +08:00
|
|
|
/** Sets the array of vertices used to describe the primitives. Somehow
|
|
|
|
* mimics the OpenGL \c glVertexPointer() function.
|
|
|
|
*/
|
|
|
|
virtual void setVertexArray(unsigned int count,const Vec2d* vertices) = 0;
|
|
|
|
|
|
|
|
/** Sets the array of vertices used to describe the primitives. Somehow
|
|
|
|
* mimics the OpenGL \c glVertexPointer() function.
|
|
|
|
*/
|
|
|
|
virtual void setVertexArray(unsigned int count,const Vec3d* vertices) = 0;
|
|
|
|
|
|
|
|
/** Sets the array of vertices used to describe the primitives. Somehow
|
|
|
|
* mimics the OpenGL \c glVertexPointer() function.
|
|
|
|
*/
|
|
|
|
virtual void setVertexArray(unsigned int count,const Vec4d* vertices) = 0;
|
|
|
|
|
2006-06-26 17:56:52 +08:00
|
|
|
/// Mimics the OpenGL \c glDrawArrays() function.
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glDrawElements() function.
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glDrawElements() function.
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glDrawElements() function.
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) = 0;
|
|
|
|
|
2006-06-26 17:56:52 +08:00
|
|
|
/// Mimics the OpenGL \c glBegin() function.
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void begin(GLenum mode) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glVertex() "family of functions".
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void vertex(const Vec2& vert) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glVertex() "family of functions".
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void vertex(const Vec3& vert) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glVertex() "family of functions".
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void vertex(const Vec4& vert) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glVertex() "family of functions".
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void vertex(float x,float y) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glVertex() "family of functions".
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void vertex(float x,float y,float z) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glVertex() "family of functions".
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void vertex(float x,float y,float z,float w) = 0;
|
2006-06-26 17:56:52 +08:00
|
|
|
|
|
|
|
/// Mimics the OpenGL \c glEnd() function.
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void end() = 0;
|
2015-01-12 18:30:50 +08:00
|
|
|
|
|
|
|
void useVertexCacheAsVertexArray()
|
|
|
|
{
|
|
|
|
setVertexArray(_vertexCache.size(),&_vertexCache.front());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<Vec3> _vertexCache;
|
|
|
|
bool _treatVertexDataAsTemporary;
|
2005-02-09 18:39:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class PrimitiveIndexFunctor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~PrimitiveIndexFunctor() {}
|
|
|
|
|
|
|
|
virtual void setVertexArray(unsigned int count,const Vec2* vertices) = 0;
|
|
|
|
virtual void setVertexArray(unsigned int count,const Vec3* vertices) = 0;
|
|
|
|
virtual void setVertexArray(unsigned int count,const Vec4* vertices) = 0;
|
|
|
|
|
2007-12-04 22:46:46 +08:00
|
|
|
virtual void setVertexArray(unsigned int count,const Vec2d* vertices) = 0;
|
|
|
|
virtual void setVertexArray(unsigned int count,const Vec3d* vertices) = 0;
|
|
|
|
virtual void setVertexArray(unsigned int count,const Vec4d* vertices) = 0;
|
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
|
|
|
|
virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0;
|
|
|
|
virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0;
|
|
|
|
virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) = 0;
|
|
|
|
|
|
|
|
virtual void begin(GLenum mode) = 0;
|
|
|
|
virtual void vertex(unsigned int pos) = 0;
|
|
|
|
virtual void end() = 0;
|
2015-01-12 18:30:50 +08:00
|
|
|
|
|
|
|
void useVertexCacheAsVertexArray()
|
|
|
|
{
|
|
|
|
setVertexArray(_vertexCache.size(),&_vertexCache.front());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<Vec3> _vertexCache;
|
|
|
|
bool _treatVertexDataAsTemporary;
|
2005-02-09 18:39:45 +08:00
|
|
|
};
|
|
|
|
|
2007-04-27 22:52:30 +08:00
|
|
|
class DrawElements;
|
|
|
|
|
2009-10-02 04:19:42 +08:00
|
|
|
class OSG_EXPORT PrimitiveSet : public BufferData
|
2002-06-27 18:50:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-27 21:15:34 +08:00
|
|
|
enum Type
|
|
|
|
{
|
2002-06-28 16:47:23 +08:00
|
|
|
PrimitiveType,
|
|
|
|
DrawArraysPrimitiveType,
|
2002-07-07 22:40:41 +08:00
|
|
|
DrawArrayLengthsPrimitiveType,
|
|
|
|
DrawElementsUBytePrimitiveType,
|
|
|
|
DrawElementsUShortPrimitiveType,
|
2016-01-22 17:47:49 +08:00
|
|
|
DrawElementsUIntPrimitiveType,
|
|
|
|
MultiDrawArraysPrimitiveType
|
2002-06-27 21:15:34 +08:00
|
|
|
};
|
|
|
|
|
2002-06-27 18:50:19 +08:00
|
|
|
enum Mode
|
|
|
|
{
|
|
|
|
POINTS = GL_POINTS,
|
|
|
|
LINES = GL_LINES,
|
|
|
|
LINE_STRIP = GL_LINE_STRIP,
|
|
|
|
LINE_LOOP = GL_LINE_LOOP,
|
|
|
|
TRIANGLES = GL_TRIANGLES,
|
|
|
|
TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
|
|
|
|
TRIANGLE_FAN = GL_TRIANGLE_FAN,
|
|
|
|
QUADS = GL_QUADS,
|
|
|
|
QUAD_STRIP = GL_QUAD_STRIP,
|
2009-10-10 17:41:28 +08:00
|
|
|
POLYGON = GL_POLYGON,
|
2015-01-27 23:07:53 +08:00
|
|
|
LINES_ADJACENCY = GL_LINES_ADJACENCY,
|
|
|
|
LINE_STRIP_ADJACENCY = GL_LINE_STRIP_ADJACENCY,
|
|
|
|
TRIANGLES_ADJACENCY = GL_TRIANGLES_ADJACENCY,
|
|
|
|
TRIANGLE_STRIP_ADJACENCY = GL_TRIANGLE_STRIP_ADJACENCY,
|
2010-11-23 22:50:31 +08:00
|
|
|
PATCHES = GL_PATCHES
|
2002-06-27 18:50:19 +08:00
|
|
|
};
|
|
|
|
|
2009-01-06 22:55:49 +08:00
|
|
|
PrimitiveSet(Type primType=PrimitiveType,GLenum mode=0, int numInstances=0):
|
2002-06-27 18:50:19 +08:00
|
|
|
_primitiveType(primType),
|
2009-01-06 22:55:49 +08:00
|
|
|
_numInstances(numInstances),
|
2011-05-06 17:21:04 +08:00
|
|
|
_mode(mode) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet(const PrimitiveSet& prim,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2009-10-02 04:19:42 +08:00
|
|
|
BufferData(prim,copyop),
|
2002-06-27 18:50:19 +08:00
|
|
|
_primitiveType(prim._primitiveType),
|
2009-01-06 22:55:49 +08:00
|
|
|
_numInstances(prim._numInstances),
|
2011-05-06 17:21:04 +08:00
|
|
|
_mode(prim._mode) {}
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2002-09-20 22:51:59 +08:00
|
|
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const PrimitiveSet*>(obj)!=NULL; }
|
2002-06-27 18:50:19 +08:00
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
2002-09-20 22:51:59 +08:00
|
|
|
virtual const char* className() const { return "PrimitiveSet"; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
Type getType() const { return _primitiveType; }
|
2012-01-24 22:34:02 +08:00
|
|
|
|
|
|
|
virtual osg::PrimitiveSet* asPrimitiveSet() { return this; }
|
|
|
|
virtual const osg::PrimitiveSet* asPrimitiveSet() const { return this; }
|
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual const GLvoid* getDataPointer() const { return 0; }
|
|
|
|
virtual unsigned int getTotalDataSize() const { return 0; }
|
|
|
|
virtual bool supportsBufferObject() const { return false; }
|
2007-04-27 22:52:30 +08:00
|
|
|
|
|
|
|
virtual DrawElements* getDrawElements() { return 0; }
|
|
|
|
virtual const DrawElements* getDrawElements() const { return 0; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-06 22:55:49 +08:00
|
|
|
void setNumInstances(int n) { _numInstances = n; }
|
|
|
|
int getNumInstances() const { return _numInstances; }
|
|
|
|
|
2002-06-27 18:50:19 +08:00
|
|
|
void setMode(GLenum mode) { _mode = mode; }
|
|
|
|
GLenum getMode() const { return _mode; }
|
|
|
|
|
2004-06-29 23:04:38 +08:00
|
|
|
virtual void draw(State& state, bool useVertexBufferObjects) const = 0;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void accept(PrimitiveFunctor& functor) const = 0;
|
|
|
|
virtual void accept(PrimitiveIndexFunctor& functor) const = 0;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-10-09 23:43:56 +08:00
|
|
|
virtual unsigned int index(unsigned int pos) const = 0;
|
|
|
|
virtual unsigned int getNumIndices() const = 0;
|
2002-07-18 08:53:03 +08:00
|
|
|
virtual void offsetIndices(int offset) = 0;
|
2002-10-09 23:43:56 +08:00
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
virtual unsigned int getNumPrimitives() const;
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2007-01-02 02:20:10 +08:00
|
|
|
virtual void computeRange() const {}
|
|
|
|
|
2002-06-27 18:50:19 +08:00
|
|
|
protected:
|
|
|
|
|
2003-01-10 17:25:42 +08:00
|
|
|
virtual ~PrimitiveSet() {}
|
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
Type _primitiveType;
|
2009-01-06 22:55:49 +08:00
|
|
|
int _numInstances;
|
2005-02-09 18:39:45 +08:00
|
|
|
GLenum _mode;
|
2002-06-27 18:50:19 +08:00
|
|
|
};
|
|
|
|
|
2005-04-12 01:14:17 +08:00
|
|
|
class OSG_EXPORT DrawArrays : public PrimitiveSet
|
2002-06-27 18:50:19 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
DrawArrays(GLenum mode=0):
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet(DrawArraysPrimitiveType,mode),
|
2002-07-07 22:40:41 +08:00
|
|
|
_first(0),
|
|
|
|
_count(0) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-06 22:55:49 +08:00
|
|
|
DrawArrays(GLenum mode, GLint first, GLsizei count, int numInstances=0):
|
|
|
|
PrimitiveSet(DrawArraysPrimitiveType, mode, numInstances),
|
2002-06-27 18:50:19 +08:00
|
|
|
_first(first),
|
|
|
|
_count(count) {}
|
|
|
|
|
|
|
|
DrawArrays(const DrawArrays& da,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet(da,copyop),
|
2002-06-27 18:50:19 +08:00
|
|
|
_first(da._first),
|
|
|
|
_count(da._count) {}
|
|
|
|
|
2002-12-16 21:40:58 +08:00
|
|
|
virtual Object* cloneType() const { return new DrawArrays(); }
|
2012-03-22 01:36:20 +08:00
|
|
|
virtual Object* clone(const CopyOp& copyop) const { return new DrawArrays(*this,copyop); }
|
2002-06-27 18:50:19 +08:00
|
|
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawArrays*>(obj)!=NULL; }
|
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
|
|
|
virtual const char* className() const { return "DrawArrays"; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-27 18:50:19 +08:00
|
|
|
|
|
|
|
void set(GLenum mode,GLint first, GLsizei count)
|
|
|
|
{
|
|
|
|
_mode = mode;
|
|
|
|
_first = first;
|
|
|
|
_count = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFirst(GLint first) { _first = first; }
|
|
|
|
GLint getFirst() const { return _first; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-27 18:50:19 +08:00
|
|
|
void setCount(GLsizei count) { _count = count; }
|
|
|
|
GLsizei getCount() const { return _count; }
|
|
|
|
|
2004-06-29 23:04:38 +08:00
|
|
|
virtual void draw(State& state, bool useVertexBufferObjects) const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void accept(PrimitiveFunctor& functor) const;
|
|
|
|
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-30 18:55:28 +08:00
|
|
|
virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(_count); }
|
|
|
|
virtual unsigned int index(unsigned int pos) const { return static_cast<unsigned int>(_first)+pos; }
|
2002-07-18 08:53:03 +08:00
|
|
|
virtual void offsetIndices(int offset) { _first += offset; }
|
|
|
|
|
2002-06-27 21:15:34 +08:00
|
|
|
protected:
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2003-01-10 17:25:42 +08:00
|
|
|
virtual ~DrawArrays() {}
|
|
|
|
|
2002-06-27 18:50:19 +08:00
|
|
|
GLint _first;
|
|
|
|
GLsizei _count;
|
|
|
|
};
|
|
|
|
|
2005-12-02 08:25:40 +08:00
|
|
|
class OSG_EXPORT DrawArrayLengths : public PrimitiveSet, public VectorGLsizei
|
2002-06-27 18:50:19 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2005-12-02 08:25:40 +08:00
|
|
|
typedef VectorGLsizei vector_type;
|
2005-07-22 16:21:17 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
DrawArrayLengths(GLenum mode=0):
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
|
2002-07-07 22:40:41 +08:00
|
|
|
_first(0) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
DrawArrayLengths(const DrawArrayLengths& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet(dal,copyop),
|
2005-07-22 16:21:17 +08:00
|
|
|
vector_type(dal),
|
2002-07-07 22:40:41 +08:00
|
|
|
_first(dal._first) {}
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawArrayLengths(GLenum mode, GLint first, unsigned int no, GLsizei* ptr) :
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
|
2005-07-22 16:21:17 +08:00
|
|
|
vector_type(ptr,ptr+no),
|
2002-07-07 22:40:41 +08:00
|
|
|
_first(first) {}
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawArrayLengths(GLenum mode,GLint first, unsigned int no) :
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
|
2005-07-22 16:21:17 +08:00
|
|
|
vector_type(no),
|
2002-07-07 22:40:41 +08:00
|
|
|
_first(first) {}
|
|
|
|
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawArrayLengths(GLenum mode,GLint first) :
|
2002-09-20 22:51:59 +08:00
|
|
|
PrimitiveSet(DrawArrayLengthsPrimitiveType,mode),
|
2005-07-22 16:21:17 +08:00
|
|
|
vector_type(),
|
2002-07-07 22:40:41 +08:00
|
|
|
_first(first) {}
|
|
|
|
|
2003-01-15 19:29:30 +08:00
|
|
|
|
2002-12-16 21:40:58 +08:00
|
|
|
virtual Object* cloneType() const { return new DrawArrayLengths(); }
|
2012-03-22 01:36:20 +08:00
|
|
|
virtual Object* clone(const CopyOp& copyop) const { return new DrawArrayLengths(*this,copyop); }
|
2002-07-07 22:40:41 +08:00
|
|
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawArrayLengths*>(obj)!=NULL; }
|
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
|
|
|
virtual const char* className() const { return "DrawArrayLengths"; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
|
|
|
|
void setFirst(GLint first) { _first = first; }
|
|
|
|
GLint getFirst() const { return _first; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2004-06-29 23:04:38 +08:00
|
|
|
virtual void draw(State& state, bool useVertexBufferObjects) const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void accept(PrimitiveFunctor& functor) const;
|
|
|
|
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-10-09 23:43:56 +08:00
|
|
|
virtual unsigned int getNumIndices() const;
|
|
|
|
virtual unsigned int index(unsigned int pos) const { return _first+pos; }
|
2002-07-18 08:53:03 +08:00
|
|
|
virtual void offsetIndices(int offset) { _first += offset; }
|
|
|
|
|
2005-12-03 08:03:31 +08:00
|
|
|
virtual unsigned int getNumPrimitives() const;
|
2002-09-04 04:12:29 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
protected:
|
|
|
|
|
2003-01-10 17:25:42 +08:00
|
|
|
virtual ~DrawArrayLengths() {}
|
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
GLint _first;
|
|
|
|
};
|
|
|
|
|
2007-04-26 02:50:11 +08:00
|
|
|
class DrawElements : public PrimitiveSet
|
|
|
|
{
|
|
|
|
public:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2009-01-06 22:55:49 +08:00
|
|
|
DrawElements(Type primType=PrimitiveType, GLenum mode=0, int numInstances=0):
|
2009-10-02 04:19:42 +08:00
|
|
|
PrimitiveSet(primType,mode, numInstances) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(const DrawElements& copy,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2009-10-02 04:19:42 +08:00
|
|
|
PrimitiveSet(copy,copyop) {}
|
2007-04-26 02:50:11 +08:00
|
|
|
|
|
|
|
|
2007-04-27 22:52:30 +08:00
|
|
|
virtual DrawElements* getDrawElements() { return this; }
|
|
|
|
virtual const DrawElements* getDrawElements() const { return this; }
|
|
|
|
|
2007-05-01 14:28:20 +08:00
|
|
|
/** Set the ElementBufferObject.*/
|
2009-10-02 04:19:42 +08:00
|
|
|
inline void setElementBufferObject(osg::ElementBufferObject* ebo) { setBufferObject(ebo); }
|
2007-04-27 00:50:06 +08:00
|
|
|
|
2007-05-01 14:28:20 +08:00
|
|
|
/** Get the ElementBufferObject. If no EBO is assigned returns NULL*/
|
2009-10-02 04:19:42 +08:00
|
|
|
inline osg::ElementBufferObject* getElementBufferObject() { return dynamic_cast<osg::ElementBufferObject*>(_bufferObject.get()); }
|
2007-04-26 02:50:11 +08:00
|
|
|
|
2007-05-01 14:28:20 +08:00
|
|
|
/** Get the const ElementBufferObject. If no EBO is assigned returns NULL*/
|
2009-10-02 04:19:42 +08:00
|
|
|
inline const osg::ElementBufferObject* getElementBufferObject() const { return dynamic_cast<const osg::ElementBufferObject*>(_bufferObject.get()); }
|
2007-04-26 02:50:11 +08:00
|
|
|
|
2015-02-11 01:04:02 +08:00
|
|
|
virtual GLenum getDataType() = 0;
|
2014-02-13 19:01:36 +08:00
|
|
|
virtual void resizeElements(unsigned int numIndices) = 0;
|
2009-03-25 19:17:21 +08:00
|
|
|
virtual void reserveElements(unsigned int numIndices) = 0;
|
|
|
|
virtual void setElement(unsigned int, unsigned int) = 0;
|
|
|
|
virtual unsigned int getElement(unsigned int) = 0;
|
|
|
|
virtual void addElement(unsigned int) = 0;
|
2007-04-26 02:50:11 +08:00
|
|
|
|
|
|
|
protected:
|
2007-05-02 02:03:32 +08:00
|
|
|
|
2009-10-02 04:19:42 +08:00
|
|
|
virtual ~DrawElements() {}
|
2007-04-26 02:50:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class OSG_EXPORT DrawElementsUByte : public DrawElements, public VectorGLubyte
|
2002-07-07 22:40:41 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-12-02 08:25:40 +08:00
|
|
|
typedef VectorGLubyte vector_type;
|
2002-07-07 22:40:41 +08:00
|
|
|
|
|
|
|
DrawElementsUByte(GLenum mode=0):
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(DrawElementsUBytePrimitiveType,mode) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2008-02-15 22:09:44 +08:00
|
|
|
DrawElementsUByte(const DrawElementsUByte& array, const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(array,copyop),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(array) {}
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2010-08-16 17:35:59 +08:00
|
|
|
/**
|
2016-06-01 21:20:14 +08:00
|
|
|
* \param mode One of osg::PrimitiveSet::Mode. Determines the type of primitives used.
|
2010-08-16 17:35:59 +08:00
|
|
|
* \param no Number of intended elements. This will be the size of the underlying vector.
|
2016-06-01 21:20:14 +08:00
|
|
|
* \param ptr Pointer to a GLubyte to copy index data from.
|
|
|
|
* \param numInstances When non zero passed as the number of draw instances to use re.
|
2010-08-16 17:35:59 +08:00
|
|
|
*/
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawElementsUByte(GLenum mode, unsigned int no, const GLubyte* ptr, int numInstances=0) :
|
2009-01-06 22:55:49 +08:00
|
|
|
DrawElements(DrawElementsUBytePrimitiveType,mode,numInstances),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(ptr,ptr+no) {}
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2010-08-16 17:35:59 +08:00
|
|
|
/**
|
2016-06-01 21:20:14 +08:00
|
|
|
* \param mode One of osg::PrimitiveSet::Mode. Determines the type of primitives used.
|
2010-08-16 17:35:59 +08:00
|
|
|
* \param no Number of intended elements. This will be the size of the underlying vector.
|
|
|
|
*/
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawElementsUByte(GLenum mode, unsigned int no) :
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(DrawElementsUBytePrimitiveType,mode),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(no) {}
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2002-12-16 21:40:58 +08:00
|
|
|
virtual Object* cloneType() const { return new DrawElementsUByte(); }
|
2012-03-22 01:36:20 +08:00
|
|
|
virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUByte(*this,copyop); }
|
2002-07-07 22:40:41 +08:00
|
|
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUByte*>(obj)!=NULL; }
|
2002-06-27 18:50:19 +08:00
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
2002-07-07 22:40:41 +08:00
|
|
|
virtual const char* className() const { return "DrawElementsUByte"; }
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
|
2009-01-30 18:55:28 +08:00
|
|
|
virtual unsigned int getTotalDataSize() const { return static_cast<unsigned int>(size()); }
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual bool supportsBufferObject() const { return false; }
|
|
|
|
|
2004-06-29 23:04:38 +08:00
|
|
|
virtual void draw(State& state, bool useVertexBufferObjects) const ;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void accept(PrimitiveFunctor& functor) const;
|
|
|
|
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
2002-07-18 08:53:03 +08:00
|
|
|
|
2009-01-30 18:55:28 +08:00
|
|
|
virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
|
2002-10-09 23:43:56 +08:00
|
|
|
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
2002-07-18 08:53:03 +08:00
|
|
|
virtual void offsetIndices(int offset);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2015-02-11 01:04:02 +08:00
|
|
|
virtual GLenum getDataType() { return GL_UNSIGNED_BYTE; }
|
2014-02-13 19:01:36 +08:00
|
|
|
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
2009-03-25 19:17:21 +08:00
|
|
|
virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
|
|
|
|
virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
|
2012-03-22 01:36:20 +08:00
|
|
|
virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
|
|
|
|
virtual void addElement(unsigned int v) { push_back(GLubyte(v)); }
|
2009-03-25 19:17:21 +08:00
|
|
|
|
2003-01-10 17:25:42 +08:00
|
|
|
protected:
|
|
|
|
|
2005-11-25 20:31:04 +08:00
|
|
|
virtual ~DrawElementsUByte();
|
2002-06-27 21:15:34 +08:00
|
|
|
};
|
|
|
|
|
2002-07-04 22:49:37 +08:00
|
|
|
|
2007-04-26 02:50:11 +08:00
|
|
|
class OSG_EXPORT DrawElementsUShort : public DrawElements, public VectorGLushort
|
2002-06-27 21:15:34 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2005-12-02 08:25:40 +08:00
|
|
|
typedef VectorGLushort vector_type;
|
2005-07-21 03:42:59 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
DrawElementsUShort(GLenum mode=0):
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(DrawElementsUShortPrimitiveType,mode) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
DrawElementsUShort(const DrawElementsUShort& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(array,copyop),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(array) {}
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2010-08-16 17:35:59 +08:00
|
|
|
/**
|
2016-06-01 21:20:14 +08:00
|
|
|
* \param mode One of osg::PrimitiveSet::Mode. Determines the type of primitives used.
|
2010-08-16 17:35:59 +08:00
|
|
|
* \param no Number of intended elements. This will be the size of the underlying vector.
|
2016-06-01 21:20:14 +08:00
|
|
|
* \param ptr Pointer to a GLushort to copy index data from.
|
|
|
|
* \param numInstances When non zero passed as the number of draw instances to use re.
|
2010-08-16 17:35:59 +08:00
|
|
|
*/
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawElementsUShort(GLenum mode, unsigned int no, const GLushort* ptr, int numInstances=0) :
|
2009-01-06 22:55:49 +08:00
|
|
|
DrawElements(DrawElementsUShortPrimitiveType,mode,numInstances),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(ptr,ptr+no) {}
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2010-08-16 17:35:59 +08:00
|
|
|
/**
|
2016-06-01 21:20:14 +08:00
|
|
|
* \param mode One of osg::PrimitiveSet::Mode. Determines the type of primitives used.
|
2010-08-16 17:35:59 +08:00
|
|
|
* \param no Number of intended elements. This will be the size of the underlying vector.
|
|
|
|
*/
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawElementsUShort(GLenum mode, unsigned int no) :
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(DrawElementsUShortPrimitiveType,mode),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(no) {}
|
2002-06-27 21:15:34 +08:00
|
|
|
|
|
|
|
template <class InputIterator>
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawElementsUShort(GLenum mode, InputIterator first,InputIterator last) :
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(DrawElementsUShortPrimitiveType,mode),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(first,last) {}
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2002-12-16 21:40:58 +08:00
|
|
|
virtual Object* cloneType() const { return new DrawElementsUShort(); }
|
2012-03-22 01:36:20 +08:00
|
|
|
virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUShort(*this,copyop); }
|
2002-07-07 22:40:41 +08:00
|
|
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUShort*>(obj)!=NULL; }
|
2002-06-27 21:15:34 +08:00
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
2002-07-07 22:40:41 +08:00
|
|
|
virtual const char* className() const { return "DrawElementsUShort"; }
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
|
2009-01-30 18:55:28 +08:00
|
|
|
virtual unsigned int getTotalDataSize() const { return 2u*static_cast<unsigned int>(size()); }
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual bool supportsBufferObject() const { return false; }
|
|
|
|
|
2004-06-29 23:04:38 +08:00
|
|
|
virtual void draw(State& state, bool useVertexBufferObjects) const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void accept(PrimitiveFunctor& functor) const;
|
|
|
|
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
2002-07-18 08:53:03 +08:00
|
|
|
|
2009-01-30 18:55:28 +08:00
|
|
|
virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
|
2002-10-09 23:43:56 +08:00
|
|
|
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
2002-07-18 08:53:03 +08:00
|
|
|
virtual void offsetIndices(int offset);
|
2003-01-10 17:25:42 +08:00
|
|
|
|
2015-02-11 01:04:02 +08:00
|
|
|
virtual GLenum getDataType() { return GL_UNSIGNED_SHORT; }
|
2014-02-13 19:01:36 +08:00
|
|
|
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
2009-03-25 19:17:21 +08:00
|
|
|
virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
|
|
|
|
virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
|
|
|
|
virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
|
|
|
|
virtual void addElement(unsigned int v) { push_back(GLushort(v)); }
|
|
|
|
|
2003-01-10 17:25:42 +08:00
|
|
|
protected:
|
|
|
|
|
2004-09-22 01:26:08 +08:00
|
|
|
virtual ~DrawElementsUShort();
|
2002-06-27 21:15:34 +08:00
|
|
|
};
|
|
|
|
|
2007-04-26 02:50:11 +08:00
|
|
|
class OSG_EXPORT DrawElementsUInt : public DrawElements, public VectorGLuint
|
2002-06-27 21:15:34 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2005-12-02 08:25:40 +08:00
|
|
|
typedef VectorGLuint vector_type;
|
2005-07-21 03:42:59 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
DrawElementsUInt(GLenum mode=0):
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(DrawElementsUIntPrimitiveType,mode) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
DrawElementsUInt(const DrawElementsUInt& array,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(array,copyop),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(array) {}
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2010-08-16 17:35:59 +08:00
|
|
|
/**
|
|
|
|
* \param mode One of osg::PrimitiveSet::Mode. Determines the type of primitives used.
|
|
|
|
* \param no Number of intended elements. This will be the size of the underlying vector.
|
2016-06-01 21:20:14 +08:00
|
|
|
* \param ptr Pointer to a GLuint to copy index data from.
|
|
|
|
* \param numInstances When non zero passed as the number of draw instances to use re.
|
2010-08-16 17:35:59 +08:00
|
|
|
*/
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawElementsUInt(GLenum mode, unsigned int no, const GLuint* ptr, int numInstances=0) :
|
2009-01-06 22:55:49 +08:00
|
|
|
DrawElements(DrawElementsUIntPrimitiveType,mode,numInstances),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(ptr,ptr+no) {}
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2010-08-16 17:35:59 +08:00
|
|
|
/**
|
2016-06-01 21:20:14 +08:00
|
|
|
* \param mode One of osg::PrimitiveSet::Mode. Determines the type of primitives used.
|
2010-08-16 17:35:59 +08:00
|
|
|
* \param no Number of intended elements. This will be the size of the underlying vector.
|
|
|
|
*/
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawElementsUInt(GLenum mode, unsigned int no) :
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(DrawElementsUIntPrimitiveType,mode),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(no) {}
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2003-09-17 03:54:57 +08:00
|
|
|
template <class InputIterator>
|
2012-03-22 01:36:20 +08:00
|
|
|
DrawElementsUInt(GLenum mode, InputIterator first,InputIterator last) :
|
2007-04-26 02:50:11 +08:00
|
|
|
DrawElements(DrawElementsUIntPrimitiveType,mode),
|
2005-07-21 03:42:59 +08:00
|
|
|
vector_type(first,last) {}
|
2003-09-17 03:54:57 +08:00
|
|
|
|
2002-12-16 21:40:58 +08:00
|
|
|
virtual Object* cloneType() const { return new DrawElementsUInt(); }
|
2012-03-22 01:36:20 +08:00
|
|
|
virtual Object* clone(const CopyOp& copyop) const { return new DrawElementsUInt(*this,copyop); }
|
2002-07-07 22:40:41 +08:00
|
|
|
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawElementsUInt*>(obj)!=NULL; }
|
2002-06-27 21:15:34 +08:00
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
2002-07-07 22:40:41 +08:00
|
|
|
virtual const char* className() const { return "DrawElementsUInt"; }
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual const GLvoid* getDataPointer() const { return empty()?0:&front(); }
|
2009-01-30 18:55:28 +08:00
|
|
|
virtual unsigned int getTotalDataSize() const { return 4u*static_cast<unsigned int>(size()); }
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual bool supportsBufferObject() const { return false; }
|
|
|
|
|
2004-06-29 23:04:38 +08:00
|
|
|
virtual void draw(State& state, bool useVertexBufferObjects) const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-02-09 18:39:45 +08:00
|
|
|
virtual void accept(PrimitiveFunctor& functor) const;
|
|
|
|
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2009-01-30 18:55:28 +08:00
|
|
|
virtual unsigned int getNumIndices() const { return static_cast<unsigned int>(size()); }
|
2002-10-09 23:43:56 +08:00
|
|
|
virtual unsigned int index(unsigned int pos) const { return (*this)[pos]; }
|
2002-07-18 08:53:03 +08:00
|
|
|
virtual void offsetIndices(int offset);
|
2003-01-10 17:25:42 +08:00
|
|
|
|
2015-02-11 01:04:02 +08:00
|
|
|
virtual GLenum getDataType() { return GL_UNSIGNED_INT; }
|
2014-02-13 19:01:36 +08:00
|
|
|
virtual void resizeElements(unsigned int numIndices) { resize(numIndices); }
|
2009-03-25 19:17:21 +08:00
|
|
|
virtual void reserveElements(unsigned int numIndices) { reserve(numIndices); }
|
|
|
|
virtual void setElement(unsigned int i, unsigned int v) { (*this)[i] = v; }
|
|
|
|
virtual unsigned int getElement(unsigned int i) { return (*this)[i]; }
|
|
|
|
virtual void addElement(unsigned int v) { push_back(GLuint(v)); }
|
|
|
|
|
2003-01-10 17:25:42 +08:00
|
|
|
protected:
|
|
|
|
|
2004-09-22 01:26:08 +08:00
|
|
|
virtual ~DrawElementsUInt();
|
2002-06-27 18:50:19 +08:00
|
|
|
};
|
|
|
|
|
2016-01-22 17:47:49 +08:00
|
|
|
#ifdef OSG_HAS_MULTIDRAWARRAYS
|
|
|
|
class OSG_EXPORT MultiDrawArrays : public osg::PrimitiveSet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
MultiDrawArrays(GLenum mode=0):
|
|
|
|
osg::PrimitiveSet(Type(MultiDrawArraysPrimitiveType), mode) {}
|
|
|
|
|
|
|
|
MultiDrawArrays(const MultiDrawArrays& dal,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
|
|
|
osg::PrimitiveSet(dal,copyop),
|
|
|
|
_firsts(dal._firsts),
|
|
|
|
_counts(dal._counts) {}
|
|
|
|
|
|
|
|
virtual osg::Object* cloneType() const { return new MultiDrawArrays(); }
|
|
|
|
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new MultiDrawArrays(*this,copyop); }
|
|
|
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const MultiDrawArrays*>(obj)!=NULL; }
|
|
|
|
virtual const char* libraryName() const { return "osg"; }
|
|
|
|
virtual const char* className() const { return "MultiDrawArrays"; }
|
|
|
|
|
|
|
|
|
|
|
|
virtual void draw(osg::State& state, bool useVertexBufferObjects) const;
|
|
|
|
|
|
|
|
virtual void accept(PrimitiveFunctor& functor) const;
|
|
|
|
virtual void accept(PrimitiveIndexFunctor& functor) const;
|
|
|
|
|
|
|
|
virtual unsigned int getNumIndices() const;
|
|
|
|
virtual unsigned int index(unsigned int pos) const;
|
|
|
|
virtual void offsetIndices(int offset);
|
|
|
|
|
|
|
|
virtual unsigned int getNumPrimitives() const;
|
|
|
|
|
|
|
|
typedef std::vector<GLint> Firsts;
|
|
|
|
void setFirsts(const Firsts& firsts) { _firsts = firsts; }
|
|
|
|
Firsts& getFirsts() { return _firsts; }
|
|
|
|
const Firsts& getFirsts() const { return _firsts; }
|
|
|
|
|
|
|
|
typedef std::vector<GLsizei> Counts;
|
|
|
|
void setCounts(const Counts& firsts) { _counts = firsts; }
|
|
|
|
Counts& getCounts() { return _counts; }
|
|
|
|
const Counts& getCounts() const { return _counts; }
|
|
|
|
|
|
|
|
void add(GLint first, GLsizei count);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
Firsts _firsts;
|
|
|
|
Counts _counts;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-06-27 18:50:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|