Browse Source

Mesh: set VAO id to 0 when the extension is not available.

Also expect this case in test.
pull/51/head
Vladimír Vondruš 13 years ago
parent
commit
64a1d6be88
  1. 2
      src/Mesh.cpp
  2. 2
      src/Mesh.h
  3. 31
      src/Test/MeshGLTest.cpp

2
src/Mesh.cpp

@ -270,7 +270,7 @@ void Mesh::initializeContextBasedFunctionality(Context& context) {
#endif #endif
} }
void Mesh::createImplementationDefault() {} void Mesh::createImplementationDefault() { _id = 0; }
void Mesh::createImplementationVAO() { void Mesh::createImplementationVAO() {
/** @todo Get some extension wrangler instead to avoid linker errors to glGenVertexArrays() on ES2 */ /** @todo Get some extension wrangler instead to avoid linker errors to glGenVertexArrays() on ES2 */

2
src/Mesh.h

@ -411,7 +411,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* @brief OpenGL mesh ID * @brief OpenGL mesh ID
* *
* If @extension{APPLE,vertex_array_object} is not available, returns * If @extension{APPLE,vertex_array_object} is not available, returns
* 0. * `0`.
*/ */
GLuint id() const { return _id; } GLuint id() const { return _id; }

31
src/Test/MeshGLTest.cpp

@ -53,7 +53,15 @@ void MeshGLTest::construct() {
const Mesh mesh; const Mesh mesh;
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_VERIFY(mesh.id() > 0);
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::APPLE::vertex_array_object>())
#elif defined(MAGNUM_TARGET_GLES2)
if(Context::current()->isExtensionSupported<Extensions::GL::OES::vertex_array_object>())
#endif
{
CORRADE_VERIFY(mesh.id() > 0);
}
} }
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
@ -72,7 +80,15 @@ void MeshGLTest::constructMove() {
const Int id = a.id(); const Int id = a.id();
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_VERIFY(id > 0);
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::APPLE::vertex_array_object>())
#elif defined(MAGNUM_TARGET_GLES2)
if(Context::current()->isExtensionSupported<Extensions::GL::OES::vertex_array_object>())
#endif
{
CORRADE_VERIFY(id > 0);
}
Mesh b(std::move(a)); Mesh b(std::move(a));
@ -84,7 +100,16 @@ void MeshGLTest::constructMove() {
c = std::move(b); c = std::move(b);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_VERIFY(cId > 0);
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::APPLE::vertex_array_object>())
#elif defined(MAGNUM_TARGET_GLES2)
if(Context::current()->isExtensionSupported<Extensions::GL::OES::vertex_array_object>())
#endif
{
CORRADE_VERIFY(cId > 0);
}
CORRADE_COMPARE(b.id(), cId); CORRADE_COMPARE(b.id(), cId);
CORRADE_COMPARE(c.id(), id); CORRADE_COMPARE(c.id(), id);
} }

Loading…
Cancel
Save