From 64a1d6be8877b0256fe4b077eb387ace0f691e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 29 Dec 2013 18:50:03 +0100 Subject: [PATCH] Mesh: set VAO id to 0 when the extension is not available. Also expect this case in test. --- src/Mesh.cpp | 2 +- src/Mesh.h | 2 +- src/Test/MeshGLTest.cpp | 31 ++++++++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/Mesh.cpp b/src/Mesh.cpp index dacc794e5..8fa370336 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -270,7 +270,7 @@ void Mesh::initializeContextBasedFunctionality(Context& context) { #endif } -void Mesh::createImplementationDefault() {} +void Mesh::createImplementationDefault() { _id = 0; } void Mesh::createImplementationVAO() { /** @todo Get some extension wrangler instead to avoid linker errors to glGenVertexArrays() on ES2 */ diff --git a/src/Mesh.h b/src/Mesh.h index 6d41aba32..893615125 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -411,7 +411,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @brief OpenGL mesh ID * * If @extension{APPLE,vertex_array_object} is not available, returns - * 0. + * `0`. */ GLuint id() const { return _id; } diff --git a/src/Test/MeshGLTest.cpp b/src/Test/MeshGLTest.cpp index a20a98081..2596a56db 100644 --- a/src/Test/MeshGLTest.cpp +++ b/src/Test/MeshGLTest.cpp @@ -53,7 +53,15 @@ void MeshGLTest::construct() { const Mesh mesh; MAGNUM_VERIFY_NO_ERROR(); - CORRADE_VERIFY(mesh.id() > 0); + + #ifndef MAGNUM_TARGET_GLES + if(Context::current()->isExtensionSupported()) + #elif defined(MAGNUM_TARGET_GLES2) + if(Context::current()->isExtensionSupported()) + #endif + { + CORRADE_VERIFY(mesh.id() > 0); + } } MAGNUM_VERIFY_NO_ERROR(); @@ -72,7 +80,15 @@ void MeshGLTest::constructMove() { const Int id = a.id(); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_VERIFY(id > 0); + + #ifndef MAGNUM_TARGET_GLES + if(Context::current()->isExtensionSupported()) + #elif defined(MAGNUM_TARGET_GLES2) + if(Context::current()->isExtensionSupported()) + #endif + { + CORRADE_VERIFY(id > 0); + } Mesh b(std::move(a)); @@ -84,7 +100,16 @@ void MeshGLTest::constructMove() { c = std::move(b); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_VERIFY(cId > 0); + + #ifndef MAGNUM_TARGET_GLES + if(Context::current()->isExtensionSupported()) + #elif defined(MAGNUM_TARGET_GLES2) + if(Context::current()->isExtensionSupported()) + #endif + { + CORRADE_VERIFY(cId > 0); + } + CORRADE_COMPARE(b.id(), cId); CORRADE_COMPARE(c.id(), id); }