Browse Source

GL: taking just an init list in MeshView::draw() was a stupid idea.

With just that, it wouldn't be possible to draw a runtime-dependent
amount of MeshViews (for example when culling them).
pull/371/head
Vladimír Vondruš 6 years ago
parent
commit
4f0170ace4
  1. 10
      doc/changelog.dox
  2. 2
      src/Magnum/GL/Implementation/MeshState.h
  3. 14
      src/Magnum/GL/MeshView.cpp
  4. 14
      src/Magnum/GL/MeshView.h

10
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()"

2
src/Magnum/GL/Implementation/MeshState.h

@ -59,7 +59,7 @@ struct MeshState {
#endif
#ifdef MAGNUM_TARGET_GLES
void(*multiDrawImplementation)(std::initializer_list<Containers::Reference<MeshView>>);
void(*multiDrawImplementation)(Containers::ArrayView<const Containers::Reference<MeshView>>);
#endif
void(*bindVAOImplementation)(GLuint);

14
src/Magnum/GL/MeshView.cpp

@ -36,7 +36,7 @@
namespace Magnum { namespace GL {
void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list<Containers::Reference<MeshView>> meshes) {
void MeshView::draw(AbstractShaderProgram& shader, Containers::ArrayView<const Containers::Reference<MeshView>> 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<Contain
#endif
}
void MeshView::draw(AbstractShaderProgram&& shader, Containers::ArrayView<const Containers::Reference<MeshView>> meshes) {
draw(shader, Containers::arrayView(meshes));
}
void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list<Containers::Reference<MeshView>> meshes) {
draw(shader, Containers::arrayView(meshes));
}
#ifndef MAGNUM_TARGET_WEBGL
void MeshView::multiDrawImplementationDefault(std::initializer_list<Containers::Reference<MeshView>> meshes) {
void MeshView::multiDrawImplementationDefault(Containers::ArrayView<const Containers::Reference<MeshView>> meshes) {
CORRADE_INTERNAL_ASSERT(meshes.size());
const Implementation::MeshState& state = *Context::current().state().mesh;
@ -123,7 +131,7 @@ void MeshView::multiDrawImplementationDefault(std::initializer_list<Containers::
#endif
#ifdef MAGNUM_TARGET_GLES
void MeshView::multiDrawImplementationFallback(std::initializer_list<Containers::Reference<MeshView>> meshes) {
void MeshView::multiDrawImplementationFallback(Containers::ArrayView<const Containers::Reference<MeshView>> meshes) {
for(MeshView& mesh: meshes) {
/* Nothing to draw in this mesh */
if(!mesh._count) continue;

14
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<const Containers::Reference<MeshView>> meshes);
/**
* @overload
* @m_since_latest
*/
static void draw(AbstractShaderProgram&& shader, Containers::ArrayView<const Containers::Reference<MeshView>> meshes);
/** @overload */
static void draw(AbstractShaderProgram& shader, std::initializer_list<Containers::Reference<MeshView>> 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<Containers::Reference<MeshView>> meshes);
static MAGNUM_GL_LOCAL void multiDrawImplementationDefault(Containers::ArrayView<const Containers::Reference<MeshView>> meshes);
#endif
static MAGNUM_GL_LOCAL void multiDrawImplementationFallback(std::initializer_list<Containers::Reference<MeshView>> meshes);
static MAGNUM_GL_LOCAL void multiDrawImplementationFallback(Containers::ArrayView<const Containers::Reference<MeshView>> meshes);
Containers::Reference<Mesh> _original;

Loading…
Cancel
Save