[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/libs/kgllib/extras/kgllib
From: Rivo Laks <rivolaks () hot ! ee>
Date: 2008-02-05 18:28:02
Message-ID: 1202236082.050369.9799.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 771316 by rivol:
- setBatchType() method
- Add apidox
M +5 -0 batch.cpp
M +81 -1 batch.h
--- trunk/playground/libs/kgllib/extras/kgllib/batch.cpp #771315:771316
@@ -120,6 +120,11 @@
}
}
+void Batch::setBatchType(Batch::BatchType type)
+{
+ mType = type;
+}
+
void Batch::render(GLenum mode)
{
if (mDirty) {
--- trunk/playground/libs/kgllib/extras/kgllib/batch.h #771315:771316
@@ -26,31 +26,111 @@
namespace KGLLib
{
+/**
+ * @brief A set of geometry.
+ *
+ * Batch class contains geometry data which is necessary for rendering
+ * something. This data can include vertices, normals, texture coordinates and
+ * vertex colors.
+ *
+ * Batch object can automatically choose appropriate rendering mode depending
+ * on your geometry. Small batches can be rendered in immediate mode while
+ * bigger ones will automatically use VBOs (vertex buffer objects) for
+ * improved performance.
+ *
+ * To use it, you need to construct the Batch object, set the necessary arrays
+ * and then call the render() method:
+ * @code
+ * // Create the Batch object
+ * Batch* b = new Batch();
+ * b->setVertices(myvertices);
+ * b->setTexCoords(mytexcoords);
+ * ...
+ * // In your rendering loop:
+ * b->render(GL_TRIANGLES);
+ * // some textured triangles will be rendered.
+ * @endcode
+ *
+ * @see Mesh
+ **/
class KGLLIB_EXTRAS_EXPORT Batch
{
public:
- enum BatchType { Auto, Plain, Array, VBO };
+ /**
+ * Specifies which method is used to render the geometry.
+ **/
+ enum BatchType {
+ Auto, /**< Mode is chosen automatically, depending on the rendered geomentry */
+ Plain, /**< Immediate mode (i.e. glVertex(), glNormal() etc calls) */
+ Array, /**< Vertex arrays */
+ VBO /**< VBOs (vertex buffer objects) */
+ };
+ /**
+ * Constructs new Batch object.
+ * You will need to set at least vertices array and vertex count before the
+ * batch can be rendered.
+ **/
Batch();
virtual ~Batch();
+ /**
+ * Renders the batch, using specified primitive mode (e.g. GL_TRIANGLES).
+ **/
virtual void render(GLenum mode);
+ /**
+ * Set the number of vertices in the batch to @p count.
+ * Each specified array must contain at least @p count entries (if they
+ * contain more, then the remaining ones will be unused).
+ **/
void setVertexCount(int count);
+ /**
+ * Sets the vertices array to @p vertices.
+ **/
void setVertices(Eigen::Vector2f* vertices) { setVertices(vertices, 2); }
void setVertices(Eigen::Vector3f* vertices) { setVertices(vertices, 3); }
void setVertices(Eigen::Vector4f* vertices) { setVertices(vertices, 4); }
+ /**
+ * Sets the per-vertex colors array to @p colors.
+ **/
void setColors(Eigen::Vector3f* colors) { setColors(colors, 3); }
void setColors(Eigen::Vector4f* colors) { setColors(colors, 4); }
+ /**
+ * Sets the normals array to @p normals.
+ **/
void setNormals(Eigen::Vector3f* normals);
+ /**
+ * Sets the texture coordinates array to @p texcoords.
+ **/
void setTexcoords(float* texcoords) { setTexcoords(texcoords, 1); }
void setTexcoords(Eigen::Vector2f* texcoords) { setTexcoords(texcoords, 2); }
void setTexcoords(Eigen::Vector3f* texcoords) { setTexcoords(texcoords, 3); }
void setTexcoords(Eigen::Vector4f* texcoords) { setTexcoords(texcoords, 4); }
+ /**
+ * Sets the indices array to @p indices. The array must contain at least
+ * @p count entries (if it contains more, then the remaining ones will be
+ * unused).
+ **/
void setIndices(unsigned int* indices, int count);
+ /**
+ * @return current rendering method of this Batch.
+ **/
BatchType batchType() const;
+ /**
+ * Sets the rendering method to @p type.
+ * The default method is @ref Auto.
+ **/
+ void setBatchType(BatchType type);
+ /**
+ * Updates the internal data if something has changed. In VBO mode it
+ * copies the data into videocard memory.
+ * This method is automatically called from @ref render() in case something
+ * has changed, but you can also call it manually to remove the delay at
+ * first rendering.
+ **/
virtual void update();
protected:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic