#include <sglInterleavedGeometry.hpp>
Inheritance diagram for sglInterleavedGeometry::
Public Methods | |
sglInterleavedGeometry () | |
virtual | ~sglInterleavedGeometry () |
virtual AAEnum | getAAType () const |
void | setGLPrimType (GLenum prim_type) |
GLenum | getGLPrimType () const |
virtual sglStats::PrimEnum | getPrimType () const |
virtual unsigned int | getPrimSize () const |
unsigned int | getNumPrims () const |
void | setNumPrims (unsigned int num) |
unsigned int* | getPrimLengths () const |
void | setPrimLengths (unsigned int *lengths) |
void | setInterleavedArray (GLenum format, void *array, GLsizei stride=0) |
void | getInterleavedArray (GLenum *format, void **array, GLsizei *stride) |
virtual bool | isValid () const |
virtual void | drawGeometry (const vector< sglTexCoords > &tex_coords) const |
virtual void | addStats (sglStats &stats) const |
virtual void | printInfo (ostream &ostrm, const char *indent_string) const |
Protected Methods | |
virtual bool | computeBounds () |
\item the primitive type by calling sglInterleavedGeometry::setGLPrimType(..).
\item the number of primitives by calling sglInterleavedGeometry::setNumPrims(..).
\item the lengths array by calling sglInterleavedGeometry::setPrimLengths(..). \end{itemize}
For the first step the format of the interleaved geometry must be one of the 14 formats in the OpenGL specification. When using this class with the default stride of zero, the user can allocate an array of one of the helper structs provided with this class. The following is a list of these structs and the corresponding OpenGL token that is needed in the call to sglInterleavedGeometry::setInterleavedArray(..):
\begin{verbatim} OpenGL format SGL struct name ------------------ --------------------- GL_V2F sglVec2f GL_V3F sglVec3f GL_C4UB_V2F sglC4ubV2fStruct GL_C4UB_V3F sglC4ubV3fStruct GL_C3F_V3F sglC3fV3fStruct GL_N3F_V3F sglN3fV3fStruct GL_C4F_N3F_V3F sglC4fN3fV3fStruct GL_T2F_V3F sglT2fV3fStruct GL_T4F_V4F sglT4fV4fStruct GL_T2F_C4UB_V3F sglT2fC4ubV3fStruct GL_T2F_C3F_V3F sglT2fC3fV3fStruct GL_T2F_N3F_V3F sglT2fN3fV3fStruct GL_T2F_C4F_N3F_V3F sglT2fC4fN3fV3fStruct GL_T4F_C4F_N3F_V4F sglT4fC4fN3fV4fStruct \end{verbatim}
Once the array is allocated and the values are set the the sglInterleavedGeometry::setInterleavedArray(...) is called to pass a pointer to this array into the object. Note: the array will be used directly by the class; however, the array will not get destructed with the class is deleted (this is the user's responsibility). With the call to setInterleavedArray(...), the user must also specify the corresponding OpenGL format token, and can optionally specify the stride between elements in the array (it defaults to zero).
The second step is to specify the primitive type from one of the following OpenGL tokens: GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON.
This class must support the strip, fan and polygon primitives which require the lengths array. Because of this all primitive types require a lengths array. For primitive types that are NOT strip, fan, or polygon types a lengths array with a single element is all that is required and that value is set to the number of vertices present in the interleaved array. For this setup the user must call sglInterleavedArrays::setNumPrims(1).
For strip, fan, and polygon types the number of primitives and the lengths array behaves just like the equivalent sglGeoSet subclasses above.
There is no indexing supported for this class.
This class imposes some restrictions on the base sglDrawable class API. While multiple states can be associated with this geometry type. The individual texture coordinates in the StateElement struct will be ignored, as the texture coordinates are stored in the respective interleaved array formats and cannot be switched out.
{\bf Example:} \begin{verbatim} sglVec3f color[3]; color[0].set(1.0f, 0.6f, 0.6f); color[1].set(0.6f, 1.0f, 0.6f); color[2].set(0.6f, 0.6f, 1.0f);
interleaved 3 component color and vertices sglC3fV3fStruct *array = new sglC3fV3fStruct[6];
unsigned int *lengths = new unsigned int[1]; lengths[0] = 6;
unsigned int index = 0; for (unsigned int ix=0; ix<3; ix++) { array[index].vertex.set(ix*8.0f - 8.0f, 0.0f, 8.0f); array[index].color = color[ix]; index++;
array[index].vertex.set(ix*8.0f - 8.0f, 0.0f, -8.0f); array[index].color = color[ix]; index++; }
sglInterleavedGeometry *gset = new sglInterleavedGeometry(); gset->setNumPrims(1); gset->setPrimLengths(lengths); gset->setGLPrimType(GL_QUAD_STRIP); gset->setInterleavedArray(GL_C3F_V3F, array, 0);
This object is too small to want a display list. gset->enableDisplayList(false); \end{verbatim}
Definition at line 149 of file sglInterleavedGeometry.hpp.
|
get/set the type of primitive prim_type is one of GL_LINES, GL_TRIANGLE_STRIP, etc |
|
get/set the number of primitives in this geometry. This has a slightly different meaning than in sglGeoSet and sglGeoStripSet. This will be used in conjunction with the lengths array regardless of whether a strip primitive is specified or not. Definition at line 176 of file sglInterleavedGeometry.hpp. |
|
get/set the lengths array (for strip and poly primitives only).
Definition at line 181 of file sglInterleavedGeometry.hpp. |
|
specify the geometry attribute array: format is one of the interleaved formats listed above...if a packed array of the one of the sgl types is used to organize the data then the stride is zero if every element is desired. |
|
tex_coords not used here.
|
|
Add this drawable's stats to the given sglStats.
Reimplemented from sglDrawable. |
|
Output the state of this node to the specified ostream.
Reimplemented from sglDrawable. |
|
Compute the bounding box for this geometry and fill in the member variable, m_bbox, in this class.
Reimplemented from sglDrawable. |