Browse Source

Minor refactoring, documentation.

vectorfields
Vladimír Vondruš 16 years ago
parent
commit
2e14f57560
  1. 4
      src/IndexedMesh.cpp
  2. 1
      src/Math/Matrix.h
  3. 1
      src/Math/Vector.h
  4. 6
      src/Mesh.cpp
  5. 11
      src/Mesh.h

4
src/IndexedMesh.cpp

@ -41,10 +41,10 @@ void IndexedMesh::draw() {
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
glVertexAttribIPointer(ait->location, ait->size, ait->type, ait->stride, ait->pointer);
glVertexAttribIPointer(ait->attribute, ait->size, ait->type, ait->stride, ait->pointer);
break;
default:
glVertexAttribPointer(ait->location, ait->size, ait->type, GL_FALSE, ait->stride, ait->pointer);
glVertexAttribPointer(ait->attribute, ait->size, ait->type, GL_FALSE, ait->stride, ait->pointer);
}
/* Unbind buffer */

1
src/Math/Matrix.h

@ -102,6 +102,7 @@ template<class T, size_t size> class Matrix {
/** @brief Equality operator */
inline bool operator==(const Matrix<T, size>& other) const {
/** @bug NaN comparisons! */
for(size_t row = 0; row != size; ++row) {
for(size_t col = 0; col != size; ++col)
if(std::abs(at(row, col) - other.at(row, col)) >= EPSILON) return false;

1
src/Math/Vector.h

@ -87,6 +87,7 @@ template<class T, size_t size> class Vector {
/** @brief Equality operator */
inline bool operator==(const Vector<T, size>& other) const {
/** @bug NaN comparisons! */
for(size_t pos = 0; pos != size; ++pos)
if(std::abs(at(pos) - other.at(pos)) >= EPSILON) return false;

6
src/Mesh.cpp

@ -59,10 +59,10 @@ void Mesh::draw() {
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
glVertexAttribIPointer(ait->location, ait->size, ait->type, ait->stride, ait->pointer);
glVertexAttribIPointer(ait->attribute, ait->size, ait->type, ait->stride, ait->pointer);
break;
default:
glVertexAttribPointer(ait->location, ait->size, ait->type, GL_FALSE, ait->stride, ait->pointer);
glVertexAttribPointer(ait->attribute, ait->size, ait->type, GL_FALSE, ait->stride, ait->pointer);
}
/* Unbind buffer */
@ -129,7 +129,7 @@ void Mesh::bindAttribute(Buffer* buffer, GLuint attribute, GLint size, GLenum ty
if(found == _buffers.end()) return;
Attribute a;
a.location = attribute;
a.attribute = attribute;
a.size = size;
a.type = type;
a.stride = 0;

11
src/Mesh.h

@ -134,12 +134,13 @@ class Mesh {
virtual void draw();
protected:
/** @brief Vertex attribute */
struct Attribute {
GLuint location;
GLint size;
GLenum type;
GLsizei stride;
const GLvoid* pointer;
GLuint attribute; /**< @brief Attribute ID */
GLint size; /**< @brief How many items of @c type are in the attribute */
GLenum type; /**< @brief Attribute item type */
GLsizei stride; /**< @brief Distance of two adjacent attributes of this type in interleaved buffer */
const GLvoid* pointer; /**< @brief Pointer to first attribute of this type in the buffer */
};
/**

Loading…
Cancel
Save