diff --git a/doc/changelog.dox b/doc/changelog.dox index 13929c053..563495594 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -177,11 +177,11 @@ See also: @subsubsection changelog-latest-changes-gl GL library -- Added @ref GL::AbstractTexture::bind() and - @ref GL::AbstractTexture::bindImages() overloads taking a - @ref Corrade::Containers::ArrayView instead of @ref std::initializer_list - in order to allow passing runtime-sized lists (see - [mosra/magnum#403](https://github.com/mosra/magnum/pull/403)) +- Added @ref GL::AbstractTexture::bind(), + @ref GL::AbstractTexture::bindImages() and @ref GL::MeshView::draw() + overloads taking a @ref Corrade::Containers::ArrayView instead of + @ref std::initializer_list in order to allow passing runtime-sized lists + (see also [mosra/magnum#403](https://github.com/mosra/magnum/pull/403)) - Added an ability to remove a buffer from a @ref GL::BufferTexture using @ref GL::BufferTexture::resetBuffer() "resetBuffer()" diff --git a/src/Magnum/GL/Implementation/MeshState.h b/src/Magnum/GL/Implementation/MeshState.h index 509f38721..5dc3b1f62 100644 --- a/src/Magnum/GL/Implementation/MeshState.h +++ b/src/Magnum/GL/Implementation/MeshState.h @@ -59,7 +59,7 @@ struct MeshState { #endif #ifdef MAGNUM_TARGET_GLES - void(*multiDrawImplementation)(std::initializer_list>); + void(*multiDrawImplementation)(Containers::ArrayView>); #endif void(*bindVAOImplementation)(GLuint); diff --git a/src/Magnum/GL/MeshView.cpp b/src/Magnum/GL/MeshView.cpp index 139302c00..42e9fa8c9 100644 --- a/src/Magnum/GL/MeshView.cpp +++ b/src/Magnum/GL/MeshView.cpp @@ -36,7 +36,7 @@ namespace Magnum { namespace GL { -void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list> meshes) { +void MeshView::draw(AbstractShaderProgram& shader, Containers::ArrayView> meshes) { /* Why std::initializer_list doesn't have empty()? */ if(!meshes.size()) return; @@ -55,8 +55,16 @@ void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list> meshes) { + draw(shader, Containers::arrayView(meshes)); +} + +void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list> meshes) { + draw(shader, Containers::arrayView(meshes)); +} + #ifndef MAGNUM_TARGET_WEBGL -void MeshView::multiDrawImplementationDefault(std::initializer_list> meshes) { +void MeshView::multiDrawImplementationDefault(Containers::ArrayView> meshes) { CORRADE_INTERNAL_ASSERT(meshes.size()); const Implementation::MeshState& state = *Context::current().state().mesh; @@ -123,7 +131,7 @@ void MeshView::multiDrawImplementationDefault(std::initializer_list> meshes) { +void MeshView::multiDrawImplementationFallback(Containers::ArrayView> meshes) { for(MeshView& mesh: meshes) { /* Nothing to draw in this mesh */ if(!mesh._count) continue; diff --git a/src/Magnum/GL/MeshView.h b/src/Magnum/GL/MeshView.h index 4cf89d54d..f63766a43 100644 --- a/src/Magnum/GL/MeshView.h +++ b/src/Magnum/GL/MeshView.h @@ -84,7 +84,17 @@ class MAGNUM_GL_EXPORT MeshView { * if the mesh is indexed and @ref baseVertex() is not `0`. * @requires_gl Specifying base vertex for indexed meshes is not * available in OpenGL ES or WebGL. + * @m_since_latest */ + static void draw(AbstractShaderProgram& shader, Containers::ArrayView> meshes); + + /** + * @overload + * @m_since_latest + */ + static void draw(AbstractShaderProgram&& shader, Containers::ArrayView> meshes); + + /** @overload */ static void draw(AbstractShaderProgram& shader, std::initializer_list> meshes); /** @overload */ @@ -287,9 +297,9 @@ class MAGNUM_GL_EXPORT MeshView { private: #ifndef MAGNUM_TARGET_WEBGL - static MAGNUM_GL_LOCAL void multiDrawImplementationDefault(std::initializer_list> meshes); + static MAGNUM_GL_LOCAL void multiDrawImplementationDefault(Containers::ArrayView> meshes); #endif - static MAGNUM_GL_LOCAL void multiDrawImplementationFallback(std::initializer_list> meshes); + static MAGNUM_GL_LOCAL void multiDrawImplementationFallback(Containers::ArrayView> meshes); Containers::Reference _original;