diff --git a/doc/changelog.dox b/doc/changelog.dox index 852fed426..b35fa1b28 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -186,6 +186,10 @@ See also: @subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs +- The @ref MeshTools::fullScreenTriangle() function now returns just a + @ref GL::Mesh instead of @ref std::pair of a mesh and a buffer, as the + buffer is now owned by the mesh. This change was not possible to be done in + a backwards-compatible way. - Removed deprecated implicit conversion @ref Corrade::Containers::Optional to @cpp std::optional @ce, deprecated in January 2018. The class now contains an *explicit* and opt-in STL compatibility, see its documentation diff --git a/src/Magnum/MeshTools/FullScreenTriangle.cpp b/src/Magnum/MeshTools/FullScreenTriangle.cpp index ae6890363..1d025462f 100644 --- a/src/Magnum/MeshTools/FullScreenTriangle.cpp +++ b/src/Magnum/MeshTools/FullScreenTriangle.cpp @@ -34,34 +34,31 @@ namespace Magnum { namespace MeshTools { -std::pair, GL::Mesh> fullScreenTriangle(GL::Version version) { +GL::Mesh fullScreenTriangle(const GL::Version version) { GL::Mesh mesh; mesh.setPrimitive(GL::MeshPrimitive::Triangles) .setCount(3); - std::unique_ptr buffer; #ifndef MAGNUM_TARGET_GLES if(version < GL::Version::GL300) #else if(version < GL::Version::GLES300) #endif { - buffer.reset(new GL::Buffer); - constexpr Vector2 triangle[] = { + constexpr Vector2 triangle[]{ {-1.0f, 1.0f}, {-1.0f, -3.0f}, { 3.0f, 1.0f} }; - buffer->setData(triangle, GL::BufferUsage::StaticDraw); - /** @todo Is it possible to attach moveable buffer here to avoid heap - allocation? OTOH this is more effective in most (modern) cases */ - mesh.addVertexBuffer(*buffer, 0, GL::Attribute<0, Vector2>{}); + GL::Buffer buffer{GL::Buffer::TargetHint::Array}; + buffer.setData(triangle, GL::BufferUsage::StaticDraw); + mesh.addVertexBuffer(std::move(buffer), 0, GL::Attribute<0, Vector2>{}); } - return {std::move(buffer), std::move(mesh)}; + return mesh; } -std::pair, GL::Mesh> fullScreenTriangle() { +GL::Mesh fullScreenTriangle() { return fullScreenTriangle(GL::Context::current().version()); } diff --git a/src/Magnum/MeshTools/FullScreenTriangle.h b/src/Magnum/MeshTools/FullScreenTriangle.h index f1830cbc2..7218a1ef5 100644 --- a/src/Magnum/MeshTools/FullScreenTriangle.h +++ b/src/Magnum/MeshTools/FullScreenTriangle.h @@ -34,9 +34,6 @@ #include "Magnum/configure.h" #ifdef MAGNUM_TARGET_GL -#include -#include - #include "Magnum/GL/GL.h" #include "Magnum/MeshTools/visibility.h" @@ -89,7 +86,7 @@ void main() { @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features for more information. */ -std::pair, GL::Mesh> MAGNUM_MESHTOOLS_EXPORT fullScreenTriangle(GL::Version version); +GL::Mesh MAGNUM_MESHTOOLS_EXPORT fullScreenTriangle(GL::Version version); /** @overload @@ -99,7 +96,7 @@ This function implicitly uses current context version. @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features for more information. */ -std::pair, GL::Mesh> MAGNUM_MESHTOOLS_EXPORT fullScreenTriangle(); +GL::Mesh MAGNUM_MESHTOOLS_EXPORT fullScreenTriangle(); #else #error this header is available only in the OpenGL build #endif