diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 7224c78df..aa8c7eec0 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -93,6 +93,9 @@ Mesh::Mesh(MeshPrimitive primitive): _primitive(primitive), _vertexCount(0), _in } Mesh::~Mesh() { + /* Moved out, nothing to do */ + if(!_id) return; + /* Remove current vao from the state */ GLuint& current = Context::current()->state().mesh->currentVAO; if(current == _id) current = 0; @@ -278,7 +281,7 @@ void Mesh::destroyImplementationDefault() {} void Mesh::destroyImplementationVAO() { /** @todo Get some extension wrangler instead to avoid linker errors to glDeleteVertexArrays() on ES2 */ #ifndef MAGNUM_TARGET_GLES2 - if(_id) glDeleteVertexArrays(1, &_id); + glDeleteVertexArrays(1, &_id); #endif } diff --git a/src/Test/MeshGLTest.cpp b/src/Test/MeshGLTest.cpp index 6efd4dc20..62215d181 100644 --- a/src/Test/MeshGLTest.cpp +++ b/src/Test/MeshGLTest.cpp @@ -33,11 +33,57 @@ class MeshGLTest: public AbstractOpenGLTester { public: explicit MeshGLTest(); + void construct(); + void constructCopy(); + void constructMove(); + void label(); }; MeshGLTest::MeshGLTest() { - addTests({&MeshGLTest::label}); + addTests({&MeshGLTest::construct, + &MeshGLTest::constructCopy, + &MeshGLTest::constructMove, + + &MeshGLTest::label}); +} + +void MeshGLTest::construct() { + { + const Mesh mesh; + + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_VERIFY(mesh.id() > 0); + } + + MAGNUM_VERIFY_NO_ERROR(); +} + +void MeshGLTest::constructCopy() { + CORRADE_VERIFY(!(std::is_constructible{})); + CORRADE_VERIFY(!(std::is_assignable{})); +} + +void MeshGLTest::constructMove() { + Mesh a; + const Int id = a.id(); + + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_VERIFY(id > 0); + + Mesh b(std::move(a)); + + CORRADE_COMPARE(a.id(), 0); + CORRADE_COMPARE(b.id(), id); + + Mesh c; + const Int cId = c.id(); + c = std::move(b); + + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_VERIFY(cId > 0); + CORRADE_COMPARE(b.id(), cId); + CORRADE_COMPARE(c.id(), id); } void MeshGLTest::label() {