2002-09-20 22:51:59 +08:00
|
|
|
#include <osg/PrimitiveSet>
|
2002-06-27 18:50:19 +08:00
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
2002-06-27 21:15:34 +08:00
|
|
|
void DrawArrays::draw() const
|
2002-06-27 18:50:19 +08:00
|
|
|
{
|
2002-06-27 21:15:34 +08:00
|
|
|
glDrawArrays(_mode,_first,_count);
|
|
|
|
}
|
|
|
|
|
2002-11-06 18:24:33 +08:00
|
|
|
void DrawArrays::accept(Drawable::PrimitiveFunctor& functor) const
|
2002-06-27 21:15:34 +08:00
|
|
|
{
|
|
|
|
functor.drawArrays(_mode,_first,_count);
|
|
|
|
}
|
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
void DrawArrayLengths::draw() const
|
|
|
|
{
|
|
|
|
GLint first = _first;
|
|
|
|
for(VectorSizei::const_iterator itr=begin();
|
|
|
|
itr!=end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
glDrawArrays(_mode,first,*itr);
|
|
|
|
first += *itr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-06 18:24:33 +08:00
|
|
|
void DrawArrayLengths::accept(Drawable::PrimitiveFunctor& functor) const
|
2002-07-07 22:40:41 +08:00
|
|
|
{
|
|
|
|
GLint first = _first;
|
2002-11-06 18:24:33 +08:00
|
|
|
for(VectorSizei::const_iterator itr=begin();
|
2002-07-07 22:40:41 +08:00
|
|
|
itr!=end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
functor.drawArrays(_mode,first,*itr);
|
|
|
|
first += *itr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-09 23:43:56 +08:00
|
|
|
unsigned int DrawArrayLengths::getNumIndices() const
|
2002-09-04 04:12:29 +08:00
|
|
|
{
|
|
|
|
unsigned int count = 0;
|
2002-10-09 23:43:56 +08:00
|
|
|
for(VectorSizei::const_iterator itr=begin();
|
2002-09-04 04:12:29 +08:00
|
|
|
itr!=end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
count += *itr;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
2002-07-07 22:40:41 +08:00
|
|
|
|
|
|
|
void DrawElementsUByte::draw() const
|
2002-06-27 21:15:34 +08:00
|
|
|
{
|
|
|
|
glDrawElements(_mode,size(),GL_UNSIGNED_BYTE,&front());
|
|
|
|
}
|
|
|
|
|
2002-11-06 18:24:33 +08:00
|
|
|
void DrawElementsUByte::accept(Drawable::PrimitiveFunctor& functor) const
|
2002-06-27 21:15:34 +08:00
|
|
|
{
|
|
|
|
if (!empty()) functor.drawElements(_mode,size(),&front());
|
|
|
|
}
|
2002-06-27 18:50:19 +08:00
|
|
|
|
2002-07-18 08:53:03 +08:00
|
|
|
void DrawElementsUByte::offsetIndices(int offset)
|
|
|
|
{
|
|
|
|
for(iterator itr=begin();
|
|
|
|
itr!=end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
*itr += offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-27 21:15:34 +08:00
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
void DrawElementsUShort::draw() const
|
2002-06-27 21:15:34 +08:00
|
|
|
{
|
|
|
|
glDrawElements(_mode,size(),GL_UNSIGNED_SHORT,&front());
|
|
|
|
}
|
|
|
|
|
2002-11-06 18:24:33 +08:00
|
|
|
void DrawElementsUShort::accept(Drawable::PrimitiveFunctor& functor) const
|
2002-06-27 18:50:19 +08:00
|
|
|
{
|
2002-06-27 21:15:34 +08:00
|
|
|
if (!empty()) functor.drawElements(_mode,size(),&front());
|
2002-06-27 18:50:19 +08:00
|
|
|
}
|
|
|
|
|
2002-07-18 08:53:03 +08:00
|
|
|
void DrawElementsUShort::offsetIndices(int offset)
|
|
|
|
{
|
|
|
|
for(iterator itr=begin();
|
|
|
|
itr!=end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
*itr += offset;
|
|
|
|
}
|
|
|
|
}
|
2002-06-27 21:15:34 +08:00
|
|
|
|
|
|
|
|
2002-07-07 22:40:41 +08:00
|
|
|
void DrawElementsUInt::draw() const
|
2002-06-27 21:15:34 +08:00
|
|
|
{
|
|
|
|
glDrawElements(_mode,size(),GL_UNSIGNED_INT,&front());
|
|
|
|
}
|
|
|
|
|
2002-11-06 18:24:33 +08:00
|
|
|
void DrawElementsUInt::accept(Drawable::PrimitiveFunctor& functor) const
|
2002-06-27 21:15:34 +08:00
|
|
|
{
|
|
|
|
if (!empty()) functor.drawElements(_mode,size(),&front());
|
|
|
|
}
|
2002-07-18 08:53:03 +08:00
|
|
|
|
|
|
|
void DrawElementsUInt::offsetIndices(int offset)
|
|
|
|
{
|
|
|
|
for(iterator itr=begin();
|
|
|
|
itr!=end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
*itr += offset;
|
|
|
|
}
|
|
|
|
}
|