diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 9e2fc5ad5..93ec8687c 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -47,20 +47,19 @@ following: @subsection opengl-support-30 OpenGL 3.0 -@todo Replace @extension{APPLE,vertex_array_object} with ARB version (we use only ARB functions without APPLE fallback) @todo @extension{EXT,texture_array} overlaps with @extension{ARB,framebuffer_object} @todo Add @extension{ARB,depth_buffer_float} and implement the missing @fn_gl{DepthRange} function, but keep (and implement) @extension{NV,depth_buffer_float} for non-linear depth buffer @todo @extension{ARB,half_float_pixel}, @extension{ARB,half_float_vertex}? %Extension | Status -------------------------------------------- | ------ -@extension{APPLE,vertex_array_object} | done (GL 3.0 subset) @extension{ARB,map_buffer_range} | done @extension{ARB,color_buffer_float} | | @extension{ARB,half_float_pixel} | done @extension{ARB,texture_float} | done @extension{ARB,depth_buffer_float} | done @extension{ARB,texture_rg} | done +@extension{ARB,vertex_array_object} | done @extension{ARB,framebuffer_object} | done @extension{EXT,gpu_shader4} | done @extension{EXT,packed_float} | done diff --git a/doc/opengl.dox b/doc/opengl.dox index 4338b6abf..babe2c6c6 100644 --- a/doc/opengl.dox +++ b/doc/opengl.dox @@ -43,7 +43,7 @@ The engine requires at least OpenGL 2.1 or OpenGL ES 2.0, but some specific functionality has greater requirements. Following are lists of features requiring specific OpenGL version. In most cases it is also specified which extension is required, so if given hardware supports required extension, it -doesn't need to have required OpenGL version too (e.g. `APPLE_vertex_array_object` +doesn't need to have required OpenGL version too (e.g. `ARB_vertex_array_object` is supported on older Intel GPUs even if they are capable of OpenGL 2.1 only). - @subpage requires-gl30 diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 79a60887c..81d8d783e 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -72,13 +72,13 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,debug_marker), _extension(GL,GREMEDY,string_marker)}; static const std::vector extensions300{ - _extension(GL,APPLE,vertex_array_object), _extension(GL,ARB,map_buffer_range), _extension(GL,ARB,color_buffer_float), _extension(GL,ARB,half_float_pixel), _extension(GL,ARB,texture_float), _extension(GL,ARB,depth_buffer_float), _extension(GL,ARB,texture_rg), + _extension(GL,ARB,vertex_array_object), _extension(GL,ARB,framebuffer_object), _extension(GL,EXT,gpu_shader4), _extension(GL,EXT,packed_float), diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index cd18c6842..9032773cf 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -73,8 +73,6 @@ namespace GL { namespace AMD { _extension(GL,AMD,vertex_shader_layer, GL210, None) // #417 _extension(GL,AMD,shader_trinary_minmax, GL210, None) // #428 - } namespace APPLE { - _extension(GL,APPLE,vertex_array_object, GL210, GL300) // #273 } namespace ARB { _extension(GL,ARB,texture_rectangle, GL210, GL310) // #38 _extension(GL,ARB,color_buffer_float, GL210, GL300) // #39 @@ -88,6 +86,7 @@ namespace GL { _extension(GL,ARB,map_buffer_range, GL210, GL300) // #50 _extension(GL,ARB,texture_buffer_object, GL210, GL310) // #51 _extension(GL,ARB,texture_rg, GL210, GL300) // #53 + _extension(GL,ARB,vertex_array_object, GL210, GL300) // #54 _extension(GL,ARB,uniform_buffer_object, GL210, GL310) // #57 _extension(GL,ARB,copy_buffer, /*?*/ GL210, GL310) // #59 _extension(GL,ARB,depth_clamp, /*?*/ GL210, GL320) // #61 diff --git a/src/Magnum/Implementation/MeshState.cpp b/src/Magnum/Implementation/MeshState.cpp index eed3a9763..308099769 100644 --- a/src/Magnum/Implementation/MeshState.cpp +++ b/src/Magnum/Implementation/MeshState.cpp @@ -39,7 +39,7 @@ MeshState::MeshState(Context& context, std::vector& extensions): cu #endif { #ifndef MAGNUM_TARGET_GLES - if(context.isExtensionSupported()) + if(context.isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) if(context.isExtensionSupported()) #else @@ -48,7 +48,7 @@ MeshState::MeshState(Context& context, std::vector& extensions): cu #endif { #ifndef MAGNUM_TARGET_GLES - extensions.push_back(Extensions::GL::APPLE::vertex_array_object::string()); + extensions.push_back(Extensions::GL::ARB::vertex_array_object::string()); #elif defined(MAGNUM_TARGET_GLES2) extensions.push_back(Extensions::GL::OES::vertex_array_object::string()); #endif diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index 4e3cdf063..eb5bba758 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -316,7 +316,7 @@ layout, see @ref addVertexBuffer() documentation for details. @anchor Mesh-performance-optimization ## Performance optimizations -If @extension{APPLE,vertex_array_object} (part of OpenGL 3.0), OpenGL ES 3.0 or +If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL ES 3.0 or @es_extension{OES,vertex_array_object} on OpenGL ES 2.0 is supported, VAOs are used instead of binding the buffers and specifying vertex attribute pointers in each @ref draw() call. The engine tracks currently bound VAO and currently @@ -409,9 +409,10 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @brief Constructor * @param primitive Primitive type * - * Creates mesh with no vertex buffers and zero vertex count. + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, vertex array object is created. * @see @ref setPrimitive(), @ref setCount(), @fn_gl{GenVertexArrays} - * (if @extension{APPLE,vertex_array_object} is available) */ explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles); @@ -424,8 +425,10 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { /** * @brief Destructor * - * @see @fn_gl{DeleteVertexArrays} (if - * @extension{APPLE,vertex_array_object} is available) + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, vertex array object is deleted. + * @see @fn_gl{DeleteVertexArrays} */ ~Mesh(); @@ -438,8 +441,9 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { /** * @brief OpenGL mesh ID * - * If @extension{APPLE,vertex_array_object} (part of OpenGL 3.0) is not - * available, returns `0`. + * If neither @extension{ARB,vertex_array_object} (part of OpenGL 3.0) + * nor OpenGL ES 3.0 nor @es_extension{OES,vertex_array_object} in + * OpenGL ES 2.0 is available, returns `0`. */ GLuint id() const { return _id; } @@ -662,6 +666,10 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * .addVertexBuffer(buffer, 76 + 24*vertexCount, Shaders::Phong::Normal()); * @endcode * + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, the vertex array object is used to hold the parameters. + * * @attention The buffer passed as parameter is not managed by the * mesh, you must ensure it will exist for whole lifetime of the * mesh and delete it afterwards. @@ -678,7 +686,6 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @fn_gl{VertexAttribPointer} or * @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access}, * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} - * if @extension{APPLE,vertex_array_object} is available */ template inline Mesh& addVertexBuffer(Buffer& buffer, GLintptr offset, const T&... attributes) { addVertexBufferInternal(buffer, offset, strideOfInterleaved(attributes...), 0, attributes...); @@ -693,6 +700,11 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * number of instances that will pass until new data are fetched from * the buffer. Setting it to `0` is equivalent to calling * @ref addVertexBuffer(). + * + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, the vertex array object is used to hold the parameters. + * * @see @ref maxVertexAttributes(), @ref setPrimitive(), * @ref setCount(), @ref setInstanceCount(), @ref setBaseInstance(), * @fn_gl{BindVertexArray}, @fn_gl{EnableVertexAttribArray}, @@ -701,7 +713,6 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access}, * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access}, * @fn_gl_extension{VertexArrayVertexAttribDivisor,EXT,direct_state_access} - * if @extension{APPLE,vertex_array_object} is available * @requires_gl33 %Extension @extension{ARB,instanced_arrays} * @requires_gles30 %Extension @es_extension{ANGLE,instanced_arrays}, * @es_extension{EXT,instanced_arrays} or @@ -728,10 +739,14 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * On OpenGL ES 2.0 this function behaves always as * @ref setIndexBuffer(Buffer&, GLintptr, IndexType), as this * functionality is not available there. + * + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, the vertex array object is used to hold the parameters. + * * @see @ref maxElementsIndices(), @ref maxElementsVertices(), * @ref setCount(), @ref isIndexed(), @fn_gl{BindVertexArray}, - * @fn_gl{BindBuffer} (if @extension{APPLE,vertex_array_object} is - * available) + * @fn_gl{BindBuffer} */ Mesh& setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end); @@ -758,14 +773,16 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * set up. If vertex/index count or instance count is `0`, no draw * commands are issued. See also * @ref AbstractShaderProgram-rendering-workflow "AbstractShaderProgram documentation" - * for more information. + * for more information. If @extension{ARB,vertex_array_object} (part + * of OpenGL 3.0), OpenGL ES 3.0 or @es_extension{OES,vertex_array_object} + * in OpenGL ES 2.0 is available, the associated vertex array object is + * bound instead of setting up the mesh from scratch. * @see @ref setCount(), @ref setInstanceCount(), * @ref MeshView::draw(AbstractShaderProgram&), * @ref MeshView::draw(AbstractShaderProgram&, std::initializer_list>), * @fn_gl{UseProgram}, @fn_gl{EnableVertexAttribArray}, * @fn_gl{BindBuffer}, @fn_gl{VertexAttribPointer}, - * @fn_gl{DisableVertexAttribArray} or @fn_gl{BindVertexArray} (if - * @extension{APPLE,vertex_array_object} is available), + * @fn_gl{DisableVertexAttribArray} or @fn_gl{BindVertexArray}, * @fn_gl{DrawArrays}/@fn_gl{DrawArraysInstanced}/ * @fn_gl{DrawArraysInstancedBaseInstance} or @fn_gl{DrawElements}/ * @fn_gl{DrawRangeElements}/@fn_gl{DrawElementsBaseVertex}/ diff --git a/src/Magnum/MeshView.h b/src/Magnum/MeshView.h index fc9fcd01c..8f6c9bb68 100644 --- a/src/Magnum/MeshView.h +++ b/src/Magnum/MeshView.h @@ -66,13 +66,17 @@ class MAGNUM_EXPORT MeshView { * In OpenGL ES, if @es_extension2{EXT,multi_draw_arrays,multi_draw_arrays} * is not present, the functionality is emulated using sequence of * @ref draw(AbstractShaderProgram&) calls. + * + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, the associated vertex array object is bound instead of + * setting up the mesh from scratch. * @attention All meshes must be views of the same original mesh and * must not be instanced. * @see @ref draw(AbstractShaderProgram&), @fn_gl{UseProgram}, * @fn_gl{EnableVertexAttribArray}, @fn_gl{BindBuffer}, * @fn_gl{VertexAttribPointer}, @fn_gl{DisableVertexAttribArray} - * or @fn_gl{BindVertexArray} (if @extension{APPLE,vertex_array_object} - * is available), @fn_gl{MultiDrawArrays} or + * or @fn_gl{BindVertexArray}, @fn_gl{MultiDrawArrays} or * @fn_gl{MultiDrawElements}/@fn_gl{MultiDrawElementsBaseVertex} */ static void draw(AbstractShaderProgram& shader, std::initializer_list> meshes); diff --git a/src/Magnum/Test/ContextGLTest.cpp b/src/Magnum/Test/ContextGLTest.cpp index e6de8bcfe..198ea4fd2 100644 --- a/src/Magnum/Test/ContextGLTest.cpp +++ b/src/Magnum/Test/ContextGLTest.cpp @@ -91,14 +91,14 @@ void ContextGLTest::isExtensionSupported() { void ContextGLTest::isExtensionDisabled() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::APPLE::vertex_array_object::string() + std::string(" extension should be supported, can't test")); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::vertex_array_object::string() + std::string(" extension should be supported, can't test")); if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::explicit_attrib_location::string() + std::string(" extension should be supported, can't test")); /* This is not disabled anywhere */ - CORRADE_VERIFY(!Context::current()->isExtensionDisabled()); + CORRADE_VERIFY(!Context::current()->isExtensionDisabled()); /* This is disabled in GL < 3.2 to work around GLSL compiler bugs */ CORRADE_VERIFY(Context::current()->isExtensionDisabled(Version::GL310)); diff --git a/src/Magnum/Test/MeshGLTest.cpp b/src/Magnum/Test/MeshGLTest.cpp index 83e0c3f6c..0431d282d 100644 --- a/src/Magnum/Test/MeshGLTest.cpp +++ b/src/Magnum/Test/MeshGLTest.cpp @@ -233,7 +233,7 @@ void MeshGLTest::construct() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current()->isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) if(Context::current()->isExtensionSupported()) #endif @@ -257,7 +257,7 @@ void MeshGLTest::constructMove() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current()->isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) if(Context::current()->isExtensionSupported()) #endif @@ -277,7 +277,7 @@ void MeshGLTest::constructMove() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current()->isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) if(Context::current()->isExtensionSupported()) #endif