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
Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectFlag::DeleteOnDestruction}, _count{0}, _baseVertex{0}, _instanceCount{1},
#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(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectFlag::DeleteOnDestruction} {
(this->*Context::current().state().mesh->createImplementation)();
}
Mesh::Mesh(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction}, _count{0}, _baseVertex{0}, _instanceCount{1},
#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(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction} {}
Mesh::~Mesh() {
/* 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
/* _id, _primitive, _flags set from constructors */
GLuint _id;
MeshPrimitive _primitive;
ObjectFlags _flags;
Int _count, _baseVertex, _instanceCount;
Int _count{}, _baseVertex{}, _instanceCount{1};
#ifndef MAGNUM_TARGET_GLES
UnsignedInt _baseInstance;
UnsignedInt _baseInstance{};
#endif
#ifndef MAGNUM_TARGET_GLES2
UnsignedInt _indexStart, _indexEnd;
UnsignedInt _indexStart{}, _indexEnd{};
#endif
GLintptr _indexOffset;
MeshIndexType _indexType;
Buffer* _indexBuffer;
GLintptr _indexOffset{};
MeshIndexType _indexType{};
Buffer* _indexBuffer{};
/* Storage for std::vector with attribute layout / attribute buffer
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;
Int _count, _baseVertex, _instanceCount;
Int _count{}, _baseVertex{}, _instanceCount{1};
#ifndef MAGNUM_TARGET_GLES
UnsignedInt _baseInstance;
UnsignedInt _baseInstance{};
#endif
GLintptr _indexOffset;
GLintptr _indexOffset{};
#ifndef MAGNUM_TARGET_GLES2
UnsignedInt _indexStart, _indexEnd;
UnsignedInt _indexStart{}, _indexEnd{};
#endif
};
inline MeshView::MeshView(Mesh& original): _original(original), _count(0), _baseVertex(0), _instanceCount{1},
#ifndef MAGNUM_TARGET_GLES
_baseInstance{0},
#endif
_indexOffset(0)
#ifndef MAGNUM_TARGET_GLES2
, _indexStart(0), _indexEnd(0)
#endif
{}
inline MeshView::MeshView(Mesh& original): _original{original} {}
inline MeshView& MeshView::setIndexRange(Int first, UnsignedInt start, UnsignedInt end) {
setIndexRange(first);

Loading…
Cancel
Save