2003-01-22 00:45:36 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
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;
|
|
|
|
}
|
|
|
|
}
|