From Leandro Motta Barros, documentation additions to PrimitiveSet & TriangleFunctor.

This commit is contained in:
Robert Osfield 2006-06-26 09:56:52 +00:00
parent 3b499341ed
commit f8644d08e5
2 changed files with 68 additions and 10 deletions

View File

@ -81,28 +81,71 @@ 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 class PrimitiveFunctor
{ {
public: public:
virtual ~PrimitiveFunctor() {} 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; 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; 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; 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; 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; 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; 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; virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) = 0;
/// Mimics the OpenGL \c glBegin() function.
virtual void begin(GLenum mode) = 0; virtual void begin(GLenum mode) = 0;
/// Mimics the OpenGL \c glVertex() "family of functions".
virtual void vertex(const Vec2& vert) = 0; virtual void vertex(const Vec2& vert) = 0;
/// Mimics the OpenGL \c glVertex() "family of functions".
virtual void vertex(const Vec3& vert) = 0; virtual void vertex(const Vec3& vert) = 0;
/// Mimics the OpenGL \c glVertex() "family of functions".
virtual void vertex(const Vec4& vert) = 0; virtual void vertex(const Vec4& vert) = 0;
/// Mimics the OpenGL \c glVertex() "family of functions".
virtual void vertex(float x,float y) = 0; 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; 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; virtual void vertex(float x,float y,float z,float w) = 0;
/// Mimics the OpenGL \c glEnd() function.
virtual void end() = 0; virtual void end() = 0;
}; };

View File

@ -19,6 +19,21 @@
namespace osg { 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> template<class T>
class TriangleFunctor : public PrimitiveFunctor, public T class TriangleFunctor : public PrimitiveFunctor, public T
{ {