From Leandro Motta Barros, documentation additions to PrimitiveSet & TriangleFunctor.
This commit is contained in:
parent
3b499341ed
commit
f8644d08e5
@ -40,7 +40,7 @@ namespace osg {
|
||||
class VectorGLsizei: public std::vector<GLsizei>
|
||||
{
|
||||
typedef std::vector<value_type> vector_type;
|
||||
public:
|
||||
public:
|
||||
VectorGLsizei(): vector_type() {}
|
||||
VectorGLsizei(const VectorGLsizei ©): vector_type(copy) {}
|
||||
VectorGLsizei(GLsizei* beg, GLsizei* end): vector_type(beg, end) {}
|
||||
@ -50,7 +50,7 @@ public:
|
||||
class VectorGLubyte: public std::vector<GLubyte>
|
||||
{
|
||||
typedef std::vector<value_type> vector_type;
|
||||
public:
|
||||
public:
|
||||
VectorGLubyte(): vector_type() {}
|
||||
VectorGLubyte(const VectorGLubyte ©): vector_type(copy) {}
|
||||
VectorGLubyte(GLubyte* beg, GLubyte* end): vector_type(beg, end) {}
|
||||
@ -60,7 +60,7 @@ public:
|
||||
class VectorGLushort: public std::vector<GLushort>
|
||||
{
|
||||
typedef std::vector<value_type> vector_type;
|
||||
public:
|
||||
public:
|
||||
VectorGLushort(): vector_type() {}
|
||||
VectorGLushort(const VectorGLushort ©): vector_type(copy) {}
|
||||
VectorGLushort(GLushort* beg, GLushort* end): vector_type(beg, end) {}
|
||||
@ -79,30 +79,73 @@ public:
|
||||
|
||||
// **************************************************************************
|
||||
|
||||
class State;
|
||||
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.
|
||||
*/
|
||||
class PrimitiveFunctor
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~PrimitiveFunctor() {}
|
||||
|
||||
/** Sets the array of vertices used to describe the primitives. Somehow
|
||||
* mimics the OpenGL \c glVertexPointer() function.
|
||||
*/
|
||||
virtual void setVertexArray(unsigned int count,const Vec2* 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 Vec3* 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 Vec4* vertices) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glDrawArrays() function.
|
||||
virtual void drawArrays(GLenum mode,GLint first,GLsizei count) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glDrawElements() function.
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glDrawElements() function.
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glDrawElements() function.
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glBegin() function.
|
||||
virtual void begin(GLenum mode) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glVertex() "family of functions".
|
||||
virtual void vertex(const Vec2& vert) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glVertex() "family of functions".
|
||||
virtual void vertex(const Vec3& vert) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glVertex() "family of functions".
|
||||
virtual void vertex(const Vec4& vert) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glVertex() "family of functions".
|
||||
virtual void vertex(float x,float y) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glVertex() "family of functions".
|
||||
virtual void vertex(float x,float y,float z) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glVertex() "family of functions".
|
||||
virtual void vertex(float x,float y,float z,float w) = 0;
|
||||
|
||||
/// Mimics the OpenGL \c glEnd() function.
|
||||
virtual void end() = 0;
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,21 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
|
||||
/** Provides access to the triangles that compose an \c osg::Drawable. If the \c
|
||||
* Drawable is not composed of triangles, the \c TriangleFunctor will convert
|
||||
* the primitives to triangles whenever possible.
|
||||
* <p>Notice that \c TriangleFunctor is a class template, and that it inherits
|
||||
* from its template parameter \c T. This template parameter must implement
|
||||
* <tt>T::operator() (const osg::Vec3 v1, const osg::Vec3 v2, const osg::Vec3
|
||||
* v3, bool treatVertexDataAsTemporary)</tt>, which will be called for every
|
||||
* triangle when the functor is applied to a \c Drawable. Parameters \c v1, \c
|
||||
* v2, and \c v3 are the triangle vertices. The fourth parameter, \c
|
||||
* treatVertexDataAsTemporary, indicates whether these vertices are coming from
|
||||
* a "real" vertex array, or from a temporary vertex array, created by the \c
|
||||
* TriangleFunctor from some other geometry representation.
|
||||
* @see \c PrimitiveFunctor for general usage hints.
|
||||
*/
|
||||
template<class T>
|
||||
class TriangleFunctor : public PrimitiveFunctor, public T
|
||||
{
|
||||
@ -31,13 +46,13 @@ public:
|
||||
_modeCache=0;
|
||||
_treatVertexDataAsTemporary=false;
|
||||
}
|
||||
|
||||
|
||||
virtual ~TriangleFunctor() {}
|
||||
|
||||
|
||||
void setTreatVertexDataAsTemporary(bool treatVertexDataAsTemporary) { _treatVertexDataAsTemporary=treatVertexDataAsTemporary; }
|
||||
bool getTreatVertexDataAsTemporary() const { return _treatVertexDataAsTemporary; }
|
||||
|
||||
virtual void setVertexArray(unsigned int,const Vec2*)
|
||||
virtual void setVertexArray(unsigned int,const Vec2*)
|
||||
{
|
||||
notify(WARN)<<"Triangle Functor does not support Vec2* vertex arrays"<<std::endl;
|
||||
}
|
||||
@ -57,7 +72,7 @@ public:
|
||||
virtual void drawArrays(GLenum mode,GLint first,GLsizei count)
|
||||
{
|
||||
if (_vertexArrayPtr==0 && count==0) return;
|
||||
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case(GL_TRIANGLES):
|
||||
@ -117,7 +132,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices)
|
||||
{
|
||||
if (indices==0 || count==0) return;
|
||||
@ -319,7 +334,7 @@ public:
|
||||
// can't be converted into to triangles.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user