diff --git a/doc/building.dox b/doc/building.dox
index 94062358b..3a05ead28 100644
--- a/doc/building.dox
+++ b/doc/building.dox
@@ -104,12 +104,10 @@ within QtCreator by adding new `make install` build rule.
@subsubsection building-windows-troubleshooting Windows troubleshooting
-If CMake isn't able to find dependencies (e.g. %Corrade is not found) and you
-have installed them to MinGW directory, point to `CMAKE_FIND_ROOT_PATH` to
-MinGW installation prefix, e.g. specify `-DCMAKE_FIND_ROOT_PATH=C:/MinGW/`
-CMake parameter.
-
-See also Corrade's @ref building-corrade-windows-troubleshooting "troubleshooting section".
+If CMake isn't able to find dependencies (e.g. %Corrade is not found), point
+`CMAKE_FIND_ROOT_PATH` and `CMAKE_INSTALL_PREFIX` to installation prefix of
+dependency libraries, e.g. specify `-DCMAKE_FIND_ROOT_PATH=C:/MinGW/` CMake
+parameter.
@subsection building-features Enabling or disabling features
diff --git a/doc/getting-started-blue.png b/doc/getting-started-blue.png
index 554613df2..50b64d15c 100644
Binary files a/doc/getting-started-blue.png and b/doc/getting-started-blue.png differ
diff --git a/doc/getting-started.dox b/doc/getting-started.dox
index c14c3e56f..297862778 100644
--- a/doc/getting-started.dox
+++ b/doc/getting-started.dox
@@ -94,8 +94,7 @@ class MyApplication: public Platform::Application {
public:
explicit MyApplication(const Arguments& arguments);
- protected:
- void viewportEvent(const Vector2i& size) override;
+ private:
void drawEvent() override;
};
@@ -103,10 +102,6 @@ MyApplication::MyApplication(const Arguments& arguments): Platform::Application(
// TODO: Add your initialization code here
}
-void MyApplication::viewportEvent(const Vector2i& size) {
- defaultFramebuffer.setViewport({{}, size});
-}
-
void MyApplication::drawEvent() {
defaultFramebuffer.clear(FramebufferClear::Color);
@@ -118,10 +113,10 @@ void MyApplication::drawEvent() {
MAGNUM_APPLICATION_MAIN(MyApplication)
@endcode
-The application essentially does nothing, just clears properly sized screen
-framebuffer to default (black) color and then does buffer swap to actually
-display it on the screen. `CMakeLists.txt` finds %Magnum, sets up compiler
-flags, creates the executable and links it to all needed libraries:
+The application essentially does nothing, just clears screen framebuffer to
+default (dark gray) color and then does buffer swap to actually display it on
+the screen. `CMakeLists.txt` finds %Magnum, sets up compiler flags, creates the
+executable and links it to all needed libraries:
@code
find_package(Magnum REQUIRED GlutApplication)
@@ -181,9 +176,8 @@ Debug() << "Hello! This application is running on" << Context::current()->versio
After rebuilding and starting the application, the clear color changes to
blueish one and something like this would be printed to the console:
-@code
-Hello! This application is running on OpenGL 3.3 using Geforce GT 330M
-@endcode
+
+> Hello! This application is running on OpenGL 3.3 using Geforce GT 330M
@image html getting-started-blue.png
@image latex getting-started-blue.png
diff --git a/doc/getting-started.png b/doc/getting-started.png
index cc0fc6112..7f4cf8c3a 100644
Binary files a/doc/getting-started.png and b/doc/getting-started.png differ
diff --git a/doc/platform.dox b/doc/platform.dox
index 463066526..fe4f82af3 100644
--- a/doc/platform.dox
+++ b/doc/platform.dox
@@ -47,15 +47,15 @@ Windowed applications provide a window and keyboard and mouse handling. The
most basic toolkit (and toolkit packaged for most systems) is GLUT, which is
implemented in @ref Platform::GlutApplication. As said above, the usage is
similar for all toolkits, you must provide one-argument constructor and
-implement at least @ref GlutApplication::viewportEvent() "viewportEvent()" and
-@ref GlutApplication::drawEvent() "drawEvent()". The class can be then used
-directly in `main()`, but for convenience and portability it's better to use
-@ref MAGNUM_GLUTAPPLICATION_MAIN() macro.
+implement at least @ref GlutApplication::drawEvent() "drawEvent()" function.
+The class can be then used directly in `main()`, but for convenience and
+portability it's better to use @ref MAGNUM_GLUTAPPLICATION_MAIN() macro.
To simplify the porting, the library provides `Platform::Application` typedef
and `MAGNUM_APPLICATION_MAIN()` macro (but only if only one application header
is included, to avoid ambiguity). Changing the code to use different toolkit is
-then matter of replacing only the #`include` statement.
+then matter of replacing only the #`include` statement (and changing
+one line in CMake build script, as you see later).
Barebone application implementation which will just clear the window to dark
blue color is shown in the following code listing.
@@ -76,7 +76,7 @@ class MyApplication: public Platform::Application {
public:
MyApplication(const Arguments& arguments);
- void viewportEvent(const Vector2i& viewport) override;
+ private:
void drawEvent() override;
};
@@ -85,11 +85,6 @@ MyApplication::MyApplication(const Arguments& arguments): Platform::Application(
Renderer::setClearColor({0.0f, 0.0f, 0.4f});
}
-void MyApplication::viewportEvent(const Vector2i& size) {
- // Resize the framebuffer to new window size
- defaultFramebuffer.setViewport({{}, size});
-}
-
void MyApplication::drawEvent() {
// Clear the window
defaultFramebuffer.clear(DefaultFramebuffer::Clear::Color);
@@ -102,6 +97,28 @@ void MyApplication::drawEvent() {
MAGNUM_APPLICATION_MAIN(MyApplication)
@endcode
+@subsection platform-windowed-viewport Responding to viewport size changes
+
+By default the application doesn't respond to window size changes in any way,
+as the window has fixed size in most cases. To respond to size change for
+example by resizing the default framebuffer, you need to reimplement
+@ref GlutApplication::viewportEvent() "viewportEvent()" function and pass the
+new size to the framebuffer:
+@code
+class MyApplication: public Platform::Application {
+ // ...
+
+ private:
+ void viewportEvent(const Vector2i& size) override;
+};
+
+// ...
+
+void MyApplication::viewportEvent(const Vector2i& size) {
+ defaultFramebuffer.setViewport({{}, size});
+}
+@endcode
+
@section platform-windowless Windowless applications
Windowless applications provide just a context for ofscreen rendering or
@@ -166,8 +183,9 @@ to it.
Again, to simplify porting, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}`
and `${MAGNUM_WAPPLICATION_LIBRARIES}` aliases (or `${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}`, `${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` for windowless applications), but
only if only one application (windowless application) component is requested to
-avoid ambiguity. Changing the code to use different toolkit is then matter of
-replacing only the requested `*Application` component.
+avoid ambiguity. Changing the build script to use different toolkit is then
+matter of replacing only the requested `*Application` component (and one
+#`include` line in the actual code, as said above).
@code
find_package(Magnum REQUIRED GlutApplication)
diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h
index 119cee213..ffb740b9b 100644
--- a/src/AbstractShaderProgram.h
+++ b/src/AbstractShaderProgram.h
@@ -340,7 +340,7 @@ class MAGNUM_EXPORT AbstractShaderProgram {
* @deprecated Use @ref Magnum::AbstractShaderProgram::maxVertexAttributes() "maxVertexAttributes()"
* instead.
*/
- static Int maxSupportedVertexAttributeCount() { return maxVertexAttributes(); }
+ static CORRADE_DEPRECATED("use maxVertexAttributes() instead") Int maxSupportedVertexAttributeCount() { return maxVertexAttributes(); }
#endif
#ifndef MAGNUM_TARGET_GLES
diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h
index 596cfe69a..4687bac5e 100644
--- a/src/AbstractTexture.h
+++ b/src/AbstractTexture.h
@@ -121,7 +121,7 @@ class MAGNUM_EXPORT AbstractTexture {
* @deprecated Use @ref Magnum::AbstractTexture::maxLayers() "maxLayers()"
* instead.
*/
- static Int maxSupportedLayerCount() { return maxLayers(); }
+ static CORRADE_DEPRECATED("use maxLayers() instead") Int maxSupportedLayerCount() { return maxLayers(); }
#endif
#ifndef MAGNUM_TARGET_GLES
diff --git a/src/Audio/AbstractImporter.cpp b/src/Audio/AbstractImporter.cpp
index 51ee765e7..52fd83bb6 100644
--- a/src/Audio/AbstractImporter.cpp
+++ b/src/Audio/AbstractImporter.cpp
@@ -24,9 +24,9 @@
#include "AbstractImporter.h"
-#include
#include
#include
+#include
namespace Magnum { namespace Audio {
@@ -57,22 +57,12 @@ void AbstractImporter::doOpenFile(const std::string& filename) {
CORRADE_ASSERT(features() & Feature::OpenData, "Audio::AbstractImporter::openFile(): not implemented", );
/* Open file */
- std::ifstream in(filename.data(), std::ios::binary);
- if(!in.good()) {
+ if(!Utility::Directory::fileExists(filename)) {
Error() << "Trade::AbstractImporter::openFile(): cannot open file" << filename;
return;
}
- /* Create array to hold file contents */
- in.seekg(0, std::ios::end);
- Containers::Array data(in.tellg());
-
- /* Read data, close */
- in.seekg(0, std::ios::beg);
- in.read(reinterpret_cast(data.begin()), data.size());
- in.close();
-
- doOpenData(data);
+ doOpenData(Utility::Directory::read(filename));
}
void AbstractImporter::close() {
diff --git a/src/Buffer.h b/src/Buffer.h
index bb92e44f2..1c119c343 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -306,7 +306,7 @@ class MAGNUM_EXPORT Buffer {
* @copybrief BufferUsage
* @deprecated Use @ref Magnum::BufferUsage "BufferUsage" instead.
*/
- typedef BufferUsage Usage;
+ typedef CORRADE_DEPRECATED("use BufferUsage instead") BufferUsage Usage;
#endif
/**
@@ -653,7 +653,7 @@ class MAGNUM_EXPORT Buffer {
* @deprecated Use @ref Magnum::Buffer::setData(Containers::ArrayReference, BufferUsage) "setData(Containers::ArrayReference, BufferUsage)"
* instead.
*/
- Buffer& setData(GLsizeiptr size, const GLvoid* data, BufferUsage usage) {
+ CORRADE_DEPRECATED("use setData(Containers::ArrayReference, BufferUsage) instead") Buffer& setData(GLsizeiptr size, const GLvoid* data, BufferUsage usage) {
return setData({data, std::size_t(size)}, usage);
}
#endif
@@ -693,7 +693,7 @@ class MAGNUM_EXPORT Buffer {
* @deprecated Use @ref Magnum::Buffer::setSubData(GLintptr, Containers::ArrayReference) "setSubData(GLintptr, Containers::ArrayReference)"
* instead.
*/
- Buffer& setSubData(GLintptr offset, GLsizeiptr size, const GLvoid* data) {
+ CORRADE_DEPRECATED("use setSubData(GLintptr, Containers::ArrayReference) instead") Buffer& setSubData(GLintptr offset, GLsizeiptr size, const GLvoid* data) {
return setSubData(offset, {data, std::size_t(size)});
}
#endif
diff --git a/src/BufferImage.h b/src/BufferImage.h
index fbc472d64..d92d62ef5 100644
--- a/src/BufferImage.h
+++ b/src/BufferImage.h
@@ -26,7 +26,7 @@
#ifndef MAGNUM_TARGET_GLES2
/** @file
- * @brief Class Magnum::BufferImage, typedef Magnum::BufferImage1D, Magnum::BufferImage2D, Magnum::BufferImage3D
+ * @brief Class @ref Magnum::BufferImage, typedef @ref Magnum::BufferImage1D, @ref Magnum::BufferImage2D, @ref Magnum::BufferImage3D
*/
#endif
@@ -41,9 +41,9 @@ namespace Magnum {
/**
@brief %Buffer image
-Stores image data in GPU memory. Interchangeable with Image, ImageReference or
-Trade::ImageData.
-@see BufferImage1D, BufferImage2D, BufferImage3D, Buffer
+Stores image data in GPU memory. Interchangeable with @ref Image,
+@ref ImageReference or @ref Trade::ImageData.
+@see @ref BufferImage1D, @ref BufferImage2D, @ref BufferImage3D, @ref Buffer
@requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0.
*/
template class MAGNUM_EXPORT BufferImage: public AbstractImage {
@@ -55,8 +55,8 @@ template class MAGNUM_EXPORT BufferImage: public Abstrac
* @param format Format of pixel data
* @param type Data type of pixel data
*
- * Dimensions and buffer are empty, call setData() to fill the image
- * with data.
+ * Dimensions and buffer are empty, call @ref setData() to fill the
+ * image with data.
*/
explicit BufferImage(ColorFormat format, ColorType type): AbstractImage(format, type) {
_buffer.setTargetHint(Buffer::Target::PixelPack);
@@ -78,8 +78,7 @@ template class MAGNUM_EXPORT BufferImage: public Abstrac
*
* Updates the image buffer with given data. The data are not deleted
* after filling the buffer.
- *
- * @see Buffer::setData()
+ * @see @ref Buffer::setData()
*/
void setData(const typename DimensionTraits::VectorType& size, ColorFormat format, ColorType type, const void* data, BufferUsage usage);
diff --git a/src/ColorFormat.h b/src/ColorFormat.h
index 54c014d7f..dadccf2cd 100644
--- a/src/ColorFormat.h
+++ b/src/ColorFormat.h
@@ -25,7 +25,7 @@
*/
/** @file
- * @brief Enum Magnum::ColorFormat, Magnum::ColorType
+ * @brief Enum @ref Magnum::ColorFormat, @ref Magnum::ColorType
*/
#include "Magnum.h"
@@ -38,9 +38,18 @@ namespace Magnum {
@brief Format of image data
Note that some formats can be used only for framebuffer reading (using
-AbstractFramebuffer::read()) and some only for texture data (using Texture::setImage()
-and others).
-@see Image, ImageReference, BufferImage, Trade::ImageData
+@ref AbstractFramebuffer::read()) and some only for texture data (using
+@ref Texture::setImage() and others), the limitations are mentioned in
+documentation of each particular value.
+
+In most cases you may want to use @ref ColorFormat::Red (for grayscale images),
+@ref ColorFormat::RGB or @ref ColorFormat::RGBA along with
+@ref ColorType::UnsignedByte, the matching texture format is then
+@ref TextureFormat::R8, @ref TextureFormat::RGB8 or @ref TextureFormat::RGBA8.
+See documentation of these values for possible limitations when using OpenGL ES
+2.0 or WebGL.
+
+@see @ref Image, @ref ImageReference, @ref BufferImage, @ref Trade::ImageData
*/
enum class ColorFormat: GLenum {
/**
@@ -57,14 +66,14 @@ enum class ColorFormat: GLenum {
#ifndef MAGNUM_TARGET_GLES
/**
* Floating-point green channel.
- * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::Red" is
+ * @requires_gl Only @ref Magnum::ColorFormat::Red "ColorFormat::Red" is
* available in OpenGL ES.
*/
Green = GL_GREEN,
/**
* Floating-point blue channel.
- * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::Red" is
+ * @requires_gl Only @ref Magnum::ColorFormat::Red "ColorFormat::Red" is
* available in OpenGL ES.
*/
Blue = GL_BLUE,
@@ -75,9 +84,9 @@ enum class ColorFormat: GLenum {
* Floating-point luminance channel. The value is used for all RGB
* channels.
* @deprecated_gl Included for compatibility reasons only, use
- * @ref Magnum::ColorFormat "ColorFormat::Red" instead.
+ * @ref Magnum::ColorFormat::Red "ColorFormat::Red" instead.
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
- * @ref Magnum::ColorFormat "ColorFormat::Red" instead.
+ * @ref Magnum::ColorFormat::Red "ColorFormat::Red" instead.
*/
Luminance = GL_LUMINANCE,
#endif
@@ -99,9 +108,9 @@ enum class ColorFormat: GLenum {
* Floating-point luminance and alpha channel. First value is used for all
* RGB channels, second value is used for alpha channel.
* @deprecated_gl Included for compatibility reasons only, use
- * @ref Magnum::ColorFormat "ColorFormat::RG" instead.
+ * @ref Magnum::ColorFormat::RG "ColorFormat::RG" instead.
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
- * @ref Magnum::ColorFormat "ColorFormat::RG" instead.
+ * @ref Magnum::ColorFormat::RG "ColorFormat::RG" instead.
*/
LuminanceAlpha = GL_LUMINANCE_ALPHA,
#endif
@@ -148,7 +157,7 @@ enum class ColorFormat: GLenum {
/**
* Integer green channel.
* @requires_gl30 %Extension @extension{EXT,texture_integer}
- * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::RedInteger"
+ * @requires_gl Only @ref Magnum::ColorFormat::RedInteger "ColorFormat::RedInteger"
* is available in OpenGL ES 3.0, only floating-point image data are
* available in OpenGL ES 2.0.
*/
@@ -157,8 +166,8 @@ enum class ColorFormat: GLenum {
/**
* Integer blue channel.
* @requires_gl30 %Extension @extension{EXT,texture_integer}
- * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::RedInteger" is
- * available in OpenGL ES 3.0, only floating-point image data are
+ * @requires_gl Only @ref Magnum::ColorFormat::RedInteger "ColorFormat::RedInteger"
+ * is available in OpenGL ES 3.0, only floating-point image data are
* available in OpenGL ES 2.0.
*/
BlueInteger = GL_BLUE_INTEGER,
@@ -194,8 +203,8 @@ enum class ColorFormat: GLenum {
/**
* Integer BGR.
* @requires_gl30 %Extension @extension{EXT,texture_integer}
- * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::RGBInteger" is
- * available in OpenGL ES 3.0, only floating-point image data are
+ * @requires_gl Only @ref Magnum::ColorFormat::RGBInteger "ColorFormat::RGBInteger"
+ * is available in OpenGL ES 3.0, only floating-point image data are
* available in OpenGL ES 2.0.
*/
BGRInteger = GL_BGR_INTEGER,
@@ -203,8 +212,8 @@ enum class ColorFormat: GLenum {
/**
* Integer BGRA.
* @requires_gl30 %Extension @extension{EXT,texture_integer}
- * @requires_gl Only @ref Magnum::ColorFormat "ColorFormat::RGBAInteger" is
- * available in OpenGL ES 3.0, only floating-point image data are
+ * @requires_gl Only @ref Magnum::ColorFormat::RGBAInteger "ColorFormat::RGBAInteger"
+ * is available in OpenGL ES 3.0, only floating-point image data are
* available in OpenGL ES 2.0.
*/
BGRAInteger = GL_BGRA_INTEGER,
@@ -251,9 +260,18 @@ enum class ColorFormat: GLenum {
@brief Type of image data
Note that some formats can be used only for framebuffer reading (using
-AbstractFramebuffer::read()) and some only for texture data (using Texture::setImage()
-and others).
-@see Image, ImageReference, BufferImage, Trade::ImageData
+@ref AbstractFramebuffer::read()) and some only for texture data (using
+@ref Texture::setImage() and others), the limitations are mentioned in
+documentation of each particular value.
+
+In most cases you may want to use @ref ColorType::UnsignedByte along with
+@ref ColorFormat::Red (for grayscale images), @ref ColorFormat::RGB or
+@ref ColorFormat::RGBA, the matching texture format is then
+@ref TextureFormat::R8, @ref TextureFormat::RGB8 or @ref TextureFormat::RGBA8.
+See documentation of these values for possible limitations when using OpenGL ES
+2.0 or WebGL.
+
+@see @ref Image, @ref ImageReference, @ref BufferImage, @ref Trade::ImageData
*/
enum class ColorType: GLenum {
/** Each component unsigned byte. */
@@ -263,8 +281,9 @@ enum class ColorType: GLenum {
/**
* Each component signed byte.
* @requires_gl Can't be used for framebuffer reading in OpenGL ES.
- * @requires_gles30 For texture data only, only @ref Magnum::ColorType "ColorType::UnsignedByte"
- * is available in OpenGL ES 2.0.
+ * @requires_gles30 For texture data only, only
+ * @ref Magnum::ColorType::UnsignedByte "ColorType::UnsignedByte" is
+ * available in OpenGL ES 2.0.
*/
Byte = GL_BYTE,
#endif
@@ -281,8 +300,9 @@ enum class ColorType: GLenum {
/**
* Each component signed short.
* @requires_gl Can't be used for framebuffer reading in OpenGL ES.
- * @requires_gles30 For texture data only, only @ref Magnum::ColorType "ColorType::UnsignedShort"
- * is available in OpenGL ES 2.0.
+ * @requires_gles30 For texture data only, only
+ * @ref Magnum::ColorType::UnsignedShort "ColorType::UnsignedShort" is
+ * available in OpenGL ES 2.0.
*/
Short = GL_SHORT,
#endif
@@ -298,7 +318,7 @@ enum class ColorType: GLenum {
#ifndef MAGNUM_TARGET_GLES2
/**
* Each component signed int.
- * @requires_gles30 Only @ref Magnum::ColorType "ColorType::UnsignedInt"
+ * @requires_gles30 Only @ref Magnum::ColorType::UnsignedInt "ColorType::UnsignedInt"
* is available in OpenGL ES 2.0.
*/
Int = GL_INT,
@@ -345,7 +365,7 @@ enum class ColorType: GLenum {
#ifndef MAGNUM_TARGET_GLES
/**
* BGR, unsigned short, red and blue 5bit, green 6bit.
- * @requires_gl Only @ref Magnum::ColorType "ColorType::RGB565" is
+ * @requires_gl Only @ref Magnum::ColorType::RGB565 "ColorType::RGB565" is
* available in OpenGL ES.
*/
UnsignedShort565Rev = GL_UNSIGNED_SHORT_5_6_5_REV,
@@ -388,22 +408,22 @@ enum class ColorType: GLenum {
#ifndef MAGNUM_TARGET_GLES
/**
* RGBA, unsigned int, each component 8bit.
- * @requires_gl Use @ref Magnum::ColorType "ColorType::UnsignedByte" in
- * OpenGL ES instead.
+ * @requires_gl Use @ref Magnum::ColorType::UnsignedByte "ColorType::UnsignedByte"
+ * in OpenGL ES instead.
*/
UnsignedInt8888 = GL_UNSIGNED_INT_8_8_8_8,
/**
* ABGR, unsigned int, each component 8bit.
* @requires_gl Only RGBA component ordering is available in OpenGL ES, see
- * @ref Magnum::ColorType "ColorType::UnsignedInt8888" for more
- * information.
+ * @ref Magnum::ColorType::UnsignedInt8888 "ColorType::UnsignedInt8888"
+ * for more information.
*/
UnsignedInt8888Rev = GL_UNSIGNED_INT_8_8_8_8_REV,
/**
* RGBA, unsigned int, each RGB component 10bit, alpha component 2bit.
- * @requires_gl Only @ref Magnum::ColorType "ColorType::UnsignedInt2101010Rev"
+ * @requires_gl Only @ref Magnum::ColorType::UnsignedInt2101010Rev "ColorType::UnsignedInt2101010Rev"
* is available in OpenGL ES.
*/
UnsignedInt1010102 = GL_UNSIGNED_INT_10_10_10_2,
@@ -455,7 +475,8 @@ enum class ColorType: GLenum {
* Float + unsigned int, depth component 32bit float, 24bit gap, stencil
* index 8bit.
* @requires_gl30 %Extension @extension{ARB,depth_buffer_float}
- * @requires_gles30 For texture data only, only @ref Magnum::ColorType "ColorType::UnsignedInt248"
+ * @requires_gles30 For texture data only, only
+ * @ref Magnum::ColorType::UnsignedInt248 "ColorType::UnsignedInt248"
* is available in OpenGL ES 2.0.
*/
Float32UnsignedInt248Rev = GL_FLOAT_32_UNSIGNED_INT_24_8_REV
diff --git a/src/DebugTools/ForceRenderer.cpp b/src/DebugTools/ForceRenderer.cpp
index e72c03551..cf5f75421 100644
--- a/src/DebugTools/ForceRenderer.cpp
+++ b/src/DebugTools/ForceRenderer.cpp
@@ -86,7 +86,7 @@ template ForceRenderer::ForceRenderer(SceneG
ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
Mesh* mesh = new Mesh;
- mesh->setPrimitive(Mesh::Primitive::Lines)
+ mesh->setPrimitive(MeshPrimitive::Lines)
.setIndexCount(indices.size())
.addVertexBuffer(*vertexBuffer, 0,
typename Shaders::Flat::Position(Shaders::Flat::Position::Components::Two))
diff --git a/src/DebugTools/Implementation/AbstractBoxRenderer.cpp b/src/DebugTools/Implementation/AbstractBoxRenderer.cpp
index 5c7624d37..8e5cd07b6 100644
--- a/src/DebugTools/Implementation/AbstractBoxRenderer.cpp
+++ b/src/DebugTools/Implementation/AbstractBoxRenderer.cpp
@@ -24,6 +24,7 @@
#include "AbstractBoxRenderer.h"
+#include "Mesh.h"
#include "Primitives/Cube.h"
#include "Primitives/Square.h"
#include "Trade/MeshData2D.h"
diff --git a/src/DebugTools/Implementation/CapsuleRenderer.cpp b/src/DebugTools/Implementation/CapsuleRenderer.cpp
index ef158ba7a..a2f3d9568 100644
--- a/src/DebugTools/Implementation/CapsuleRenderer.cpp
+++ b/src/DebugTools/Implementation/CapsuleRenderer.cpp
@@ -24,6 +24,7 @@
#include "CapsuleRenderer.h"
+#include "Mesh.h"
#include "MeshView.h"
#include "DebugTools/ResourceManager.h"
#include "DebugTools/ShapeRenderer.h"
diff --git a/src/DebugTools/ObjectRenderer.cpp b/src/DebugTools/ObjectRenderer.cpp
index 84cb49177..dd20e7d8c 100644
--- a/src/DebugTools/ObjectRenderer.cpp
+++ b/src/DebugTools/ObjectRenderer.cpp
@@ -164,7 +164,7 @@ template ObjectRenderer::ObjectRenderer(Scen
indexBuffer->setData(Renderer::indices, BufferUsage::StaticDraw);
ResourceManager::instance().set(this->indexBuffer.key(), indexBuffer, ResourceDataState::Final, ResourcePolicy::Manual);
- mesh->setPrimitive(Mesh::Primitive::Lines)
+ mesh->setPrimitive(MeshPrimitive::Lines)
.setIndexCount(Renderer::indices.size())
.addVertexBuffer(*vertexBuffer, 0,
typename Shaders::VertexColor::Position(),
diff --git a/src/Image.h b/src/Image.h
index 6c171af4e..1bdc52633 100644
--- a/src/Image.h
+++ b/src/Image.h
@@ -25,7 +25,7 @@
*/
/** @file
- * @brief Class Magnum::Image, typedef Magnum::Image1D, Magnum::Image2D, Magnum::Image3D
+ * @brief Class @ref Magnum::Image, typedef @ref Magnum::Image1D, @ref Magnum::Image2D, @ref Magnum::Image3D
*/
#include "ImageReference.h"
@@ -35,9 +35,9 @@ namespace Magnum {
/**
@brief %Image
-Stores image data on client memory. Interchangeable with ImageReference,
-BufferImage or Trade::ImageData.
-@see Image1D, Image2D, Image3D
+Stores image data on client memory. Interchangeable with @ref ImageReference,
+@ref BufferImage or @ref Trade::ImageData.
+@see @ref Image1D, @ref Image2D, @ref Image3D
*/
template class Image: public AbstractImage {
public:
@@ -60,8 +60,8 @@ template class Image: public AbstractImage {
* @param format Format of pixel data
* @param type Data type of pixel data
*
- * Dimensions and data pointer are set to zero, call setData() to fill
- * the image with data.
+ * Dimensions are set to zero and data pointer to `nullptr`, call
+ * @ref setData() to fill the image with data.
*/
explicit Image(ColorFormat format, ColorType type): AbstractImage(format, type), _data(nullptr) {}
@@ -80,17 +80,27 @@ template class Image: public AbstractImage {
/** @brief Destructor */
~Image() { delete[] _data; }
- /**
- * @brief Conversion to reference
- *
- * @todo GCC 4.8: don't allow this on rvalue-ref
- */
- /*implicit*/ operator ImageReference() const;
+ /** @brief Conversion to reference */
+ /*implicit*/ operator ImageReference()
+ #ifndef CORRADE_GCC47_COMPATIBILITY
+ const &;
+ #else
+ const;
+ #endif
+
+ #ifndef CORRADE_GCC47_COMPATIBILITY
+ /** @overload */
+ /*implicit*/ operator ImageReference() const && = delete;
+ #endif
/** @brief %Image size */
typename DimensionTraits::VectorType size() const { return _size; }
- /** @brief Pointer to raw data */
+ /**
+ * @brief Pointer to raw data
+ *
+ * @see @ref release()
+ */
unsigned char* data() { return _data; }
const unsigned char* data() const { return _data; } /**< @overload */
@@ -103,9 +113,19 @@ template class Image: public AbstractImage {
*
* Deletes previous data and replaces them with new. Note that the
* data are not copied, but they are deleted on destruction.
+ * @see @ref release()
*/
void setData(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size, void* data);
+ /**
+ * @brief Release data storage
+ *
+ * Returns the data pointer and resets internal state to default.
+ * Deleting the returned array is user responsibility.
+ * @see @ref setData()
+ */
+ unsigned char* release();
+
private:
Math::Vector _size;
unsigned char* _data;
@@ -132,10 +152,24 @@ template inline Image& Image::op
return *this;
}
-template inline Image::operator ImageReference() const {
+template inline Image::operator ImageReference()
+#ifndef CORRADE_GCC47_COMPATIBILITY
+const &
+#else
+const
+#endif
+{
return ImageReference(AbstractImage::format(), AbstractImage::type(), _size, _data);
}
+template inline unsigned char* Image::release() {
+ /** @todo I need `std::exchange` NOW. */
+ unsigned char* const data = _data;
+ _size = {};
+ _data = nullptr;
+ return data;
+}
+
}
#endif
diff --git a/src/ImageFormat.h b/src/ImageFormat.h
index 5ec6e8a31..68b65db46 100644
--- a/src/ImageFormat.h
+++ b/src/ImageFormat.h
@@ -38,13 +38,13 @@ namespace Magnum {
@copybrief ColorFormat
@deprecated Use @ref Magnum::ColorFormat "ColorFormat" instead.
*/
-typedef ColorFormat ImageFormat;
+typedef CORRADE_DEPRECATED("use ColorFormat instead") ColorFormat ImageFormat;
/**
@copybrief ColorType
@deprecated Use @ref Magnum::ColorType "ColorType" instead.
*/
-typedef ColorType ImageType;
+typedef CORRADE_DEPRECATED("use ColorType instead") ColorType ImageType;
}
#else
diff --git a/src/ImageReference.h b/src/ImageReference.h
index f41007d2c..d2f754e16 100644
--- a/src/ImageReference.h
+++ b/src/ImageReference.h
@@ -25,7 +25,7 @@
*/
/** @file
- * @brief Class Magnum::ImageReference
+ * @brief Class @ref Magnum::ImageReference, typedef @ref Magnum::ImageReference1D, @ref Magnum::ImageReference2D, @ref Magnum::ImageReference3D
*/
#include "Math/Vector3.h"
@@ -40,15 +40,14 @@ namespace Magnum {
Adds information about dimensions, color components and component type to some
data in memory.
-Unlike Image, this class doesn't delete the data on destruction, so it is
+Unlike @ref Image, this class doesn't delete the data on destruction, so it is
targeted for wrapping data which are either stored in stack/constant memory
(and shouldn't be deleted) or they are managed by someone else and have the
same properties for each frame, such as video stream. Thus it is not possible
to change image properties, only data pointer.
-Interchangeable with Image, BufferImage or Trade::ImageData.
-@see ImageReference1D, ImageReference2D, ImageReference3D
-@todo Provide const version somewhat
+Interchangeable with @ref Image, @ref BufferImage or @ref Trade::ImageData.
+@see @ref ImageReference1D, @ref ImageReference2D, @ref ImageReference3D
*/
template class ImageReference: public AbstractImage {
public:
@@ -61,7 +60,7 @@ template class ImageReference: public AbstractImage {
* @param size %Image size
* @param data %Image data
*/
- constexpr explicit ImageReference(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size, void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {}
+ constexpr explicit ImageReference(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size, const void* data): AbstractImage(format, type), _size(size), _data(reinterpret_cast(data)) {}
/**
* @brief Constructor
@@ -69,8 +68,8 @@ template class ImageReference: public AbstractImage {
* @param type Data type of pixel data
* @param size %Image size
*
- * Data pointer is set to zero, call setData() to fill the image with
- * data.
+ * Data pointer is set to `nullptr`, call @ref setData() to fill the
+ * image with data.
*/
constexpr explicit ImageReference(ColorFormat format, ColorType type, const typename DimensionTraits::VectorType& size): AbstractImage(format, type), _size(size), _data(nullptr) {}
@@ -78,8 +77,7 @@ template class ImageReference: public AbstractImage {
constexpr typename DimensionTraits::VectorType size() const { return _size; }
/** @brief Pointer to raw data */
- unsigned char* data() { return _data; }
- constexpr const unsigned char* data() const { return _data; } /**< @overload */
+ constexpr const unsigned char* data() const { return _data; }
/**
* @brief Set image data
@@ -89,13 +87,13 @@ template class ImageReference: public AbstractImage {
* passed in constructor. The data are not copied nor deleted on
* destruction.
*/
- void setData(void* data) {
- _data = reinterpret_cast(data);
+ void setData(const void* data) {
+ _data = reinterpret_cast(data);
}
private:
Math::Vector _size;
- unsigned char* _data;
+ const unsigned char* _data;
};
/** @brief One-dimensional image wrapper */
diff --git a/src/Magnum.h b/src/Magnum.h
index cbc81dd25..fbd020fbb 100644
--- a/src/Magnum.h
+++ b/src/Magnum.h
@@ -34,6 +34,10 @@
#include "Types.h"
#include "magnumConfigure.h"
+#ifdef MAGNUM_BUILD_DEPRECATED
+#include
+#endif
+
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef unsigned int GLenum; /* Needed for *Format and *Type enums */
#endif
@@ -330,15 +334,15 @@ typedef Math::Range3D Range3Di;
#ifdef MAGNUM_BUILD_DEPRECATED
/**
@copybrief Range2D
-@deprecated Use @ref Magnum::Range2D instead.
+@deprecated Use @ref Magnum::Range2D "Range2D" instead.
*/
-typedef Math::Geometry::Rectangle Rectangle;
+typedef CORRADE_DEPRECATED("use Range2D instead") Math::Geometry::Rectangle Rectangle;
/**
@copybrief Range2Di
-@deprecated Use @ref Magnum::Range2Di instead.
+@deprecated Use @ref Magnum::Range2Di "Range2Di" instead.
*/
-typedef Math::Geometry::Rectangle Rectanglei;
+typedef CORRADE_DEPRECATED("use Range2Di instead") Math::Geometry::Rectangle Rectanglei;
#endif
/*@}*/
@@ -388,7 +392,7 @@ typedef Math::Matrix<2, Double> Matrix2x2d;
@copybrief Matrix2x2d
@deprecated Use @ref Magnum::Matrix2x2d "Matrix2x2d" instead.
*/
-typedef Math::Matrix<2, Double> Matrix2d;
+typedef CORRADE_DEPRECATED("use Matrix2x2d instead") Math::Matrix<2, Double> Matrix2d;
#endif
/**
@@ -496,7 +500,7 @@ typedef Math::Range3D Range3Dd;
@copybrief Range2Dd
@deprecated Use @ref Magnum::Range2Dd instead.
*/
-typedef Math::Geometry::Rectangle Rectangled;
+typedef CORRADE_DEPRECATED("use Range2Dd instead") Math::Geometry::Rectangle Rectangled;
#endif
/*@}*/
@@ -585,6 +589,8 @@ typedef ImageReference<1> ImageReference1D;
typedef ImageReference<2> ImageReference2D;
typedef ImageReference<3> ImageReference3D;
+enum class MeshPrimitive: GLenum;
+
class Mesh;
class MeshView;
diff --git a/src/Math/Geometry/CMakeLists.txt b/src/Math/Geometry/CMakeLists.txt
index ad0e92d5e..fafc17d75 100644
--- a/src/Math/Geometry/CMakeLists.txt
+++ b/src/Math/Geometry/CMakeLists.txt
@@ -26,14 +26,14 @@ set(MagnumMathGeometry_HEADERS
Distance.h
Intersection.h)
-install(FILES ${MagnumMathGeometry_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Geometry)
-
# Deprecated headers
if(BUILD_DEPRECATED)
set(MagnumMathGeometry_HEADERS ${MagnumMathGeometry_HEADERS}
Rectangle.h)
endif()
+install(FILES ${MagnumMathGeometry_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Geometry)
+
if(BUILD_TESTS)
add_subdirectory(Test)
endif()
diff --git a/src/Math/Geometry/Rectangle.h b/src/Math/Geometry/Rectangle.h
index bd2153a41..c3833fbf4 100644
--- a/src/Math/Geometry/Rectangle.h
+++ b/src/Math/Geometry/Rectangle.h
@@ -32,13 +32,15 @@
#include "Math/Range.h"
#ifdef MAGNUM_BUILD_DEPRECATED
+#include
+
namespace Magnum { namespace Math { namespace Geometry {
/**
@copybrief Math::Range2D
-@deprecated Use @ref Magnum::Math::Range2D instead.
+@deprecated Use @ref Magnum::Math::Range2D "Math::Range2D" instead.
*/
-template class Rectangle: public Range2D {
+template class CORRADE_DEPRECATED("use Math::Range2D instead") Rectangle: public Range2D {
public:
/** @copydoc Range2D() */
constexpr Rectangle() = default;
diff --git a/src/Math/RectangularMatrix.h b/src/Math/RectangularMatrix.h
index 74f65894d..f040ed87e 100644
--- a/src/Math/RectangularMatrix.h
+++ b/src/Math/RectangularMatrix.h
@@ -185,20 +185,8 @@ template class RectangularMatrix {
*
* @see operator[]
*/
- T* data()
- #if !defined(CORRADE_GCC47_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
- &
- #endif
- { return _data[0].data(); }
-
- /** @overload */
- constexpr const T* data()
- #if !defined(CORRADE_GCC47_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
- const &
- #else
- const
- #endif
- { return _data[0].data(); }
+ T* data() { return _data[0].data(); }
+ constexpr const T* data() const { return _data[0].data(); } /**< @overload */
/**
* @brief %Matrix column
diff --git a/src/Math/Vector.h b/src/Math/Vector.h
index a3c1e4f81..510a083da 100644
--- a/src/Math/Vector.h
+++ b/src/Math/Vector.h
@@ -199,28 +199,8 @@ template class Vector {
*
* @see operator[]()
*/
- T* data()
- #if !defined(CORRADE_GCC47_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
- &
- #endif
- #ifndef CORRADE_MSVC2013_COMPATIBILITY
- { return _data; }
- #else
- { return _data.data(); }
- #endif
-
- /** @overload */
- constexpr const T* data()
- #if !defined(CORRADE_GCC47_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
- const &
- #else
- const
- #endif
- #ifndef CORRADE_MSVC2013_COMPATIBILITY
- { return _data; }
- #else
- { return _data.data(); }
- #endif
+ T* data() { return _data; }
+ constexpr const T* data() const { return _data; } /**< @overload */
/**
* @brief Value at given position
diff --git a/src/Mesh.cpp b/src/Mesh.cpp
index bfd3d8ed7..bb2235e17 100644
--- a/src/Mesh.cpp
+++ b/src/Mesh.cpp
@@ -82,7 +82,7 @@ std::size_t Mesh::indexSize(IndexType type) {
CORRADE_ASSERT_UNREACHABLE();
}
-Mesh::Mesh(Primitive primitive): _primitive(primitive), _vertexCount(0), _indexCount(0)
+Mesh::Mesh(MeshPrimitive primitive): _primitive(primitive), _vertexCount(0), _indexCount(0)
#ifndef MAGNUM_TARGET_GLES2
, _indexStart(0), _indexEnd(0)
#endif
@@ -379,9 +379,9 @@ void Mesh::unbindImplementationDefault() {
void Mesh::unbindImplementationVAO() {}
#ifndef DOXYGEN_GENERATING_OUTPUT
-Debug operator<<(Debug debug, Mesh::Primitive value) {
+Debug operator<<(Debug debug, MeshPrimitive value) {
switch(value) {
- #define _c(value) case Mesh::Primitive::value: return debug << "Mesh::Primitive::" #value;
+ #define _c(value) case MeshPrimitive::value: return debug << "MeshPrimitive::" #value;
_c(Points)
_c(LineStrip)
_c(LineLoop)
@@ -401,7 +401,7 @@ Debug operator<<(Debug debug, Mesh::Primitive value) {
#undef _c
}
- return debug << "Mesh::Primitive::(invalid)";
+ return debug << "MeshPrimitive::(invalid)";
}
Debug operator<<(Debug debug, Mesh::IndexType value) {
@@ -421,9 +421,9 @@ Debug operator<<(Debug debug, Mesh::IndexType value) {
namespace Corrade { namespace Utility {
-std::string ConfigurationValue::toString(Magnum::Mesh::Primitive value, ConfigurationValueFlags) {
+std::string ConfigurationValue::toString(Magnum::MeshPrimitive value, ConfigurationValueFlags) {
switch(value) {
- #define _c(value) case Magnum::Mesh::Primitive::value: return #value;
+ #define _c(value) case Magnum::MeshPrimitive::value: return #value;
_c(Points)
_c(LineStrip)
_c(LineLoop)
@@ -446,8 +446,8 @@ std::string ConfigurationValue::toString(Magnum::Mesh::
return {};
}
-Magnum::Mesh::Primitive ConfigurationValue::fromString(const std::string& stringValue, ConfigurationValueFlags) {
- #define _c(value) if(stringValue == #value) return Magnum::Mesh::Primitive::value;
+Magnum::MeshPrimitive ConfigurationValue::fromString(const std::string& stringValue, ConfigurationValueFlags) {
+ #define _c(value) if(stringValue == #value) return Magnum::MeshPrimitive::value;
_c(LineStrip)
_c(LineLoop)
_c(Lines)
@@ -465,7 +465,7 @@ Magnum::Mesh::Primitive ConfigurationValue::fromString(
#endif
#undef _c
- return Magnum::Mesh::Primitive::Points;
+ return Magnum::MeshPrimitive::Points;
}
std::string ConfigurationValue::toString(Magnum::Mesh::IndexType value, ConfigurationValueFlags) {
diff --git a/src/Mesh.h b/src/Mesh.h
index 8af843eec..57af67504 100644
--- a/src/Mesh.h
+++ b/src/Mesh.h
@@ -35,6 +35,80 @@
namespace Magnum {
+/**
+ * @brief %Mesh primitive type
+ *
+ * @see @ref Mesh::primitive(), @ref Mesh::setPrimitive()
+ */
+enum class MeshPrimitive: GLenum {
+ /** Single points. */
+ Points = GL_POINTS,
+
+ /**
+ * First two vertices define first line segment, each following
+ * vertex defines another segment.
+ */
+ LineStrip = GL_LINE_STRIP,
+
+ /** Line strip, last and first vertex are connected together. */
+ LineLoop = GL_LINE_LOOP,
+
+ /**
+ * Each pair of vertices defines a single line, lines aren't
+ * connected together.
+ */
+ Lines = GL_LINES,
+
+ #ifndef MAGNUM_TARGET_GLES
+ /**
+ * Line strip with adjacency information.
+ * @requires_gl32 %Extension @extension{ARB,geometry_shader4}
+ */
+ LineStripAdjacency = GL_LINE_STRIP_ADJACENCY,
+
+ /**
+ * Lines with adjacency information.
+ * @requires_gl32 %Extension @extension{ARB,geometry_shader4}
+ */
+ LinesAdjacency = GL_LINES_ADJACENCY,
+ #endif
+
+ /**
+ * First three vertices define first triangle, each following
+ * vertex defines another triangle.
+ */
+ TriangleStrip = GL_TRIANGLE_STRIP,
+
+ /**
+ * First vertex is center, each following vertex is connected to
+ * previous and center vertex.
+ */
+ TriangleFan = GL_TRIANGLE_FAN,
+
+ /** Each three vertices define one triangle. */
+ Triangles = GL_TRIANGLES,
+
+ #ifndef MAGNUM_TARGET_GLES
+ /**
+ * Triangle strip with adjacency information.
+ * @requires_gl32 %Extension @extension{ARB,geometry_shader4}
+ */
+ TriangleStripAdjacency = GL_TRIANGLE_STRIP_ADJACENCY,
+
+ /**
+ * Triangles with adjacency information.
+ * @requires_gl32 %Extension @extension{ARB,geometry_shader4}
+ */
+ TrianglesAdjacency = GL_TRIANGLES_ADJACENCY,
+
+ /**
+ * Patches.
+ * @requires_gl40 %Extension @extension{ARB,tessellation_shader}
+ */
+ Patches = GL_PATCHES
+ #endif
+};
+
/**
@brief %Mesh
@@ -86,7 +160,7 @@ static constexpr Vector3 positions[30] = {
vertexBuffer.setData(positions, BufferUsage::StaticDraw);
// Set primitive and vertex count, add the buffer and specify its layout
-mesh.setPrimitive(Mesh::Primitive::Triangles)
+mesh.setPrimitive(MeshPrimitive::Triangles)
.setVertexCount(30)
.addVertexBuffer(vertexBuffer, 0, MyShader::Position());
@endcode
@@ -135,7 +209,7 @@ static constexpr GLubyte indices[75] = {
indexBuffer.setData(indices, BufferUsage::StaticDraw);
// Set primitive, index count, specify the buffers
-mesh.setPrimitive(Mesh::Primitive::Triangles)
+mesh.setPrimitive(MeshPrimitive::Triangles)
.setIndexCount(75)
.addVertexBuffer(vertexBuffer, 0, MyShader::Position())
.setIndexBuffer(indexBuffer, 0, Mesh::IndexType::UnsignedByte, 176, 229);
@@ -238,79 +312,13 @@ class MAGNUM_EXPORT Mesh {
friend class MeshView;
public:
+ #ifdef MAGNUM_BUILD_DEPRECATED
/**
- * @brief Primitive type
- *
- * @see @ref primitive(), @ref setPrimitive()
+ * @copybrief MeshPrimitive
+ * @deprecated Use @ref Magnum::MeshPrimitive "MeshPrimitive" instead.
*/
- enum class Primitive: GLenum {
- /** Single points. */
- Points = GL_POINTS,
-
- /**
- * First two vertices define first line segment, each following
- * vertex defines another segment.
- */
- LineStrip = GL_LINE_STRIP,
-
- /** Line strip, last and first vertex are connected together. */
- LineLoop = GL_LINE_LOOP,
-
- /**
- * Each pair of vertices defines a single line, lines aren't
- * connected together.
- */
- Lines = GL_LINES,
-
- #ifndef MAGNUM_TARGET_GLES
- /**
- * Line strip with adjacency information.
- * @requires_gl32 %Extension @extension{ARB,geometry_shader4}
- */
- LineStripAdjacency = GL_LINE_STRIP_ADJACENCY,
-
- /**
- * Lines with adjacency information.
- * @requires_gl32 %Extension @extension{ARB,geometry_shader4}
- */
- LinesAdjacency = GL_LINES_ADJACENCY,
- #endif
-
- /**
- * First three vertices define first triangle, each following
- * vertex defines another triangle.
- */
- TriangleStrip = GL_TRIANGLE_STRIP,
-
- /**
- * First vertex is center, each following vertex is connected to
- * previous and center vertex.
- */
- TriangleFan = GL_TRIANGLE_FAN,
-
- /** Each three vertices define one triangle. */
- Triangles = GL_TRIANGLES,
-
- #ifndef MAGNUM_TARGET_GLES
- /**
- * Triangle strip with adjacency information.
- * @requires_gl32 %Extension @extension{ARB,geometry_shader4}
- */
- TriangleStripAdjacency = GL_TRIANGLE_STRIP_ADJACENCY,
-
- /**
- * Triangles with adjacency information.
- * @requires_gl32 %Extension @extension{ARB,geometry_shader4}
- */
- TrianglesAdjacency = GL_TRIANGLES_ADJACENCY,
-
- /**
- * Patches.
- * @requires_gl40 %Extension @extension{ARB,tessellation_shader}
- */
- Patches = GL_PATCHES
- #endif
- };
+ typedef CORRADE_DEPRECATED("use MeshPrimitive instead") MeshPrimitive Primitive;
+ #endif
/**
* @brief Index type
@@ -377,7 +385,7 @@ class MAGNUM_EXPORT Mesh {
* @see @ref setPrimitive(), @ref setVertexCount(), @fn_gl{GenVertexArrays}
* (if @extension{APPLE,vertex_array_object} is available)
*/
- explicit Mesh(Primitive primitive = Primitive::Triangles);
+ explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles);
/** @brief Copying is not allowed */
Mesh(const Mesh&) = delete;
@@ -407,16 +415,16 @@ class MAGNUM_EXPORT Mesh {
std::size_t indexSize() const { return indexSize(_indexType); }
/** @brief Primitive type */
- Primitive primitive() const { return _primitive; }
+ MeshPrimitive primitive() const { return _primitive; }
/**
* @brief Set primitive type
* @return Reference to self (for method chaining)
*
- * Default is @ref Primitive::Triangles.
+ * Default is @ref MeshPrimitive::Triangles.
* @see @ref setVertexCount(), @ref addVertexBuffer()
*/
- Mesh& setPrimitive(Primitive primitive) {
+ Mesh& setPrimitive(MeshPrimitive primitive) {
_primitive = primitive;
return *this;
}
@@ -743,7 +751,7 @@ class MAGNUM_EXPORT Mesh {
static MAGNUM_LOCAL UnbindImplementation unbindImplementation;
GLuint _id;
- Primitive _primitive;
+ MeshPrimitive _primitive;
Int _vertexCount, _indexCount;
#ifndef MAGNUM_TARGET_GLES2
UnsignedInt _indexStart, _indexEnd;
@@ -762,7 +770,7 @@ class MAGNUM_EXPORT Mesh {
};
/** @debugoperator{Magnum::Mesh} */
-Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::Primitive value);
+Debug MAGNUM_EXPORT operator<<(Debug debug, MeshPrimitive value);
/** @debugoperator{Magnum::Mesh} */
Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value);
@@ -772,7 +780,7 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Mesh::IndexType value);
namespace Corrade { namespace Utility {
/** @configurationvalue{Magnum::Mesh} */
-template<> struct MAGNUM_EXPORT ConfigurationValue {
+template<> struct MAGNUM_EXPORT ConfigurationValue {
ConfigurationValue() = delete;
/**
@@ -780,14 +788,14 @@ template<> struct MAGNUM_EXPORT ConfigurationValue {
*
* If the value is invalid, returns empty string.
*/
- static std::string toString(Magnum::Mesh::Primitive value, ConfigurationValueFlags);
+ static std::string toString(Magnum::MeshPrimitive value, ConfigurationValueFlags);
/**
* @brief Reads enum value as string
*
- * If the value is invalid, returns @ref Magnum::Mesh::Primitive::Points "Mesh::Primitive::Points".
+ * If the value is invalid, returns @ref Magnum::MeshPrimitive::Points "MeshPrimitive::Points".
*/
- static Magnum::Mesh::Primitive fromString(const std::string& stringValue, ConfigurationValueFlags);
+ static Magnum::MeshPrimitive fromString(const std::string& stringValue, ConfigurationValueFlags);
};
/** @configurationvalue{Magnum::Mesh} */
diff --git a/src/MeshTools/CombineIndexedArrays.h b/src/MeshTools/CombineIndexedArrays.h
index 59fa27c87..ab56624ec 100644
--- a/src/MeshTools/CombineIndexedArrays.h
+++ b/src/MeshTools/CombineIndexedArrays.h
@@ -128,6 +128,8 @@ std::vector indices = MeshTools::combineIndexedArrays(
attributes indexed with `indices`.
@attention The function expects that all arrays have the same size.
+@todo Use `std::pair` (to avoid `std::make_tuple`), make this usable also at
+ runtime
*/
/* Implementation note: It's done using tuples because it is more clear which
parameter is index array and which is attribute array, mainly when both are
diff --git a/src/MeshTools/CompressIndices.h b/src/MeshTools/CompressIndices.h
index 54d53d6ba..1aa924063 100644
--- a/src/MeshTools/CompressIndices.h
+++ b/src/MeshTools/CompressIndices.h
@@ -69,9 +69,9 @@ std::tuple> MAGNUM_MESHTOO
@param indices Index array
The same as @ref compressIndices(const std::vector&), but this
-function writes the output to given buffer, updates index count and specifies
-index buffer with proper index range in the mesh, so you don't have to call
-@ref Mesh::setIndexCount() and @ref Mesh::setIndexBuffer() on your own.
+function writes the output to given buffer and calls @ref Mesh::setIndexCount()
+and @ref Mesh::setIndexBuffer(), thus you don't need to do anything else for
+mesh index configuration.
@see @ref MeshTools::interleave()
*/
diff --git a/src/MeshTools/FullScreenTriangle.cpp b/src/MeshTools/FullScreenTriangle.cpp
index da3518248..80d7ca37f 100644
--- a/src/MeshTools/FullScreenTriangle.cpp
+++ b/src/MeshTools/FullScreenTriangle.cpp
@@ -34,7 +34,7 @@ namespace Magnum { namespace MeshTools {
std::pair fullScreenTriangle() {
Mesh mesh;
- mesh.setPrimitive(Mesh::Primitive::Triangles)
+ mesh.setPrimitive(MeshPrimitive::Triangles)
.setVertexCount(3);
Buffer* buffer = nullptr;
diff --git a/src/MeshTools/Interleave.h b/src/MeshTools/Interleave.h
index dc663456a..cb6644162 100644
--- a/src/MeshTools/Interleave.h
+++ b/src/MeshTools/Interleave.h
@@ -190,8 +190,8 @@ The same as @ref interleave(const T&, const U&...), but this function writes the
output to given array buffer and updates vertex count in the mesh accordingly,
so you don't have to call @ref Mesh::setVertexCount() on your own.
-@attention Setting primitive type and binding the attributes to shader is left
- to user - see @ref Mesh-configuration "Mesh documentation".
+@attention You still must call @ref Mesh::setPrimitive() and
+ @ref Mesh::addVertexBuffer() on the mesh afterwards.
For only one attribute array this function is convenient equivalent to the
following, without any performance loss:
@@ -201,6 +201,7 @@ mesh.setVertexCount(attribute.size());
@endcode
@see @ref MeshTools::compressIndices()
+@todo rework so Mesh & Buffer doesn't need to be included in header
*/
template inline void interleave(Mesh& mesh, Buffer& buffer, BufferUsage usage, const T&... attributes) {
return Implementation::Interleave()(mesh, buffer, usage, attributes...);
diff --git a/src/Platform/AbstractXApplication.cpp b/src/Platform/AbstractXApplication.cpp
index a2d2846aa..cdbbb58fc 100644
--- a/src/Platform/AbstractXApplication.cpp
+++ b/src/Platform/AbstractXApplication.cpp
@@ -42,13 +42,6 @@ AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandle
createContext(configuration);
}
-#ifndef DOXYGEN_GENERATING_OUTPUT
-AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments&): contextHandler(contextHandler), c(nullptr), flags(Flag::Redraw) {
- /* GCC 4.5 can't handle {} here (wtf) */
- createContext(Configuration());
-}
-#endif
-
#ifndef CORRADE_GCC45_COMPATIBILITY
AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments&, std::nullptr_t)
#else
@@ -56,8 +49,14 @@ AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandle
#endif
: contextHandler(contextHandler), c(nullptr), flags(Flag::Redraw) {}
+void AbstractXApplication::createContext() { createContext({}); }
+
void AbstractXApplication::createContext(const Configuration& configuration) {
- CORRADE_ASSERT(!c, "AbstractXApplication::createContext(): context already created", );
+ if(!tryCreateContext(configuration)) std::exit(1);
+}
+
+bool AbstractXApplication::tryCreateContext(const Configuration& configuration) {
+ CORRADE_ASSERT(!c, "AbstractXApplication::tryCreateContext(): context already created", false);
viewportSize = configuration.size();
@@ -73,8 +72,8 @@ void AbstractXApplication::createContext(const Configuration& configuration) {
visTemplate.visualid = visualId;
visInfo = XGetVisualInfo(display, VisualIDMask, &visTemplate, &visualCount);
if(!visInfo) {
- Error() << "Cannot get X visual";
- std::exit(1);
+ Error() << "Platform::WindowlessGlxApplication::tryCreateContext(): cannot get X visual";
+ return false;
}
/* Create X Window */
@@ -103,6 +102,7 @@ void AbstractXApplication::createContext(const Configuration& configuration) {
contextHandler->makeCurrent();
c = new Context;
+ return true;
}
AbstractXApplication::~AbstractXApplication() {
@@ -174,6 +174,7 @@ int AbstractXApplication::exec() {
return 0;
}
+void AbstractXApplication::viewportEvent(const Vector2i&) {}
void AbstractXApplication::keyPressEvent(KeyEvent&) {}
void AbstractXApplication::keyReleaseEvent(KeyEvent&) {}
void AbstractXApplication::mousePressEvent(MouseEvent&) {}
diff --git a/src/Platform/AbstractXApplication.h b/src/Platform/AbstractXApplication.h
index 56e5ab78d..f413ba6b7 100644
--- a/src/Platform/AbstractXApplication.h
+++ b/src/Platform/AbstractXApplication.h
@@ -73,6 +73,18 @@ class AbstractXApplication {
class MouseEvent;
class MouseMoveEvent;
+ /** @brief Copying is not allowed */
+ AbstractXApplication(const AbstractXApplication&) = delete;
+
+ /** @brief Moving is not allowed */
+ AbstractXApplication(AbstractXApplication&&) = delete;
+
+ /** @brief Copying is not allowed */
+ AbstractXApplication& operator=(const AbstractXApplication&) = delete;
+
+ /** @brief Moving is not allowed */
+ AbstractXApplication& operator=(AbstractXApplication&&) = delete;
+
/**
* @brief Execute main loop
* @return Value for returning from `main()`.
@@ -87,23 +99,37 @@ class AbstractXApplication {
this is faster than public pure virtual destructor */
~AbstractXApplication();
- /** @copydoc GlutApplication::createContext() */
+ /** @copydoc Sdl2Application::createContext() */
+ #ifdef DOXYGEN_GENERATING_OUTPUT
+ void createContext(const Configuration& configuration = Configuration());
+ #else
+ /* To avoid "invalid use of incomplete type" */
void createContext(const Configuration& configuration);
+ void createContext();
+ #endif
- /** @{ @name Drawing functions */
-
- /** @copydoc GlutApplication::viewportEvent() */
- virtual void viewportEvent(const Vector2i& size) = 0;
+ /** @copydoc Sdl2Application::tryCreateContext() */
+ bool tryCreateContext(const Configuration& configuration);
- /** @copydoc GlutApplication::drawEvent() */
- virtual void drawEvent() = 0;
+ /** @{ @name Screen handling */
- /** @copydoc GlutApplication::swapBuffers() */
+ /** @copydoc Sdl2Application::swapBuffers() */
void swapBuffers();
- /** @copydoc GlutApplication::redraw() */
+ /** @copydoc Sdl2Application::redraw() */
void redraw() { flags |= Flag::Redraw; }
+ #ifdef DOXYGEN_GENERATING_OUTPUT
+ protected:
+ #else
+ private:
+ #endif
+ /** @copydoc Sdl2Application::viewportEvent() */
+ virtual void viewportEvent(const Vector2i& size);
+
+ /** @copydoc Sdl2Application::drawEvent() */
+ virtual void drawEvent() = 0;
+
/*@}*/
/** @{ @name Keyboard handling */
@@ -134,10 +160,7 @@ class AbstractXApplication {
#else
protected:
#endif
- /* These two are split to avoid "invalid use of incomplete type" when
- using default argument for configuration */
explicit AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, const Configuration& configuration);
- explicit AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments);
#ifndef CORRADE_GCC45_COMPATIBILITY
explicit AbstractXApplication(Implementation::AbstractContextHandler* contextHandler, const Arguments& arguments, std::nullptr_t);
@@ -174,15 +197,11 @@ CORRADE_ENUMSET_OPERATORS(AbstractXApplication::Flags)
@brief %Configuration
Double-buffered OpenGL context.
-@see AbstractXApplication(), createContext()
+@see @ref GlxApplication::GlxApplication(), @ref XEglApplication::XEglApplication(),
+ @ref createContext(), @ref tryCreateContext()
@todo GLX_ARB_create_context_robustness/EGL_EXT_create_context_robustness
*/
class AbstractXApplication::Configuration {
- Configuration(const Configuration&) = delete;
- Configuration(Configuration&&) = delete;
- Configuration& operator=(const Configuration&) = delete;
- Configuration& operator=(Configuration&&) = delete;
-
public:
/*implicit*/ Configuration();
~Configuration();
@@ -223,21 +242,16 @@ class AbstractXApplication::Configuration {
/**
@brief Base for input events
-@see KeyEvent, MouseEvent, MouseMoveEvent, keyPressEvent(), keyReleaseEvent(),
- mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent()
+@see @ref KeyEvent, @ref MouseEvent, @ref MouseMoveEvent, @ref keyPressEvent(),
+ @ref keyReleaseEvent(), @ref mousePressEvent(), @ref mouseReleaseEvent(),
+ @ref mouseMoveEvent()
*/
class AbstractXApplication::InputEvent {
- InputEvent(const InputEvent&) = delete;
- InputEvent(InputEvent&&) = delete;
- InputEvent& operator=(const InputEvent&) = delete;
- InputEvent& operator=(InputEvent&&) = delete;
-
- public:
public:
/**
* @brief %Modifier
*
- * @see Modifiers, modifiers()
+ * @see @ref Modifiers, @ref modifiers()
*/
enum class Modifier: unsigned int {
Shift = ShiftMask, /**< Shift */
@@ -278,7 +292,7 @@ class AbstractXApplication::InputEvent {
/**
* @brief Set of modifiers
*
- * @see modifiers()
+ * @see @ref modifiers()
*/
typedef Containers::EnumSet Modifiers;
@@ -300,10 +314,22 @@ class AbstractXApplication::InputEvent {
*/
typedef Containers::EnumSet