Browse Source

Ability to instantiate OpenGL objects without creating them.

Similarly to what's now done with NoInit tags for Containers::Array and
all math types such as Vector, there's now NoCreate tag for creating
wrappers without actually creating the underlying OpenGL object. The
instance is then equivalent to moved-from state. Useful to avoid
needless creation/deletion of OpenGL object in case you would overwrite
the instance later anyway:

    Mesh mesh{NoCreate};
    std::unique_ptr<Buffer> indices, vertices;
    std::tie(mesh, indices, vertices) = MeshTools:compile(...);
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
adf88d5535
  1. 2
      src/Magnum/AbstractQuery.h
  2. 2
      src/Magnum/AbstractTexture.h
  3. 21
      src/Magnum/Buffer.h
  4. 14
      src/Magnum/BufferTexture.h
  5. 1
      src/Magnum/CMakeLists.txt
  6. 14
      src/Magnum/CubeMapTexture.h
  7. 15
      src/Magnum/CubeMapTextureArray.h
  8. 14
      src/Magnum/Framebuffer.h
  9. 9
      src/Magnum/Mesh.cpp
  10. 16
      src/Magnum/Mesh.h
  11. 14
      src/Magnum/MultisampleTexture.h
  12. 13
      src/Magnum/PrimitiveQuery.h
  13. 15
      src/Magnum/RectangleTexture.h
  14. 15
      src/Magnum/Renderbuffer.h
  15. 13
      src/Magnum/SampleQuery.h
  16. 51
      src/Magnum/Tags.h
  17. 13
      src/Magnum/Test/BufferGLTest.cpp
  18. 13
      src/Magnum/Test/BufferTextureGLTest.cpp
  19. 13
      src/Magnum/Test/CubeMapTextureArrayGLTest.cpp
  20. 13
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  21. 13
      src/Magnum/Test/FramebufferGLTest.cpp
  22. 13
      src/Magnum/Test/MeshGLTest.cpp
  23. 26
      src/Magnum/Test/MultisampleTextureGLTest.cpp
  24. 15
      src/Magnum/Test/PrimitiveQueryGLTest.cpp
  25. 13
      src/Magnum/Test/RectangleTextureGLTest.cpp
  26. 13
      src/Magnum/Test/RenderbufferGLTest.cpp
  27. 15
      src/Magnum/Test/SampleQueryGLTest.cpp
  28. 26
      src/Magnum/Test/TextureArrayGLTest.cpp
  29. 39
      src/Magnum/Test/TextureGLTest.cpp
  30. 13
      src/Magnum/Test/TransformFeedbackGLTest.cpp
  31. 4
      src/Magnum/Text/Test/RendererGLTest.cpp
  32. 16
      src/Magnum/Texture.h
  33. 14
      src/Magnum/TextureArray.h
  34. 13
      src/Magnum/TimeQuery.h
  35. 14
      src/Magnum/TransformFeedback.h

2
src/Magnum/AbstractQuery.h

@ -35,6 +35,7 @@
#include <Corrade/Utility/Assert.h>
#include "Magnum/AbstractObject.h"
#include "Magnum/Tags.h"
#include "Magnum/configure.h"
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
@ -173,6 +174,7 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
private:
#endif
explicit AbstractQuery(GLenum target);
explicit AbstractQuery(NoCreateT, GLenum target) noexcept: _id{0}, _target{target}, _flags{ObjectFlag::DeleteOnDestruction} {}
explicit AbstractQuery(GLuint id, GLenum target, ObjectFlags flags) noexcept: _id{id}, _target{target}, _flags{flags} {}
#ifdef MAGNUM_BUILD_DEPRECATED

2
src/Magnum/AbstractTexture.h

@ -34,6 +34,7 @@
#include "Magnum/AbstractObject.h"
#include "Magnum/DimensionTraits.h"
#include "Magnum/Sampler.h"
#include "Magnum/Tags.h"
namespace Magnum {
@ -340,6 +341,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
template<UnsignedInt textureDimensions> struct DataHelper {};
explicit AbstractTexture(GLenum target);
explicit AbstractTexture(NoCreateT, GLenum target) noexcept: _target{target}, _id{0}, _flags{ObjectFlag::DeleteOnDestruction} {}
explicit AbstractTexture(GLuint id, GLenum target, ObjectFlags flags) noexcept: _target{target}, _id{id}, _flags{flags} {}
#ifndef MAGNUM_TARGET_WEBGL

21
src/Magnum/Buffer.h

@ -38,6 +38,7 @@
#include "Magnum/AbstractObject.h"
#include "Magnum/Magnum.h"
#include "Magnum/Tags.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Utility/Macros.h>
@ -850,11 +851,21 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* Creates new OpenGL buffer object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the buffer is created on
* first use.
* @see @ref wrap(), @fn_gl{CreateBuffers}, eventually
* @fn_gl{GenBuffers}
* @see @ref Buffer(NoCreateT), @ref wrap(), @fn_gl{CreateBuffers},
* eventually @fn_gl{GenBuffers}
*/
explicit Buffer(TargetHint targetHint = TargetHint::Array);
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref Buffer(TargetHint), @ref wrap()
*/
explicit Buffer(NoCreateT) noexcept;
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief Buffer(TargetHint)
@ -1424,6 +1435,12 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::TargetHint value);
Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::Target value);
#endif
inline Buffer::Buffer(NoCreateT) noexcept: _id{0}, _targetHint{TargetHint::Array}, _flags{ObjectFlag::DeleteOnDestruction}
#ifdef CORRADE_TARGET_NACL
, _mappedBuffer{nullptr}
#endif
{}
inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint},
#ifdef CORRADE_TARGET_NACL
_mappedBuffer{other._mappedBuffer},

14
src/Magnum/BufferTexture.h

@ -244,11 +244,21 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture {
* Creates new OpenGL texture object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the texture is created on
* first use.
* @see @ref wrap(), @fn_gl{CreateTextures} with @def_gl{TEXTURE_BUFFER},
* eventually @fn_gl{GenTextures}
* @see @ref BufferTexture(NoCreateT), @ref wrap(), @fn_gl{CreateTextures}
* with @def_gl{TEXTURE_BUFFER}, eventually @fn_gl{GenTextures}
*/
explicit BufferTexture(): AbstractTexture(GL_TEXTURE_BUFFER) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref BufferTexture(), @ref wrap()
*/
explicit BufferTexture(NoCreateT) noexcept: AbstractTexture{NoCreate, GL_TEXTURE_BUFFER} {}
/**
* @brief Set texture buffer
* @param internalFormat Internal format

1
src/Magnum/CMakeLists.txt

@ -108,6 +108,7 @@ set(Magnum_HEADERS
ResourceManager.hpp
Sampler.h
Shader.h
Tags.h
Texture.h
TextureFormat.h
Timeline.h

14
src/Magnum/CubeMapTexture.h

@ -123,11 +123,21 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
* Creates new OpenGL texture object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the texture is created on
* first use.
* @see @ref wrap(), @fn_gl{CreateTextures} with
* @def_gl{TEXTURE_CUBE_MAP}, eventually @fn_gl{GenTextures}
* @see @ref CubeMapTexture(NoCreateT), @ref wrap(), @fn_gl{CreateTextures}
* with @def_gl{TEXTURE_CUBE_MAP}, eventually @fn_gl{GenTextures}
*/
explicit CubeMapTexture(): AbstractTexture(GL_TEXTURE_CUBE_MAP) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref CubeMapTexture(), @ref wrap()
*/
explicit CubeMapTexture(NoCreateT) noexcept: AbstractTexture{NoCreate, GL_TEXTURE_CUBE_MAP} {}
#ifndef MAGNUM_TARGET_GLES2
/**
* @copybrief Texture::setBaseLevel()

15
src/Magnum/CubeMapTextureArray.h

@ -116,11 +116,22 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture {
* Creates new OpenGL texture object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the texture is created on
* first use.
* @see @ref wrap(), @fn_gl{CreateTextures} with
* @def_gl{TEXTURE_CUBE_MAP_ARRAY}, eventually @fn_gl{GenTextures}
* @see @ref CubeMapTextureArray(NoCreateT), @ref wrap(),
* @fn_gl{CreateTextures} with @def_gl{TEXTURE_CUBE_MAP_ARRAY},
* eventually @fn_gl{GenTextures}
*/
explicit CubeMapTextureArray(): AbstractTexture(GL_TEXTURE_CUBE_MAP_ARRAY) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref CubeMapTextureArray(), @ref wrap()
*/
explicit CubeMapTextureArray(NoCreateT) noexcept: AbstractTexture{NoCreate, GL_TEXTURE_CUBE_MAP_ARRAY} {}
/**
* @copybrief Texture::setBaseLevel()
* @return Reference to self (for method chaining)

14
src/Magnum/Framebuffer.h

@ -340,11 +340,21 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje
* Generates new OpenGL framebuffer object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the framebuffer is created on
* first use.
* @see @ref setViewport(), @ref wrap(), @fn_gl{CreateFramebuffers},
* eventually @fn_gl{GenFramebuffers}
* @see @ref Framebuffer(NoCreateT), @ref wrap(), @ref setViewport(),
* @fn_gl{CreateFramebuffers}, eventually @fn_gl{GenFramebuffers}
*/
explicit Framebuffer(const Range2Di& viewport);
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref Framebuffer(const Range2Di&), @ref wrap()
*/
explicit Framebuffer(NoCreateT) noexcept { _id = 0; }
/** @brief Copying is not allowed */
Framebuffer(const Framebuffer&) = delete;

9
src/Magnum/Mesh.cpp

@ -119,6 +119,15 @@ Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectF
(this->*Context::current()->state().mesh->createImplementation)();
}
Mesh::Mesh(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction}, _count{0}, _baseVertex{0}, _instanceCount{1},
#ifndef MAGNUM_TARGET_GLES
_baseInstance{0},
#endif
#ifndef MAGNUM_TARGET_GLES2
_indexStart(0), _indexEnd(0),
#endif
_indexOffset(0), _indexType(IndexType::UnsignedInt), _indexBuffer(nullptr) {}
Mesh::~Mesh() {
/* Moved out or not deleting on destruction, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return;

16
src/Magnum/Mesh.h

@ -35,6 +35,7 @@
#include "Magnum/AbstractObject.h"
#include "Magnum/Attribute.h"
#include "Magnum/Tags.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Utility/Macros.h>
@ -461,11 +462,22 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* available, vertex array object is created. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the vertex array object is
* created on first use.
* @see @ref setPrimitive(), @ref setCount(), @ref wrap(),
* @fn_gl{CreateVertexArrays}, eventually @fn_gl{GenVertexArrays}
* @see @ref Mesh(NoCreateT), @ref wrap(), @ref setPrimitive(),
* @ref setCount(), @fn_gl{CreateVertexArrays}, eventually
* @fn_gl{GenVertexArrays}
*/
explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles);
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref Mesh(MeshPrimitive), @ref wrap()
*/
explicit Mesh(NoCreateT) noexcept;
/** @brief Copying is not allowed */
Mesh(const Mesh&) = delete;

14
src/Magnum/MultisampleTexture.h

@ -136,13 +136,23 @@ template<UnsignedInt dimensions> class MultisampleTexture: public AbstractTextur
* Creates new OpenGL texture object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the texture is created on
* first use.
* @see @ref wrap(), @fn_gl{CreateTextures} with
* @def_gl{TEXTURE_2D_MULTISAMPLE} or
* @see @ref MultisampleTexture(NoCreateT), @ref wrap(),
* @fn_gl{CreateTextures} with @def_gl{TEXTURE_2D_MULTISAMPLE} or
* @def_gl{TEXTURE_2D_MULTISAMPLE_ARRAY}, eventually
* @fn_gl{GenTextures}
*/
explicit MultisampleTexture(): AbstractTexture(Implementation::multisampleTextureTarget<dimensions>()) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref MultisampleTexture(), @ref wrap()
*/
explicit MultisampleTexture(NoCreateT) noexcept: AbstractTexture{NoCreate, Implementation::multisampleTextureTarget<dimensions>()} {}
/**
* @brief Set storage
* @param samples Sample count

13
src/Magnum/PrimitiveQuery.h

@ -114,10 +114,21 @@ class PrimitiveQuery: public AbstractQuery {
* Creates new OpenGL query object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the query is created on first
* use.
* @see @ref wrap(), @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries}
* @see @ref PrimitiveQuery(NoCreateT), @ref wrap(),
* @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries}
*/
explicit PrimitiveQuery(Target target): AbstractQuery(GLenum(target)) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref PrimitiveQuery(Target), @ref wrap()
*/
explicit PrimitiveQuery(NoCreateT) noexcept: AbstractQuery{NoCreate, GLenum(Target::TransformFeedbackPrimitivesWritten)} {}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief AbstractQuery::begin()

15
src/Magnum/RectangleTexture.h

@ -101,11 +101,22 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
* Creates new OpenGL texture object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the texture is created on
* first use.
* @see @ref wrap(), @fn_gl{CreateTextures} with
* @def_gl{TEXTURE_RECTANGLE}, eventually @fn_gl{GenTextures}
* @see @ref RectangleTexture(NoCreateT), @ref wrap(),
* @fn_gl{CreateTextures} with @def_gl{TEXTURE_RECTANGLE},
* eventually @fn_gl{GenTextures}
*/
explicit RectangleTexture(): AbstractTexture(GL_TEXTURE_RECTANGLE) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref RectangleTexture(), @ref wrap()
*/
explicit RectangleTexture(NoCreateT) noexcept: AbstractTexture{NoCreate, GL_TEXTURE_RECTANGLE} {}
/**
* @copybrief Texture::setMinificationFilter()
* @return Reference to self (for method chaining)

15
src/Magnum/Renderbuffer.h

@ -33,6 +33,7 @@
#include "Magnum/AbstractObject.h"
#include "Magnum/Magnum.h"
#include "Magnum/Tags.h"
namespace Magnum {
@ -109,11 +110,21 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject {
* Generates new OpenGL renderbuffer object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the renderbuffer is created
* on first use.
* @see @ref wrap(), @fn_gl{CreateRenderbuffers}, eventually
* @fn_gl{GenRenderbuffers}
* @see @ref Renderbuffer(NoCreateT), @ref wrap(),
* @fn_gl{CreateRenderbuffers}, eventually @fn_gl{GenRenderbuffers}
*/
explicit Renderbuffer();
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref Renderbuffer(), @ref wrap()
*/
explicit Renderbuffer(NoCreateT) noexcept: _id{0}, _flags{ObjectFlag::DeleteOnDestruction} {}
/** @brief Copying is not allowed */
Renderbuffer(const Renderbuffer&) = delete;

13
src/Magnum/SampleQuery.h

@ -212,10 +212,21 @@ class SampleQuery: public AbstractQuery {
* Creates new OpenGL query object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the query is created on first
* use.
* @see @ref wrap(), @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries}
* @see @ref SampleQuery(NoCreateT), @ref wrap(), @fn_gl{CreateQueries},
* eventually @fn_gl{GenQueries}
*/
explicit SampleQuery(Target target): AbstractQuery(GLenum(target)) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref SampleQuery(Target), @ref wrap()
*/
explicit SampleQuery(NoCreateT) noexcept: AbstractQuery{NoCreate, GLenum(Target::AnySamplesPassed)} {}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief AbstractQuery::begin()

51
src/Magnum/Tags.h

@ -0,0 +1,51 @@
#ifndef Magnum_Tags_h
#define Magnum_Tags_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Tag type @ref Magnum::NoCreateT, tag @ref Magnum::NoCreate
*/
namespace Magnum {
/**
@brief No creation tag type
Used to distinguish construction without creating the underlying OpenGL object.
@see @ref NoCreate
*/
struct NoCreateT {};
/**
@brief No creation tag
Use for construction without creating the underlying OpenGL object.
*/
constexpr NoCreateT NoCreate{};
}
#endif

13
src/Magnum/Test/BufferGLTest.cpp

@ -38,6 +38,7 @@ struct BufferGLTest: AbstractOpenGLTester {
explicit BufferGLTest();
void construct();
void constructNoCreate();
void constructCopy();
void constructMove();
void wrap();
@ -64,6 +65,7 @@ struct BufferGLTest: AbstractOpenGLTester {
BufferGLTest::BufferGLTest() {
addTests({&BufferGLTest::construct,
&BufferGLTest::constructNoCreate,
&BufferGLTest::constructCopy,
&BufferGLTest::constructMove,
&BufferGLTest::wrap,
@ -101,6 +103,17 @@ void BufferGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void BufferGLTest::constructNoCreate() {
{
Buffer buffer{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(buffer.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void BufferGLTest::constructCopy() {
CORRADE_VERIFY(!(std::is_constructible<Buffer, const Buffer&>{}));
CORRADE_VERIFY(!(std::is_assignable<Buffer, const Buffer&>{}));

13
src/Magnum/Test/BufferTextureGLTest.cpp

@ -35,6 +35,7 @@ struct BufferTextureGLTest: AbstractOpenGLTester {
explicit BufferTextureGLTest();
void construct();
void constructNoCreate();
void wrap();
void bind();
@ -44,6 +45,7 @@ struct BufferTextureGLTest: AbstractOpenGLTester {
BufferTextureGLTest::BufferTextureGLTest() {
addTests({&BufferTextureGLTest::construct,
&BufferTextureGLTest::constructNoCreate,
&BufferTextureGLTest::wrap,
&BufferTextureGLTest::bind,
@ -65,6 +67,17 @@ void BufferTextureGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void BufferTextureGLTest::constructNoCreate() {
{
BufferTexture texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void BufferTextureGLTest::wrap() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_buffer_object>())
CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported."));

13
src/Magnum/Test/CubeMapTextureArrayGLTest.cpp

@ -40,6 +40,7 @@ struct CubeMapTextureArrayGLTest: AbstractOpenGLTester {
explicit CubeMapTextureArrayGLTest();
void construct();
void constructNoCreate();
void wrap();
void bind();
@ -67,6 +68,7 @@ struct CubeMapTextureArrayGLTest: AbstractOpenGLTester {
CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() {
addTests({&CubeMapTextureArrayGLTest::construct,
&CubeMapTextureArrayGLTest::constructNoCreate,
&CubeMapTextureArrayGLTest::wrap,
&CubeMapTextureArrayGLTest::bind,
@ -106,6 +108,17 @@ void CubeMapTextureArrayGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void CubeMapTextureArrayGLTest::constructNoCreate() {
{
CubeMapTextureArray texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void CubeMapTextureArrayGLTest::wrap() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported."));

13
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -43,6 +43,7 @@ struct CubeMapTextureGLTest: AbstractOpenGLTester {
explicit CubeMapTextureGLTest();
void construct();
void constructNoCreate();
void wrap();
void bind();
@ -90,6 +91,7 @@ struct CubeMapTextureGLTest: AbstractOpenGLTester {
CubeMapTextureGLTest::CubeMapTextureGLTest() {
addTests({&CubeMapTextureGLTest::construct,
&CubeMapTextureGLTest::constructNoCreate,
&CubeMapTextureGLTest::wrap,
&CubeMapTextureGLTest::bind,
@ -146,6 +148,17 @@ void CubeMapTextureGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void CubeMapTextureGLTest::constructNoCreate() {
{
CubeMapTexture texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void CubeMapTextureGLTest::wrap() {
GLuint id;
glGenTextures(1, &id);

13
src/Magnum/Test/FramebufferGLTest.cpp

@ -53,6 +53,7 @@ struct FramebufferGLTest: AbstractOpenGLTester {
explicit FramebufferGLTest();
void construct();
void constructNoCreate();
void constructCopy();
void constructMove();
void wrap();
@ -105,6 +106,7 @@ struct FramebufferGLTest: AbstractOpenGLTester {
FramebufferGLTest::FramebufferGLTest() {
addTests({&FramebufferGLTest::construct,
&FramebufferGLTest::constructNoCreate,
&FramebufferGLTest::constructCopy,
&FramebufferGLTest::constructMove,
&FramebufferGLTest::wrap,
@ -177,6 +179,17 @@ void FramebufferGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void FramebufferGLTest::constructNoCreate() {
{
Framebuffer framebuffer{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(framebuffer.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void FramebufferGLTest::constructCopy() {
CORRADE_VERIFY(!(std::is_constructible<Framebuffer, const Framebuffer&>{}));
CORRADE_VERIFY(!(std::is_assignable<Framebuffer, const Framebuffer&>{}));

13
src/Magnum/Test/MeshGLTest.cpp

@ -46,6 +46,7 @@ struct MeshGLTest: AbstractOpenGLTester {
explicit MeshGLTest();
void construct();
void constructNoCreate();
void constructCopy();
void constructMove();
void wrap();
@ -138,6 +139,7 @@ struct MeshGLTest: AbstractOpenGLTester {
MeshGLTest::MeshGLTest() {
addTests({&MeshGLTest::construct,
&MeshGLTest::constructNoCreate,
&MeshGLTest::constructCopy,
&MeshGLTest::constructMove,
&MeshGLTest::wrap,
@ -247,6 +249,17 @@ void MeshGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void MeshGLTest::constructNoCreate() {
{
Mesh mesh{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(mesh.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void MeshGLTest::constructCopy() {
CORRADE_VERIFY(!(std::is_constructible<Mesh, const Mesh&>{}));
CORRADE_VERIFY(!(std::is_assignable<Mesh, const Mesh&>{}));

26
src/Magnum/Test/MultisampleTextureGLTest.cpp

@ -36,8 +36,10 @@ struct MultisampleTextureGLTest: AbstractOpenGLTester {
explicit MultisampleTextureGLTest();
void construct2D();
void construct2DNoCreate();
#ifndef MAGNUM_TARGET_GLES
void construct2DArray();
void construct2DArrayNoCreate();
#endif
void wrap2D();
@ -68,8 +70,10 @@ struct MultisampleTextureGLTest: AbstractOpenGLTester {
MultisampleTextureGLTest::MultisampleTextureGLTest() {
addTests({&MultisampleTextureGLTest::construct2D,
&MultisampleTextureGLTest::construct2DNoCreate,
#ifndef MAGNUM_TARGET_GLES
&MultisampleTextureGLTest::construct2DArray,
&MultisampleTextureGLTest::construct2DArrayNoCreate,
#endif
&MultisampleTextureGLTest::wrap2D,
@ -118,6 +122,17 @@ void MultisampleTextureGLTest::construct2D() {
MAGNUM_VERIFY_NO_ERROR();
}
void MultisampleTextureGLTest::construct2DNoCreate() {
{
MultisampleTexture2D texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
#ifndef MAGNUM_TARGET_GLES
void MultisampleTextureGLTest::construct2DArray() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
@ -132,6 +147,17 @@ void MultisampleTextureGLTest::construct2DArray() {
MAGNUM_VERIFY_NO_ERROR();
}
void MultisampleTextureGLTest::construct2DArrayNoCreate() {
{
MultisampleTexture2DArray texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
#endif
void MultisampleTextureGLTest::wrap2D() {

15
src/Magnum/Test/PrimitiveQueryGLTest.cpp

@ -40,6 +40,7 @@ namespace Magnum { namespace Test {
struct PrimitiveQueryGLTest: AbstractOpenGLTester {
explicit PrimitiveQueryGLTest();
void constructNoCreate();
void wrap();
#ifndef MAGNUM_TARGET_GLES
@ -49,7 +50,8 @@ struct PrimitiveQueryGLTest: AbstractOpenGLTester {
};
PrimitiveQueryGLTest::PrimitiveQueryGLTest() {
addTests({&PrimitiveQueryGLTest::wrap,
addTests({&PrimitiveQueryGLTest::constructNoCreate,
&PrimitiveQueryGLTest::wrap,
#ifndef MAGNUM_TARGET_GLES
&PrimitiveQueryGLTest::primitivesGenerated,
@ -57,6 +59,17 @@ PrimitiveQueryGLTest::PrimitiveQueryGLTest() {
&PrimitiveQueryGLTest::transformFeedbackPrimitivesWritten});
}
void PrimitiveQueryGLTest::constructNoCreate() {
{
PrimitiveQuery query{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(query.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void PrimitiveQueryGLTest::wrap() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::transform_feedback2>())

13
src/Magnum/Test/RectangleTextureGLTest.cpp

@ -42,6 +42,7 @@ struct RectangleTextureGLTest: AbstractOpenGLTester {
explicit RectangleTextureGLTest();
void construct();
void constructNoCreate();
void wrap();
void bind();
@ -67,6 +68,7 @@ struct RectangleTextureGLTest: AbstractOpenGLTester {
RectangleTextureGLTest::RectangleTextureGLTest() {
addTests({&RectangleTextureGLTest::construct,
&RectangleTextureGLTest::constructNoCreate,
&RectangleTextureGLTest::wrap,
&RectangleTextureGLTest::bind,
@ -105,6 +107,17 @@ void RectangleTextureGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void RectangleTextureGLTest::constructNoCreate() {
{
RectangleTexture texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void RectangleTextureGLTest::wrap() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));

13
src/Magnum/Test/RenderbufferGLTest.cpp

@ -36,6 +36,7 @@ struct RenderbufferGLTest: AbstractOpenGLTester {
explicit RenderbufferGLTest();
void construct();
void constructNoCreate();
void constructCopy();
void constructMove();
void wrap();
@ -48,6 +49,7 @@ struct RenderbufferGLTest: AbstractOpenGLTester {
RenderbufferGLTest::RenderbufferGLTest() {
addTests({&RenderbufferGLTest::construct,
&RenderbufferGLTest::constructNoCreate,
&RenderbufferGLTest::constructCopy,
&RenderbufferGLTest::constructMove,
&RenderbufferGLTest::wrap,
@ -74,6 +76,17 @@ void RenderbufferGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void RenderbufferGLTest::constructNoCreate() {
{
Renderbuffer renderbuffer{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(renderbuffer.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void RenderbufferGLTest::constructCopy() {
CORRADE_VERIFY(!(std::is_constructible<Renderbuffer, const Renderbuffer&>{}));
CORRADE_VERIFY(!(std::is_assignable<Renderbuffer, const Renderbuffer&>{}));

15
src/Magnum/Test/SampleQueryGLTest.cpp

@ -41,6 +41,7 @@ namespace Magnum { namespace Test {
struct SampleQueryGLTest: AbstractOpenGLTester {
explicit SampleQueryGLTest();
void constructNoCreate();
void wrap();
void querySamplesPassed();
@ -50,7 +51,8 @@ struct SampleQueryGLTest: AbstractOpenGLTester {
};
SampleQueryGLTest::SampleQueryGLTest() {
addTests({&SampleQueryGLTest::wrap,
addTests({&SampleQueryGLTest::constructNoCreate,
&SampleQueryGLTest::wrap,
&SampleQueryGLTest::querySamplesPassed,
#ifndef MAGNUM_TARGET_GLES
@ -59,6 +61,17 @@ SampleQueryGLTest::SampleQueryGLTest() {
});
}
void SampleQueryGLTest::constructNoCreate() {
{
SampleQuery query{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(query.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void SampleQueryGLTest::wrap() {
#ifdef MAGNUM_TARGET_GLES2
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::occlusion_query_boolean>())

26
src/Magnum/Test/TextureArrayGLTest.cpp

@ -42,8 +42,10 @@ struct TextureArrayGLTest: AbstractOpenGLTester {
#ifndef MAGNUM_TARGET_GLES
void construct1D();
void construct1DNoCreate();
#endif
void construct2D();
void construct2DNoCreate();
#ifndef MAGNUM_TARGET_GLES
void wrap1D();
@ -134,8 +136,10 @@ TextureArrayGLTest::TextureArrayGLTest() {
addTests({
#ifndef MAGNUM_TARGET_GLES
&TextureArrayGLTest::construct1D,
&TextureArrayGLTest::construct1DNoCreate,
#endif
&TextureArrayGLTest::construct2D,
&TextureArrayGLTest::construct2DNoCreate,
#ifndef MAGNUM_TARGET_GLES
&TextureArrayGLTest::wrap1D,
@ -231,6 +235,17 @@ void TextureArrayGLTest::construct1D() {
MAGNUM_VERIFY_NO_ERROR();
}
void TextureArrayGLTest::construct1DNoCreate() {
{
Texture1DArray texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
#endif
void TextureArrayGLTest::construct2D() {
@ -249,6 +264,17 @@ void TextureArrayGLTest::construct2D() {
MAGNUM_VERIFY_NO_ERROR();
}
void TextureArrayGLTest::construct2DNoCreate() {
{
Texture2DArray texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
#ifndef MAGNUM_TARGET_GLES
void TextureArrayGLTest::wrap1D() {
GLuint id;

39
src/Magnum/Test/TextureGLTest.cpp

@ -44,9 +44,12 @@ struct TextureGLTest: AbstractOpenGLTester {
#ifndef MAGNUM_TARGET_GLES
void construct1D();
void construct1DNoCreate();
#endif
void construct2D();
void construct2DNoCreate();
void construct3D();
void construct3DNoCreate();
#ifndef MAGNUM_TARGET_GLES
void wrap1D();
@ -165,9 +168,12 @@ TextureGLTest::TextureGLTest() {
addTests({
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::construct1D,
&TextureGLTest::construct1DNoCreate,
#endif
&TextureGLTest::construct2D,
&TextureGLTest::construct2DNoCreate,
&TextureGLTest::construct3D,
&TextureGLTest::construct3DNoCreate,
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::wrap1D,
@ -292,6 +298,17 @@ void TextureGLTest::construct1D() {
MAGNUM_VERIFY_NO_ERROR();
}
void TextureGLTest::construct1DNoCreate() {
{
Texture1D texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
#endif
void TextureGLTest::construct2D() {
@ -305,6 +322,17 @@ void TextureGLTest::construct2D() {
MAGNUM_VERIFY_NO_ERROR();
}
void TextureGLTest::construct2DNoCreate() {
{
Texture2D texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void TextureGLTest::construct3D() {
#ifdef MAGNUM_TARGET_GLES2
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_3D>())
@ -321,6 +349,17 @@ void TextureGLTest::construct3D() {
MAGNUM_VERIFY_NO_ERROR();
}
void TextureGLTest::construct3DNoCreate() {
{
Texture3D texture{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(texture.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
#ifndef MAGNUM_TARGET_GLES
void TextureGLTest::wrap1D() {
GLuint id;

13
src/Magnum/Test/TransformFeedbackGLTest.cpp

@ -37,6 +37,7 @@ struct TransformFeedbackGLTest: AbstractOpenGLTester {
explicit TransformFeedbackGLTest();
void construct();
void constructNoCreate();
void constructCopy();
void constructMove();
void wrap();
@ -55,6 +56,7 @@ struct TransformFeedbackGLTest: AbstractOpenGLTester {
TransformFeedbackGLTest::TransformFeedbackGLTest() {
addTests({&TransformFeedbackGLTest::construct,
&TransformFeedbackGLTest::constructNoCreate,
&TransformFeedbackGLTest::constructCopy,
&TransformFeedbackGLTest::constructMove,
&TransformFeedbackGLTest::wrap,
@ -88,6 +90,17 @@ void TransformFeedbackGLTest::construct() {
MAGNUM_VERIFY_NO_ERROR();
}
void TransformFeedbackGLTest::constructNoCreate() {
{
TransformFeedback feedback{NoCreate};
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(feedback.id(), 0);
}
MAGNUM_VERIFY_NO_ERROR();
}
void TransformFeedbackGLTest::constructCopy() {
CORRADE_VERIFY(!(std::is_constructible<TransformFeedback, const TransformFeedback&>{}));
CORRADE_VERIFY(!(std::is_assignable<TransformFeedback, const TransformFeedback&>{}));

4
src/Magnum/Text/Test/RendererGLTest.cpp

@ -172,7 +172,7 @@ void RendererGLTest::renderData() {
void RendererGLTest::renderMesh() {
TestFont font;
Mesh mesh;
Mesh mesh{NoCreate};
Buffer vertexBuffer, indexBuffer;
Range2D bounds;
std::tie(mesh, bounds) = Text::Renderer3D::render(font, nullGlyphCache,
@ -220,7 +220,7 @@ void RendererGLTest::renderMesh() {
void RendererGLTest::renderMeshIndexType() {
#ifndef MAGNUM_TARGET_GLES
TestFont font;
Mesh mesh;
Mesh mesh{NoCreate};
Buffer vertexBuffer, indexBuffer;
/* Sizes: four vertices per glyph, each vertex has 2D position and 2D

16
src/Magnum/Texture.h

@ -145,12 +145,22 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* Creates new OpenGL texture object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the texture is created on
* first use.
* @see @ref wrap(), @fn_gl{CreateTextures} with @def_gl{TEXTURE_1D},
* @def_gl{TEXTURE_2D} or @def_gl{TEXTURE_3D}, eventually
* @fn_gl{GenTextures}
* @see @ref Texture(NoCreateT), @ref wrap(), @fn_gl{CreateTextures}
* with @def_gl{TEXTURE_1D}, @def_gl{TEXTURE_2D} or
* @def_gl{TEXTURE_3D}, eventually @fn_gl{GenTextures}
*/
explicit Texture(): AbstractTexture(Implementation::textureTarget<dimensions>()) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref Texture(), @ref wrap()
*/
explicit Texture(NoCreateT) noexcept: AbstractTexture{NoCreate, Implementation::textureTarget<dimensions>()} {}
#ifndef MAGNUM_TARGET_GLES2
/**
* @brief Set base mip level

14
src/Magnum/TextureArray.h

@ -133,12 +133,22 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* Creates new OpenGL texture object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the texture is created on
* first use.
* @see @ref wrap(), @fn_gl{CreateTextures} with
* @def_gl{TEXTURE_1D_ARRAY} or @def_gl{TEXTURE_2D_ARRAY},
* @see @ref TextureArray(NoCreateT), @ref wrap(), @fn_gl{CreateTextures}
* with @def_gl{TEXTURE_1D_ARRAY} or @def_gl{TEXTURE_2D_ARRAY},
* eventually @fn_gl{GenTextures}
*/
explicit TextureArray(): AbstractTexture(Implementation::textureArrayTarget<dimensions>()) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref TextureArray(), @ref wrap()
*/
explicit TextureArray(NoCreateT) noexcept: AbstractTexture{NoCreate, Implementation::textureArrayTarget<dimensions>()} {}
/**
* @copybrief Texture::setBaseLevel()
* @return Reference to self (for method chaining)

13
src/Magnum/TimeQuery.h

@ -126,10 +126,21 @@ class TimeQuery: public AbstractQuery {
* Creates new OpenGL query object. If @extension{ARB,direct_state_access}
* (part of OpenGL 4.5) is not available, the query is created on first
* use.
* @see @ref wrap(), @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries}
* @see @ref TimeQuery(NoCreateT), @ref wrap(), @fn_gl{CreateQueries},
* eventually @fn_gl{GenQueries}
*/
explicit TimeQuery(Target target): AbstractQuery(GLenum(target)) {}
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref TimeQuery(Target), @ref wrap()
*/
explicit TimeQuery(NoCreateT) noexcept: AbstractQuery{NoCreate, GLenum(Target::TimeElapsed)} {}
/**
* @brief Query timestamp
*

14
src/Magnum/TransformFeedback.h

@ -28,6 +28,7 @@
#include <Corrade/Containers/ArrayView.h>
#include "Magnum/AbstractObject.h"
#include "Magnum/Tags.h"
#ifndef MAGNUM_TARGET_GLES2
/** @file
@ -168,11 +169,22 @@ class MAGNUM_EXPORT TransformFeedback: public AbstractObject {
* Creates new OpenGL transform feedback object. If
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) is not
* available, the transform feedback object is created on first use.
* @see @ref wrap(), @fn_gl{CreateTransformFeedbacks}, eventually
* @see @ref TransformFeedback(NoCreateT), @ref wrap(),
* @fn_gl{CreateTransformFeedbacks}, eventually
* @fn_gl{GenTransformFeedbacks}
*/
explicit TransformFeedback();
/**
* @brief Construct without creating the underlying OpenGL object
*
* The constructed instance is equivalent to moved-from state. Useful
* in cases where you will overwrite the instance later anyway. Move
* another object over it to make it useful.
* @see @ref TransformFeedback(), @ref wrap()
*/
explicit TransformFeedback(NoCreateT) noexcept: _id{0}, _flags{ObjectFlag::DeleteOnDestruction} {}
/** @brief Copying is not allowed */
TransformFeedback(const TransformFeedback&) = delete;

Loading…
Cancel
Save