Browse Source

GL: construct simple Mesh and MeshView members in-class.

Better for maintenance, worse for header pollution.
pull/255/head
Vladimír Vondruš 8 years ago
parent
commit
fdbd90a327
  1. 19
      src/Magnum/GL/Mesh.cpp
  2. 13
      src/Magnum/GL/Mesh.h
  3. 18
      src/Magnum/GL/MeshView.h

19
src/Magnum/GL/Mesh.cpp

@ -204,26 +204,11 @@ std::size_t Mesh::indexSize(Magnum::MeshIndexType type) {
} }
#endif #endif
Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectFlag::DeleteOnDestruction}, _count{0}, _baseVertex{0}, _instanceCount{1}, Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectFlag::DeleteOnDestruction} {
#ifndef MAGNUM_TARGET_GLES
_baseInstance{0},
#endif
#ifndef MAGNUM_TARGET_GLES2
_indexStart(0), _indexEnd(0),
#endif
_indexOffset(0), _indexType(MeshIndexType::UnsignedInt), _indexBuffer(nullptr)
{
(this->*Context::current().state().mesh->createImplementation)(); (this->*Context::current().state().mesh->createImplementation)();
} }
Mesh::Mesh(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction}, _count{0}, _baseVertex{0}, _instanceCount{1}, Mesh::Mesh(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction} {}
#ifndef MAGNUM_TARGET_GLES
_baseInstance{0},
#endif
#ifndef MAGNUM_TARGET_GLES2
_indexStart(0), _indexEnd(0),
#endif
_indexOffset(0), _indexType(MeshIndexType::UnsignedInt), _indexBuffer(nullptr) {}
Mesh::~Mesh() { Mesh::~Mesh() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */

13
src/Magnum/GL/Mesh.h

@ -1031,19 +1031,20 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
#endif #endif
#endif #endif
/* _id, _primitive, _flags set from constructors */
GLuint _id; GLuint _id;
MeshPrimitive _primitive; MeshPrimitive _primitive;
ObjectFlags _flags; ObjectFlags _flags;
Int _count, _baseVertex, _instanceCount; Int _count{}, _baseVertex{}, _instanceCount{1};
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
UnsignedInt _baseInstance; UnsignedInt _baseInstance{};
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
UnsignedInt _indexStart, _indexEnd; UnsignedInt _indexStart{}, _indexEnd{};
#endif #endif
GLintptr _indexOffset; GLintptr _indexOffset{};
MeshIndexType _indexType; MeshIndexType _indexType{};
Buffer* _indexBuffer; Buffer* _indexBuffer{};
/* Storage for std::vector with attribute layout / attribute buffer /* Storage for std::vector with attribute layout / attribute buffer
instances. 4 pointers should be one pointer more than enough. */ instances. 4 pointers should be one pointer more than enough. */

18
src/Magnum/GL/MeshView.h

@ -286,25 +286,17 @@ class MAGNUM_GL_EXPORT MeshView {
std::reference_wrapper<Mesh> _original; std::reference_wrapper<Mesh> _original;
Int _count, _baseVertex, _instanceCount; Int _count{}, _baseVertex{}, _instanceCount{1};
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
UnsignedInt _baseInstance; UnsignedInt _baseInstance{};
#endif #endif
GLintptr _indexOffset; GLintptr _indexOffset{};
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
UnsignedInt _indexStart, _indexEnd; UnsignedInt _indexStart{}, _indexEnd{};
#endif #endif
}; };
inline MeshView::MeshView(Mesh& original): _original(original), _count(0), _baseVertex(0), _instanceCount{1}, inline MeshView::MeshView(Mesh& original): _original{original} {}
#ifndef MAGNUM_TARGET_GLES
_baseInstance{0},
#endif
_indexOffset(0)
#ifndef MAGNUM_TARGET_GLES2
, _indexStart(0), _indexEnd(0)
#endif
{}
inline MeshView& MeshView::setIndexRange(Int first, UnsignedInt start, UnsignedInt end) { inline MeshView& MeshView::setIndexRange(Int first, UnsignedInt start, UnsignedInt end) {
setIndexRange(first); setIndexRange(first);

Loading…
Cancel
Save