Browse Source

Getter for index count and type in IndexedMesh.

pull/279/head
Vladimír Vondruš 16 years ago
parent
commit
46e6af1a91
  1. 2
      src/IndexedMesh.cpp
  2. 20
      src/IndexedMesh.h

2
src/IndexedMesh.cpp

@ -53,7 +53,7 @@ void IndexedMesh::draw() {
/* Bind index array, draw the elements and unbind */ /* Bind index array, draw the elements and unbind */
_indexBuffer.bind(); _indexBuffer.bind();
glDrawElements(primitive(), indexCount, indexType, 0); glDrawElements(primitive(), _indexCount, _indexType, 0);
_indexBuffer.unbind(); _indexBuffer.unbind();
/* Disable vertex arrays for all attributes */ /* Disable vertex arrays for all attributes */

20
src/IndexedMesh.h

@ -33,13 +33,19 @@ class IndexedMesh: public Mesh {
public: public:
/** /**
* @brief Constructor * @brief Constructor
* @param _primitive Primitive type * @param primitive Primitive type
* @param _vertexCount Count of unique vertices * @param vertexCount Count of unique vertices
* @param _indexCount Count of indices * @param indexCount Count of indices
* @param _indexType Type of indices (GL_UNSIGNED_BYTE, * @param indexType Type of indices (GL_UNSIGNED_BYTE,
* GL_UNSIGNED_SHORT or GL_UNSIGNED_INT) * GL_UNSIGNED_SHORT or GL_UNSIGNED_INT)
*/ */
inline IndexedMesh(Primitive _primitive, GLsizei _vertexCount, GLsizei _indexCount, GLenum _indexType = GL_UNSIGNED_SHORT): Mesh(_primitive, _vertexCount), _indexBuffer(Buffer::ElementArrayBuffer), indexCount(_indexCount), indexType(_indexType) {} inline IndexedMesh(Primitive primitive, GLsizei vertexCount, GLsizei indexCount, GLenum indexType = GL_UNSIGNED_SHORT): Mesh(primitive, vertexCount), _indexBuffer(Buffer::ElementArrayBuffer), _indexCount(indexCount), _indexType(indexType) {}
/** @brief Index count */
inline GLsizei indexCount() const { return _indexCount; }
/** @brief Index type */
inline GLenum indexType() const { return _indexType; }
/** /**
* @brief Index buffer * @brief Index buffer
@ -59,8 +65,8 @@ class IndexedMesh: public Mesh {
private: private:
Buffer _indexBuffer; Buffer _indexBuffer;
GLsizei indexCount; GLsizei _indexCount;
GLenum indexType; GLenum _indexType;
}; };
} }

Loading…
Cancel
Save