Browse Source

Merge branch 'master' into compatibility

Conflicts:
	src/Magnum/Math/Test/TypeTraitsTest.cpp
	src/Magnum/Test/MeshGLTest.cpp
Vladimír Vondruš 12 years ago
parent
commit
33816cf5e5
  1. 3
      CMakeLists.txt
  2. 2
      doc/cmake.dox
  3. 43
      modules/FindMagnum.cmake
  4. 8
      src/Magnum/AbstractFramebuffer.cpp
  5. 9
      src/Magnum/AbstractFramebuffer.h
  6. 44
      src/Magnum/AbstractObject.cpp
  7. 9
      src/Magnum/AbstractObject.h
  8. 24
      src/Magnum/AbstractShaderProgram.cpp
  9. 62
      src/Magnum/AbstractShaderProgram.h
  10. 2
      src/Magnum/AbstractTexture.cpp
  11. 13
      src/Magnum/AbstractTexture.h
  12. 2
      src/Magnum/Audio/AbstractImporter.h
  13. 1
      src/Magnum/Audio/Audio.cpp
  14. 6
      src/Magnum/Audio/CMakeLists.txt
  15. 2
      src/Magnum/Buffer.cpp
  16. 11
      src/Magnum/Buffer.h
  17. 4
      src/Magnum/BufferTexture.h
  18. 15
      src/Magnum/CMakeLists.txt
  19. 2
      src/Magnum/Context.cpp
  20. 4
      src/Magnum/CubeMapTexture.h
  21. 4
      src/Magnum/CubeMapTextureArray.h
  22. 4
      src/Magnum/DebugMessage.h
  23. 21
      src/Magnum/DebugTools/CMakeLists.txt
  24. 4
      src/Magnum/DefaultFramebuffer.cpp
  25. 28
      src/Magnum/DefaultFramebuffer.h
  26. 6
      src/Magnum/Framebuffer.cpp
  27. 38
      src/Magnum/Framebuffer.h
  28. 2
      src/Magnum/Implementation/DebugState.h
  29. 30
      src/Magnum/Implementation/FramebufferState.cpp
  30. 2
      src/Magnum/Implementation/FramebufferState.h
  31. 3
      src/Magnum/Math/Algorithms/CMakeLists.txt
  32. 6
      src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp
  33. 3
      src/Magnum/Math/CMakeLists.txt
  34. 3
      src/Magnum/Math/Geometry/CMakeLists.txt
  35. 14
      src/Magnum/Math/Test/Matrix4Test.cpp
  36. 2
      src/Magnum/Math/Test/QuaternionTest.cpp
  37. 85
      src/Magnum/Math/Test/TypeTraitsTest.cpp
  38. 4
      src/Magnum/Math/Test/UnitTest.cpp
  39. 40
      src/Magnum/Math/TypeTraits.h
  40. 2
      src/Magnum/Mesh.cpp
  41. 11
      src/Magnum/Mesh.h
  42. 4
      src/Magnum/MeshTools/CMakeLists.txt
  43. 4
      src/Magnum/MultisampleTexture.h
  44. 191
      src/Magnum/Platform/CMakeLists.txt
  45. 10
      src/Magnum/Primitives/CMakeLists.txt
  46. 2
      src/Magnum/Query.cpp
  47. 24
      src/Magnum/Query.h
  48. 4
      src/Magnum/RectangleTexture.h
  49. 2
      src/Magnum/Renderbuffer.cpp
  50. 13
      src/Magnum/Renderbuffer.h
  51. 10
      src/Magnum/Renderer.cpp
  52. 25
      src/Magnum/Renderer.h
  53. 4
      src/Magnum/SceneGraph/CMakeLists.txt
  54. 4
      src/Magnum/SceneGraph/Drawable.h
  55. 2
      src/Magnum/Shader.cpp
  56. 12
      src/Magnum/Shader.h
  57. 10
      src/Magnum/Shaders/CMakeLists.txt
  58. 3
      src/Magnum/Shaders/DistanceFieldVector.cpp
  59. 3
      src/Magnum/Shaders/Flat.cpp
  60. 58
      src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp
  61. 27
      src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h
  62. 3
      src/Magnum/Shaders/MeshVisualizer.cpp
  63. 3
      src/Magnum/Shaders/Phong.cpp
  64. 3
      src/Magnum/Shaders/Vector.cpp
  65. 3
      src/Magnum/Shaders/VertexColor.cpp
  66. 8
      src/Magnum/Shapes/CMakeLists.txt
  67. 4
      src/Magnum/Test/AbstractOpenGLTester.h
  68. 8
      src/Magnum/Test/AbstractQueryGLTest.cpp
  69. 29
      src/Magnum/Test/AbstractShaderProgramGLTest.cpp
  70. 7
      src/Magnum/Test/AbstractTextureGLTest.cpp
  71. 7
      src/Magnum/Test/BufferGLTest.cpp
  72. 2
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  73. 6
      src/Magnum/Test/DebugGLTest.cpp
  74. 22
      src/Magnum/Test/FramebufferGLTest.cpp
  75. 24
      src/Magnum/Test/MeshGLTest.cpp
  76. 13
      src/Magnum/Test/PrimitiveQueryGLTest.cpp
  77. 11
      src/Magnum/Test/RenderbufferGLTest.cpp
  78. 18
      src/Magnum/Test/SampleQueryGLTest.cpp
  79. 4
      src/Magnum/Test/TimeQueryGLTest.cpp
  80. 2
      src/Magnum/Text/AbstractFont.h
  81. 2
      src/Magnum/Text/AbstractFontConverter.h
  82. 10
      src/Magnum/Text/CMakeLists.txt
  83. 4
      src/Magnum/Texture.h
  84. 4
      src/Magnum/TextureArray.h
  85. 10
      src/Magnum/TextureTools/CMakeLists.txt
  86. 21
      src/Magnum/TextureTools/DistanceField.cpp
  87. 5
      src/Magnum/TextureTools/DistanceFieldShader.frag
  88. 2
      src/Magnum/Trade/AbstractImageConverter.h
  89. 5
      src/Magnum/Trade/AbstractImporter.cpp
  90. 9
      src/Magnum/Trade/AbstractImporter.h
  91. 3
      src/Magnum/Trade/CMakeLists.txt
  92. 2
      src/MagnumExternal/OpenGL/GL/CMakeLists.txt
  93. 4
      src/MagnumPlugins/TgaImporter/TgaImporter.conf
  94. 4
      src/MagnumPlugins/TgaImporter/TgaImporter.cpp

3
CMakeLists.txt

@ -161,8 +161,7 @@ endif()
if(BUILD_GL_TESTS)
if(UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES))
set(WITH_WINDOWLESSGLXAPPLICATION ON)
find_package(X11 REQUIRED)
set(GL_TEST_LIBRARIES Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES})
set(GL_TEST_LIBRARIES Magnum MagnumWindowlessGlxApplication)
else()
message(FATAL_ERROR "Cannot run tests for OpenGL code on this platform. Set BUILD_GL_TESTS to OFF to skip building them.")
endif()

2
doc/cmake.dox

@ -173,7 +173,7 @@ are also available as preprocessor variables if including
If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable also
contains path directly to Magnum directory (i.e. for includes without `Magnum/`
prefix) and `MAGNUM_PLUGINS_INCLUDE_DIR` contains include dir for plugins (i.e.
instead of `MagnumPlugins/` prefix).
for includes without `MagnumPlugins/` prefix).
%Corrade library provides also its own set of CMake macros and variables, see
@ref corrade-cmake "its documentation" for more information.

43
modules/FindMagnum.cmake

@ -94,10 +94,10 @@
# emulation on desktop OpenGL
# MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL
#
# If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable
# also contains path directly to Magnum directory (i.e. for includes without
# `Magnum/` prefix) and `MAGNUM_PLUGINS_INCLUDE_DIR` contains include dir for
# plugins (i.e. instead of `MagnumPlugins/` prefix).
# If MAGNUM_BUILD_DEPRECATED is defined, the MAGNUM_INCLUDE_DIR variable also
# contains path directly to Magnum directory (i.e. for includes without
# Magnum/ prefix) and MAGNUM_PLUGINS_INCLUDE_DIR contains include dir for
# plugins (i.e. for includes without MagnumPlugins/ prefix).
#
# Additionally these variables are defined for internal usage:
# MAGNUM_INCLUDE_DIR - Root include dir (w/o dependencies)
@ -181,6 +181,15 @@ endif()
find_path(MAGNUM_INCLUDE_DIR
NAMES Magnum/Magnum.h)
# We need to open configure.h file from MAGNUM_INCLUDE_DIR before we check for
# the components. Bail out with proper error message if it wasn't found. The
# complete check with all components is further below.
if(NOT MAGNUM_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Magnum
REQUIRED_VARS MAGNUM_LIBRARY MAGNUM_INCLUDE_DIR)
endif()
# Configuration
file(READ ${MAGNUM_INCLUDE_DIR}/Magnum/configure.h _magnumConfigure)
@ -348,20 +357,18 @@ foreach(component ${Magnum_FIND_COMPONENTS})
else()
unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif()
endif()
# GLUT application dependencies
if(${component} STREQUAL GlutApplication)
elseif(${component} STREQUAL GlutApplication)
find_package(GLUT)
if(GLUT_FOUND)
set(_MAGNUM_${_COMPONENT}_LIBRARIES ${GLUT_glut_LIBRARY})
else()
unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif()
endif()
# SDL2 application dependencies
if(${component} STREQUAL Sdl2Application)
elseif(${component} STREQUAL Sdl2Application)
find_package(SDL2)
if(SDL2_FOUND)
set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY})
@ -369,25 +376,25 @@ foreach(component ${Magnum_FIND_COMPONENTS})
else()
unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif()
endif()
# (Windowless) NaCl application dependencies
if(${component} STREQUAL NaClApplication OR ${component} STREQUAL WindowlessNaClApplication)
elseif(${component} STREQUAL NaClApplication OR ${component} STREQUAL WindowlessNaClApplication)
set(_MAGNUM_${_COMPONENT}_LIBRARIES ppapi_cpp ppapi)
endif()
# GLX application dependencies
if(${component} STREQUAL GlxApplication OR ${component} STREQUAL WindowlessGlxApplication)
# (Windowless) GLX application dependencies
elseif(${component} STREQUAL GlxApplication OR ${component} STREQUAL WindowlessGlxApplication)
find_package(X11)
if(X11_FOUND)
set(_MAGNUM_${_COMPONENT}_LIBRARIES ${X11_LIBRARIES})
else()
unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif()
endif()
# Windowless CGL application has no additional dependencies
# Windowless WGL application has no additional dependencies
# X/EGL application dependencies
if(${component} STREQUAL XEglApplication)
elseif(${component} STREQUAL XEglApplication)
find_package(EGL)
find_package(X11)
if(EGL_FOUND AND X11_FOUND)
@ -398,7 +405,9 @@ foreach(component ${Magnum_FIND_COMPONENTS})
endif()
# Common application dependencies
set(_MAGNUM_${_COMPONENT}_LIBRARIES ${_MAGNUM_${_COMPONENT}_LIBRARIES} ${_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY})
set(_MAGNUM_${_COMPONENT}_LIBRARIES
${_MAGNUM_${_COMPONENT}_LIBRARIES}
${_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY})
# Audio library
elseif(${component} STREQUAL Audio)
@ -471,7 +480,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
endif()
endforeach()
include(FindPackageHandleStandardArgs)
# Complete the check with also all components
find_package_handle_standard_args(Magnum
REQUIRED_VARS MAGNUM_LIBRARY MAGNUM_INCLUDE_DIR
HANDLE_COMPONENTS)

8
src/Magnum/AbstractFramebuffer.cpp

@ -211,7 +211,9 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Buf
}
#endif
void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attachments) {
void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum* const) {}
void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments) {
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glInvalidateFramebuffer(GLenum(bindInternal()), count, attachments);
@ -223,7 +225,9 @@ void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attach
#endif
}
void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attachments, const Range2Di& rectangle) {
void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&) {}
void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) {
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glInvalidateSubFramebuffer(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY());

9
src/Magnum/AbstractFramebuffer.h

@ -338,9 +338,6 @@ class MAGNUM_EXPORT AbstractFramebuffer {
FramebufferTarget MAGNUM_LOCAL bindInternal();
void MAGNUM_LOCAL setViewportInternal();
void MAGNUM_LOCAL invalidateImplementation(GLsizei count, GLenum* attachments);
void MAGNUM_LOCAL invalidateImplementation(GLsizei count, GLenum* attachments, const Range2Di& rectangle);
GLuint _id;
Range2Di _viewport;
@ -367,6 +364,12 @@ class MAGNUM_EXPORT AbstractFramebuffer {
static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
static void MAGNUM_LOCAL readImplementationRobustness(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*);
void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments);
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&);
void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments, const Range2Di& rectangle);
};
inline AbstractFramebuffer::AbstractFramebuffer() = default;

44
src/Magnum/AbstractObject.cpp

@ -26,6 +26,7 @@
#include "AbstractObject.h"
#include <Corrade/Utility/Assert.h>
#include <Corrade/Containers/Array.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
@ -123,26 +124,26 @@ Int AbstractObject::maxLabelLength() {
return value;
}
void AbstractObject::labelImplementationNoOp(GLenum, GLuint, const std::string&) {}
void AbstractObject::labelImplementationNoOp(GLenum, GLuint, Containers::ArrayReference<const char>) {}
void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const std::string& label) {
void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const Containers::ArrayReference<const char> label) {
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glObjectLabel(identifier, name, label.size(), label.data());
glObjectLabel(identifier, name, label.size(), label);
#else
static_cast<void>(identifier);
static_cast<void>(name);
static_cast<void>(label);
CORRADE_INTERNAL_ASSERT(false);
//glObjectLabelKHR(identifier, name, label.size(), label.data());
//glObjectLabelKHR(identifier, name, label.size(), label);
#endif
}
void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const std::string& label) {
void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const Containers::ArrayReference<const char> label) {
const GLenum type = extTypeFromKhrIdentifier(identifier);
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glLabelObjectEXT(type, name, label.size(), label.data());
glLabelObjectEXT(type, name, label.size(), label);
#else
static_cast<void>(type);
static_cast<void>(name);
@ -154,46 +155,31 @@ void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuin
std::string AbstractObject::getLabelImplementationNoOp(GLenum, GLuint) { return {}; }
std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, const GLuint name) {
/**
* @todo Get rid of this workaround when NVidia returns proper size for
* length=0 & label=nullptr (even crashes on length>0 & label=nullptr)
*/
#if 0
/* Get label size (w/o null terminator) */
GLsizei size;
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glGetObjectLabel(type, name, 0, &size, nullptr);
glGetObjectLabel(identifier, name, 0, &size, nullptr);
#else
glGetObjectLabelKHR(type, name, 0, &size, nullptr);
static_cast<void>(identifier);
static_cast<void>(name);
CORRADE_INTERNAL_ASSERT(false);
//glGetObjectLabelKHR(identifier, name, 0, &size, nullptr);
#endif
/* Make place also for the null terminator */
std::string label;
label.resize(size+1);
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glGetObjectLabel(identifier, name, size+1, nullptr, &label[0]);
#else
glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]);
//glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]);
#endif
/* Pop null terminator and return the string */
label.resize(size);
return label;
#else
GLsizei size;
std::string label;
label.resize(maxLabelLength());
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glGetObjectLabel(identifier, name, label.size(), &size, &label[0]);
#else
static_cast<void>(identifier);
static_cast<void>(name);
CORRADE_INTERNAL_ASSERT(false);
//glGetObjectLabelKHR(identifier, name, label.size(), &size, &label[0]);
#endif
return label.substr(0, size);
#endif
}
std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, const GLuint name) {

9
src/Magnum/AbstractObject.h

@ -30,9 +30,10 @@
*/
#include <string>
#include <Corrade/Containers/Containers.h>
#include "Magnum/Magnum.h"
#include "Magnum/OpenGL.h"
#include "Magnum/Types.h"
#include "Magnum/visibility.h"
namespace Magnum {
@ -66,9 +67,9 @@ class MAGNUM_EXPORT AbstractObject {
MAGNUM_LOCAL ~AbstractObject();
private:
static MAGNUM_LOCAL void labelImplementationNoOp(GLenum, GLuint, const std::string&);
static MAGNUM_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, const std::string& label);
static MAGNUM_LOCAL void labelImplementationKhr(GLenum identifier, GLuint name, const std::string& label);
static MAGNUM_LOCAL void labelImplementationNoOp(GLenum, GLuint, Containers::ArrayReference<const char> label);
static MAGNUM_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, Containers::ArrayReference<const char> label);
static MAGNUM_LOCAL void labelImplementationKhr(GLenum identifier, GLuint name, Containers::ArrayReference<const char> label);
static MAGNUM_LOCAL std::string getLabelImplementationNoOp(GLenum, GLuint);
static MAGNUM_LOCAL std::string getLabelImplementationExt(GLenum identifier, GLuint name);
static MAGNUM_LOCAL std::string getLabelImplementationKhr(GLenum identifier, GLuint name);

24
src/Magnum/AbstractShaderProgram.cpp

@ -227,7 +227,7 @@ std::string AbstractShaderProgram::label() const {
#endif
}
AbstractShaderProgram& AbstractShaderProgram::setLabel(const std::string& label) {
AbstractShaderProgram& AbstractShaderProgram::setLabelInternal(const Containers::ArrayReference<const char> label) {
#ifndef MAGNUM_TARGET_GLES
Context::current()->state().debug->labelImplementation(GL_PROGRAM, _id, label);
#else
@ -264,16 +264,20 @@ void AbstractShaderProgram::attachShader(Shader& shader) {
glAttachShader(_id, shader.id());
}
void AbstractShaderProgram::bindAttributeLocation(UnsignedInt location, const std::string& name) {
glBindAttribLocation(_id, location, name.data());
void AbstractShaderProgram::attachShaders(std::initializer_list<std::reference_wrapper<Shader>> shaders) {
for(Shader& s: shaders) attachShader(s);
}
void AbstractShaderProgram::bindAttributeLocationInternal(const UnsignedInt location, const Containers::ArrayReference<const char> name) {
glBindAttribLocation(_id, location, name);
}
#ifndef MAGNUM_TARGET_GLES
void AbstractShaderProgram::bindFragmentDataLocation(UnsignedInt location, const std::string& name) {
glBindFragDataLocation(_id, location, name.data());
void AbstractShaderProgram::bindFragmentDataLocationInternal(const UnsignedInt location, const Containers::ArrayReference<const char> name) {
glBindFragDataLocation(_id, location, name);
}
void AbstractShaderProgram::bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const std::string& name) {
glBindFragDataLocationIndexed(_id, location, index, name.data());
void AbstractShaderProgram::bindFragmentDataLocationIndexedInternal(const UnsignedInt location, UnsignedInt index, const Containers::ArrayReference<const char> name) {
glBindFragDataLocationIndexed(_id, location, index, name);
}
#endif
@ -354,10 +358,10 @@ bool AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<Ab
return allSuccess;
}
Int AbstractShaderProgram::uniformLocation(const std::string& name) {
GLint location = glGetUniformLocation(_id, name.data());
Int AbstractShaderProgram::uniformLocationInternal(const Containers::ArrayReference<const char> name) {
GLint location = glGetUniformLocation(_id, name);
if(location == -1)
Warning() << "AbstractShaderProgram: location of uniform \'" + name + "\' cannot be retrieved!";
Warning() << "AbstractShaderProgram: location of uniform \'" + std::string{name, name.size()} + "\' cannot be retrieved!";
return location;
}

62
src/Magnum/AbstractShaderProgram.h

@ -31,6 +31,7 @@
#include <functional>
#include <string>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/EnumSet.h>
#include "Magnum/AbstractObject.h"
@ -540,7 +541,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* @def_gl{PROGRAM} or @fn_gl_extension2{LabelObject,EXT,debug_label}
* with @def_gl{PROGRAM_OBJECT_EXT}
*/
AbstractShaderProgram& setLabel(const std::string& label);
AbstractShaderProgram& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> AbstractShaderProgram& setLabel(const char (&label)[size]) {
return setLabelInternal(label);
}
/**
* @brief Validate program
@ -614,6 +622,15 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
*/
void attachShader(Shader& shader);
/**
* @brief Attach shaders
*
* Convenience overload to the above, allowing the user to specify more
* than one shader at once. Other than that there is no other
* (performance) difference when using this function.
*/
void attachShaders(std::initializer_list<std::reference_wrapper<Shader>> shaders);
/**
* @brief Bind attribute to given location
* @param location Location
@ -627,7 +644,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* @ref AbstractShaderProgram-attribute-location "class documentation"
* for more information.
*/
void bindAttributeLocation(UnsignedInt location, const std::string& name);
void bindAttributeLocation(UnsignedInt location, const std::string& name) {
bindAttributeLocationInternal(location, {name.data(), name.size()});
}
/** @overload */
template<std::size_t size> void bindAttributeLocation(UnsignedInt location, const char(&name)[size]) {
bindAttributeLocationInternal(location, name);
}
#ifndef MAGNUM_TARGET_GLES
/**
@ -648,7 +672,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* @requires_gl Multiple blend function inputs are not available in
* OpenGL ES.
*/
void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const std::string& name);
void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const std::string& name) {
bindFragmentDataLocationIndexedInternal(location, index, {name.data(), name.size()});
}
/** @overload */
template<std::size_t size> void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const char(&name)[size]) {
bindFragmentDataLocationIndexedInternal(location, index, name);
}
/**
* @brief Bind fragment data to given location and first color input index
@ -663,7 +694,15 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* and `gl_FragData[n]` provided by @es_extension2{NV,draw_buffers,GL_NV_draw_buffers}
* in OpenGL ES 2.0.
*/
void bindFragmentDataLocation(UnsignedInt location, const std::string& name);
void bindFragmentDataLocation(UnsignedInt location, const std::string& name) {
bindFragmentDataLocationInternal(location, {name.data(), name.size()});
}
/** @overload */
template<std::size_t size> void bindFragmentDataLocation(UnsignedInt location, const char(&name)[size]) {
/* Not using const char* parameter, because this way it avoids most accidents with non-zero-terminated strings */
bindFragmentDataLocationInternal(location, name);
}
#endif
/**
@ -689,7 +728,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* @ref AbstractShaderProgram-uniform-location "class documentation"
* for more information.
*/
Int uniformLocation(const std::string& name);
Int uniformLocation(const std::string& name) {
return uniformLocationInternal({name.data(), name.size()});
}
/** @overload */
template<std::size_t size> Int uniformLocation(const char(&name)[size]) {
return uniformLocationInternal(name);
}
/**
* @brief Set uniform value
@ -811,6 +857,12 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
#endif
private:
AbstractShaderProgram& setLabelInternal(Containers::ArrayReference<const char> label);
void bindAttributeLocationInternal(UnsignedInt location, Containers::ArrayReference<const char> name);
void bindFragmentDataLocationIndexedInternal(UnsignedInt location, UnsignedInt index, Containers::ArrayReference<const char> name);
void bindFragmentDataLocationInternal(UnsignedInt location, Containers::ArrayReference<const char> name);
Int uniformLocationInternal(Containers::ArrayReference<const char> name);
#ifndef MAGNUM_BUILD_DEPRECATED
void use();
#endif

2
src/Magnum/AbstractTexture.cpp

@ -190,7 +190,7 @@ std::string AbstractTexture::label() const {
return Context::current()->state().debug->getLabelImplementation(GL_TEXTURE, _id);
}
AbstractTexture& AbstractTexture::setLabel(const std::string& label) {
AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayReference<const char> label) {
Context::current()->state().debug->labelImplementation(GL_TEXTURE, _id, label);
return *this;
}

13
src/Magnum/AbstractTexture.h

@ -29,6 +29,8 @@
* @brief Class @ref Magnum::AbstractTexture
*/
#include <Corrade/Containers/Array.h>
#include "Magnum/Sampler.h"
#include "Magnum/AbstractObject.h"
@ -264,7 +266,14 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
* @fn_gl_extension2{LabelObject,EXT,debug_label} with
* @def_gl{TEXTURE}
*/
AbstractTexture& setLabel(const std::string& label);
AbstractTexture& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> AbstractTexture& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
}
/** @brief OpenGL texture ID */
GLuint id() const { return _id; }
@ -294,6 +303,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
explicit AbstractTexture(GLenum target);
AbstractTexture& setLabelInternal(Containers::ArrayReference<const char> label);
/* Unlike bind() this also sets the texture binding unit as active */
void MAGNUM_LOCAL bindInternal();

2
src/Magnum/Audio/AbstractImporter.h

@ -59,6 +59,8 @@ checked by the implementation:
supported.
- All `do*()` implementations working on opened file are called only if
there is any file opened.
Plugin interface string is `"cz.mosra.magnum.Audio.AbstractImporter/0.1"`.
*/
class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractPlugin {
CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Audio.AbstractImporter/0.1")

1
src/Magnum/Audio/Audio.cpp

@ -26,6 +26,7 @@
#include <type_traits>
#include <al.h>
#include "Corrade/configure.h"
#include "Magnum/Types.h"
namespace Magnum { namespace Audio {

6
src/Magnum/Audio/CMakeLists.txt

@ -27,7 +27,7 @@ find_package(OpenAL REQUIRED)
include_directories(${OPENAL_INCLUDE_DIR})
set(MagnumAudio_SOURCES
set(MagnumAudio_SRCS
AbstractImporter.cpp
Audio.cpp
Buffer.cpp
@ -45,7 +45,9 @@ set(MagnumAudio_HEADERS
visibility.h)
add_library(MagnumAudio ${SHARED_OR_STATIC} ${MagnumAudio_SOURCES})
add_library(MagnumAudio ${SHARED_OR_STATIC}
${MagnumAudio_SRCS}
${MagnumAudio_HEADERS})
set_target_properties(MagnumAudio PROPERTIES DEBUG_POSTFIX "-d")
target_link_libraries(MagnumAudio ${CORRADE_PLUGINMANAGER_LIBRARIES} ${OPENAL_LIBRARY})

2
src/Magnum/Buffer.cpp

@ -138,7 +138,7 @@ std::string Buffer::label() const {
#endif
}
Buffer& Buffer::setLabel(const std::string& label) {
Buffer& Buffer::setLabelInternal(const Containers::ArrayReference<const char> label) {
#ifndef MAGNUM_TARGET_GLES
Context::current()->state().debug->labelImplementation(GL_BUFFER, _id, label);
#else

11
src/Magnum/Buffer.h

@ -582,7 +582,14 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
* or @fn_gl_extension2{LabelObject,EXT,debug_label} with
* @def_gl{BUFFER_OBJECT_EXT}
*/
Buffer& setLabel(const std::string& label);
Buffer& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Buffer& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
}
/** @brief Target hint */
Target targetHint() const { return _targetHint; }
@ -854,6 +861,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
#endif
private:
Buffer& setLabelInternal(Containers::ArrayReference<const char> label);
static void bind(Target hint, GLuint id);
Target MAGNUM_LOCAL bindInternal(Target hint);

4
src/Magnum/BufferTexture.h

@ -279,6 +279,10 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> BufferTexture& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
#endif
private:

15
src/Magnum/CMakeLists.txt

@ -119,6 +119,19 @@ set(Magnum_HEADERS
visibility.h)
# Header files to display in project view of IDEs only
set(Magnum_PRIVATE_HEADERS
Implementation/BufferState.h
Implementation/DebugState.h
Implementation/FramebufferState.h
Implementation/maxTextureSize.h
Implementation/MeshState.h
Implementation/RendererState.h
Implementation/ShaderProgramState.h
Implementation/ShaderState.h
Implementation/State.h
Implementation/TextureState.h)
# Deprecated headers
if(BUILD_DEPRECATED)
set(Magnum_HEADERS ${Magnum_HEADERS}
@ -159,6 +172,8 @@ set(MagnumMath_SRCS
add_library(MagnumMathObjects OBJECT ${MagnumMath_SRCS})
add_library(Magnum ${SHARED_OR_STATIC}
${Magnum_SRCS}
${Magnum_HEADERS}
${Magnum_PRIVATE_HEADERS}
$<TARGET_OBJECTS:MagnumMathObjects>)
set_target_properties(Magnum PROPERTIES DEBUG_POSTFIX "-d")

2
src/Magnum/Context.cpp

@ -332,7 +332,7 @@ Context::Context() {
/* Allow ES2 context on driver that reports ES3 as supported */
const std::string version = versionString();
#ifndef MAGNUM_TARGET_GLES
if(version.compare(0, 4, "2.1 ") == 0)
if(version.compare(0, 3, "2.1") == 0)
#elif defined(MAGNUM_TARGET_WEBGL)
if(version.find("WebGL 1") != std::string::npos)
#else

4
src/Magnum/CubeMapTexture.h

@ -392,6 +392,10 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> CubeMapTexture& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
#endif
};

4
src/Magnum/CubeMapTextureArray.h

@ -415,6 +415,10 @@ class CubeMapTextureArray: public AbstractTexture {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> CubeMapTextureArray& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
#endif
};

4
src/Magnum/DebugMessage.h

@ -56,8 +56,8 @@ using @ref setCallback() or use the default one provided in
@ref setDefaultCallback():
@code
Renderer::setFeature(Renderer::Feature::DebugOutput, true);
Renderer::setFeature(Renderer::Feature::DebugOutputSynchronous, true);
Renderer::enable(Renderer::Feature::DebugOutput);
Renderer::enable(Renderer::Feature::DebugOutputSynchronous);
DebugMessage::setDefaultCallback();
DebugMessage::insert(DebugMessage::Source::Application, DebugMessage::Type::Marker,

21
src/Magnum/DebugTools/CMakeLists.txt

@ -50,7 +50,26 @@ set(MagnumDebugTools_HEADERS
visibility.h)
add_library(MagnumDebugTools ${SHARED_OR_STATIC} ${MagnumDebugTools_SRCS})
# Header files to display in project view of IDEs only
set(MagnumDebugTools_PRIVATE_HEADERS
Implementation/AbstractBoxRenderer.h
Implementation/AbstractShapeRenderer.h
Implementation/AxisAlignedBoxRenderer.h
Implementation/BoxRenderer.h
Implementation/CapsuleRenderer.h
Implementation/CapsuleRendererTransformation.h
Implementation/CylinderRenderer.h
Implementation/CylinderRendererTransformation.h
Implementation/ForceRendererTransformation.h
Implementation/LineSegmentRenderer.h
Implementation/LineSegmentRendererTransformation.h
Implementation/PointRenderer.h
Implementation/SphereRenderer.h)
add_library(MagnumDebugTools ${SHARED_OR_STATIC}
${MagnumDebugTools_SRCS}
${MagnumDebugTools_HEADERS}
${MagnumDebugTools_PRIVATE_HEADERS})
set_target_properties(MagnumDebugTools PROPERTIES DEBUG_POSTFIX "-d")
if(BUILD_STATIC_PIC)
# TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property

4
src/Magnum/DefaultFramebuffer.cpp

@ -77,7 +77,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
invalidateImplementation(attachments.size(), _attachments);
(this->*Context::current()->state().framebuffer->invalidateImplementation)(attachments.size(), _attachments);
}
void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle) {
@ -86,7 +86,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list<InvalidationAttachment
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
invalidateImplementation(attachments.size(), _attachments, rectangle);
(this->*Context::current()->state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle);
}
void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) {

28
src/Magnum/DefaultFramebuffer.h

@ -388,17 +388,13 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
* @brief Invalidate framebuffer
* @param attachments Attachments to invalidate
*
* The framebuffer is bound to some target before the operation, if
* not already.
* If extension @extension{ARB,invalidate_subdata} (part of OpenGL
* 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES
* 2.0 or OpenGL ES 3.0 is not available, this function does nothing.
* The framebuffer is bound to some target before the operation, if not
* already.
* @see @fn_gl{InvalidateFramebuffer} or @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer}
* on OpenGL ES 2.0
* @requires_gl43 %Extension @extension{ARB,invalidate_subdata}. Use
* @ref Magnum::DefaultFramebuffer::clear() "clear()" instead
* where the extension is not supported.
* @requires_gles30 %Extension @es_extension{EXT,discard_framebuffer}
* in OpenGL ES 2.0. Use
* @ref Magnum::DefaultFramebuffer::clear() "clear()" instead
* where the extension is not supported.
*/
void invalidate(std::initializer_list<InvalidationAttachment> attachments);
@ -407,17 +403,13 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
* @param attachments Attachments to invalidate
* @param rectangle %Rectangle to invalidate
*
* The framebuffer is bound to some target before the operation, if
* not already.
* If extension @extension{ARB,invalidate_subdata} (part of OpenGL
* 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES
* 2.0 or OpenGL ES 3.0 is not available, this function does nothing.
* The framebuffer is bound to some target before the operation, if not
* already.
* @see @fn_gl{InvalidateSubFramebuffer} or @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer}
* on OpenGL ES 2.0
* @requires_gl43 %Extension @extension{ARB,invalidate_subdata}. Use
* @ref Magnum::DefaultFramebuffer::clear() "clear()" instead
* where the extension is not supported.
* @requires_gles30 %Extension @es_extension{EXT,discard_framebuffer}
* in OpenGL ES 2.0. Use
* @ref Magnum::DefaultFramebuffer::clear() "clear()" instead
* where the extension is not supported.
*/
void invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle);

6
src/Magnum/Framebuffer.cpp

@ -112,7 +112,7 @@ std::string Framebuffer::label() const {
return Context::current()->state().debug->getLabelImplementation(GL_FRAMEBUFFER, _id);
}
Framebuffer& Framebuffer::setLabel(const std::string& label) {
Framebuffer& Framebuffer::setLabelInternal(const Containers::ArrayReference<const char> label) {
Context::current()->state().debug->labelImplementation(GL_FRAMEBUFFER, _id, label);
return *this;
}
@ -154,7 +154,7 @@ void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attac
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
invalidateImplementation(attachments.size(), _attachments);
(this->*Context::current()->state().framebuffer->invalidateImplementation)(attachments.size(), _attachments);
}
void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle) {
@ -163,7 +163,7 @@ void Framebuffer::invalidate(std::initializer_list<InvalidationAttachment> attac
for(std::size_t i = 0; i != attachments.size(); ++i)
_attachments[i] = GLenum(*(attachments.begin()+i));
invalidateImplementation(attachments.size(), _attachments, rectangle);
(this->*Context::current()->state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle);
}
Framebuffer& Framebuffer::attachRenderbuffer(const BufferAttachment attachment, Renderbuffer& renderbuffer) {

38
src/Magnum/Framebuffer.h

@ -370,7 +370,14 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje
* @fn_gl_extension2{LabelObject,EXT,debug_label} with
* @def_gl{FRAMEBUFFER}
*/
Framebuffer& setLabel(const std::string& label);
Framebuffer& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Framebuffer& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
}
/**
* @brief Check framebuffer status
@ -466,16 +473,13 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje
* @param attachments Attachments to invalidate
* @param rectangle %Rectangle to invalidate
*
* The framebuffer is bound to some target before the operation, if
* not already.
* @see @fn_gl{InvalidateSubFramebuffer} or @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer}
* If extension @extension{ARB,invalidate_subdata} (part of OpenGL
* 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES
* 2.0 or OpenGL ES 3.0 is not available, this function does nothing.
* The framebuffer is bound to some target before the operation, if not
* already.
* @see @fn_gl{InvalidateFramebuffer} or @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer}
* on OpenGL ES 2.0
* @requires_gl43 %Extension @extension{ARB,invalidate_subdata}. Use
* @ref Magnum::Framebuffer::clear() "clear()" instead where the
* extension is not supported.
* @requires_gles30 %Extension @es_extension{EXT,discard_framebuffer}
* in OpenGL ES 2.0. Use @ref Magnum::Framebuffer::clear() "clear()"
* instead where the extension is not supported.
*/
void invalidate(std::initializer_list<InvalidationAttachment> attachments, const Range2Di& rectangle);
@ -485,11 +489,13 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje
* @param renderbuffer %Renderbuffer
* @return Reference to self (for method chaining)
*
* If @extension{EXT,direct_state_access} is not available and the
* framebufferbuffer is not currently bound, it is bound before the
* operation.
* @see @fn_gl{BindFramebuffer}, @fn_gl{FramebufferRenderbuffer} or
* @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access}
* If extension @extension{ARB,invalidate_subdata} (part of OpenGL
* 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES
* 2.0 or OpenGL ES 3.0 is not available, this function does nothing.
* The framebuffer is bound to some target before the operation, if not
* already.
* @see @fn_gl{InvalidateSubFramebuffer} or @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer}
* on OpenGL ES 2.0
*/
Framebuffer& attachRenderbuffer(BufferAttachment attachment, Renderbuffer& renderbuffer);
@ -643,6 +649,8 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje
#endif
private:
Framebuffer& setLabelInternal(Containers::ArrayReference<const char> label);
void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer);

2
src/Magnum/Implementation/DebugState.h

@ -36,7 +36,7 @@ struct DebugState {
explicit DebugState(Context& context, std::vector<std::string>& extensions);
std::string(*getLabelImplementation)(GLenum, GLuint);
void(*labelImplementation)(GLenum, GLuint, const std::string&);
void(*labelImplementation)(GLenum, GLuint, Containers::ArrayReference<const char>);
void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugMessage::Severity, const std::string&);
void(*messageCallbackImplementation)(DebugMessage::Callback, const void*);

30
src/Magnum/Implementation/FramebufferState.cpp

@ -138,6 +138,36 @@ FramebufferState::FramebufferState(Context& context, std::vector<std::string>& e
renderbufferStorageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationDefault;
#endif
}
/* Framebuffer invalidation implementation on desktop GL */
#ifndef MAGNUM_TARGET_GLES
if(context.isExtensionSupported<Extensions::GL::ARB::invalidate_subdata>()) {
extensions.push_back(Extensions::GL::ARB::invalidate_subdata::string());
invalidateImplementation = &AbstractFramebuffer::invalidateImplementationDefault;
invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationDefault;
} else {
invalidateImplementation = &AbstractFramebuffer::invalidateImplementationNoOp;
invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationNoOp;
}
/* Framebuffer invalidation implementation on ES2 */
#elif defined(MAGNUM_TARGET_GLES2)
if(context.isExtensionSupported<Extensions::GL::EXT::discard_framebuffer>()) {
extensions.push_back(Extensions::GL::EXT::discard_framebuffer::string());
invalidateImplementation = &AbstractFramebuffer::invalidateImplementationDefault;
invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationDefault;
} else {
invalidateImplementation = &AbstractFramebuffer::invalidateImplementationNoOp;
invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationNoOp;
}
/* Always available on ES3 */
#else
invalidateImplementation = &AbstractFramebuffer::invalidateImplementationDefault;
invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationDefault;
#endif
}
void FramebufferState::reset() {

2
src/Magnum/Implementation/FramebufferState.h

@ -51,6 +51,8 @@ struct FramebufferState {
void(AbstractFramebuffer::*drawBuffersImplementation)(GLsizei, const GLenum*);
void(AbstractFramebuffer::*drawBufferImplementation)(GLenum);
void(AbstractFramebuffer::*readBufferImplementation)(GLenum);
void(AbstractFramebuffer::*invalidateImplementation)(GLsizei, const GLenum*);
void(AbstractFramebuffer::*invalidateSubImplementation)(GLsizei, const GLenum*, const Range2Di&);
void(Framebuffer::*renderbufferImplementation)(Framebuffer::BufferAttachment, Renderbuffer&);
#ifndef MAGNUM_TARGET_GLES

3
src/Magnum/Math/Algorithms/CMakeLists.txt

@ -28,6 +28,9 @@ set(MagnumMathAlgorithms_HEADERS
GramSchmidt.h
Svd.h)
# Force IDEs to display all header files in project view
add_custom_target(MagnumMathAlgorithms SOURCES ${MagnumMathAlgorithms_HEADERS})
install(FILES ${MagnumMathAlgorithms_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Algorithms)
if(BUILD_TESTS)

6
src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp

@ -90,9 +90,9 @@ void GramSchmidtTest::orthonormalize() {
CORRADE_COMPARE(Vector3::dot(orthonormalized[1], orthonormalized[2]), 0.0f);
/* Just to be sure */
Matrix3x3 expected(Vector3( 0.303046f, 0.505076f, 0.808122f),
Vector3( 0.928316f, -0.348119f, -0.130544f),
Vector3(-0.215388f, -0.789754f, 0.574367f));
Matrix3x3 expected(Vector3( 0.3030458f, 0.5050763f, 0.8081220f),
Vector3( 0.9283164f, -0.3481189f, -0.1305445f),
Vector3(-0.2153877f, -0.7897540f, 0.5743665f));
CORRADE_COMPARE(orthonormalized, expected);
}

3
src/Magnum/Math/CMakeLists.txt

@ -47,6 +47,9 @@ set(MagnumMath_HEADERS
Vector3.h
Vector4.h)
# Force IDEs to display all header files in project view
add_custom_target(MagnumMath SOURCES ${MagnumMath_HEADERS})
install(FILES ${MagnumMath_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math)
add_subdirectory(Algorithms)

3
src/Magnum/Math/Geometry/CMakeLists.txt

@ -33,6 +33,9 @@ if(BUILD_DEPRECATED)
Rectangle.h)
endif()
# Force IDEs to display all header files in project view
add_custom_target(MagnumMathGeometry SOURCES ${MagnumMathGeometry_HEADERS})
install(FILES ${MagnumMathGeometry_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Geometry)
if(BUILD_TESTS)

14
src/Magnum/Math/Test/Matrix4Test.cpp

@ -274,10 +274,10 @@ void Matrix4Test::rotation() {
CORRADE_COMPARE(Matrix4::rotation(Deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Matrix4());
CORRADE_COMPARE(o.str(), "Math::Matrix4::rotation(): axis must be normalized\n");
Matrix4 matrix({ 0.35612214f, -0.80181062f, 0.47987163f, 0.0f},
{ 0.47987163f, 0.59757638f, 0.6423595f, 0.0f},
{-0.80181062f, 0.0015183985f, 0.59757638f, 0.0f},
{ 0.0f, 0.0f, 0.0f, 1.0f});
Matrix4 matrix({ 0.35612202f, -0.80181062f, 0.47987163f, 0.0f},
{ 0.47987163f, 0.59757626f, 0.6423596f, 0.0f},
{-0.80181062f, 0.00151846f, 0.59757626f, 0.0f},
{ 0.0f, 0.0f, 0.0f, 1.0f});
CORRADE_COMPARE(Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()), matrix);
}
@ -399,9 +399,9 @@ void Matrix4Test::rotationNormalizedPart() {
void Matrix4Test::rotationPart() {
Matrix4 rotation = Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized());
Matrix3x3 expectedRotationPart(Vector3( 0.35612214f, -0.80181062f, 0.47987163f),
Vector3( 0.47987163f, 0.59757638f, 0.6423595f),
Vector3(-0.80181062f, 0.0015183985f, 0.59757638f));
Matrix3x3 expectedRotationPart(Vector3( 0.35612206f, -0.80181074f, 0.47987169f),
Vector3( 0.47987163f, 0.59757626f, 0.64235962f),
Vector3(-0.80181062f, 0.00151846f, 0.59757626f));
/* For rotation and translation this is the same as rotationScaling() */
Matrix4 rotationTranslation = rotation*Matrix4::translation({2.0f, 5.0f, -3.0f});

2
src/Magnum/Math/Test/QuaternionTest.cpp

@ -347,7 +347,7 @@ void QuaternionTest::slerp() {
CORRADE_COMPARE(o.str(), "Math::Quaternion::slerp(): quaternions must be normalized\n");
Quaternion slerp = Quaternion::slerp(a, b, 0.35f);
CORRADE_COMPARE(slerp, Quaternion({0.119165f, 0.0491109f, 0.0491109f}, 0.990442f));
CORRADE_COMPARE(slerp, Quaternion({0.1191653f, 0.0491109f, 0.0491109f}, 0.9904423f));
}
void QuaternionTest::transformVector() {

85
src/Magnum/Math/Test/TypeTraitsTest.cpp

@ -34,17 +34,29 @@ class TypeTraitsTest: public Corrade::TestSuite::Tester {
public:
TypeTraitsTest();
void equalsFloatingPoint();
void equalsIntegral();
void equalsFloatingPoint0();
void equalsFloatingPoint1();
void equalsFloatingPointLarge();
void equalsFloatingPointInfinity();
void equalsFloatingPointNaN();
private:
template<class T> void _equalsFloatingPoint();
template<class T> void _equalsIntegral();
template<class> void _equalsIntegral();
template<class> void _equalsFloatingPoint0();
template<class> void _equalsFloatingPoint1();
template<class> void _equalsFloatingPointLarge();
template<class> void _equalsFloatingPointInfinity();
template<class> void _equalsFloatingPointNaN();
};
TypeTraitsTest::TypeTraitsTest() {
addTests<TypeTraitsTest>({&TypeTraitsTest::equalsIntegral,
&TypeTraitsTest::equalsFloatingPoint});
&TypeTraitsTest::equalsFloatingPoint0,
&TypeTraitsTest::equalsFloatingPoint1,
&TypeTraitsTest::equalsFloatingPointLarge,
&TypeTraitsTest::equalsFloatingPointInfinity,
&TypeTraitsTest::equalsFloatingPointNaN});
}
void TypeTraitsTest::equalsIntegral() {
@ -58,29 +70,68 @@ void TypeTraitsTest::equalsIntegral() {
_equalsIntegral<Long>();
}
void TypeTraitsTest::equalsFloatingPoint() {
_equalsFloatingPoint<Float>();
template<class T> void TypeTraitsTest::_equalsIntegral() {
CORRADE_VERIFY(!TypeTraits<T>::equals(1, 1+TypeTraits<T>::epsilon()));
}
void TypeTraitsTest::equalsFloatingPoint0() {
_equalsFloatingPoint0<Float>();
#ifndef MAGNUM_TARGET_GLES
_equalsFloatingPoint<Double>();
_equalsFloatingPoint0<Double>();
#endif
}
template<class T> void TypeTraitsTest::_equalsIntegral() {
CORRADE_VERIFY(!TypeTraits<T>::equals(1, 1+TypeTraits<T>::epsilon()));
template<class T> void TypeTraitsTest::_equalsFloatingPoint0() {
CORRADE_VERIFY(TypeTraits<T>::equals(T(0)+TypeTraits<T>::epsilon()/T(2), T(0)));
CORRADE_VERIFY(!TypeTraits<T>::equals(T(0)+TypeTraits<T>::epsilon()*T(2), T(0)));
}
template<class T> void TypeTraitsTest::_equalsFloatingPoint() {
void TypeTraitsTest::equalsFloatingPoint1() {
_equalsFloatingPoint1<Float>();
#ifndef MAGNUM_TARGET_GLES
_equalsFloatingPoint1<Double>();
#endif
}
template<class T> void TypeTraitsTest::_equalsFloatingPoint1() {
CORRADE_VERIFY(TypeTraits<T>::equals(T(1)+TypeTraits<T>::epsilon()/T(2), T(1)));
CORRADE_VERIFY(!TypeTraits<T>::equals(T(1)+TypeTraits<T>::epsilon()*T(2), T(1)));
CORRADE_VERIFY(!TypeTraits<T>::equals(T(1)+TypeTraits<T>::epsilon()*T(3), T(1)));
}
void TypeTraitsTest::equalsFloatingPointLarge() {
_equalsFloatingPointLarge<Float>();
#ifndef MAGNUM_TARGET_GLES
_equalsFloatingPointLarge<Double>();
#endif
}
template<class T> void TypeTraitsTest::_equalsFloatingPointLarge() {
CORRADE_VERIFY(TypeTraits<T>::equals(T(25)+TypeTraits<T>::epsilon()*T(2), T(25)));
CORRADE_VERIFY(!TypeTraits<T>::equals(T(25)+TypeTraits<T>::epsilon()*T(75), T(25)));
}
{
CORRADE_EXPECT_FAIL("Comparing to infinity is broken");
CORRADE_VERIFY(TypeTraits<T>::equals(std::numeric_limits<T>::infinity(),
std::numeric_limits<T>::infinity()));
}
void TypeTraitsTest::equalsFloatingPointInfinity() {
_equalsFloatingPointInfinity<Float>();
#ifndef MAGNUM_TARGET_GLES
_equalsFloatingPointInfinity<Double>();
#endif
}
template<class T> void TypeTraitsTest::_equalsFloatingPointInfinity() {
CORRADE_VERIFY(TypeTraits<T>::equals(std::numeric_limits<T>::infinity(),
std::numeric_limits<T>::infinity()));
}
void TypeTraitsTest::equalsFloatingPointNaN() {
_equalsFloatingPointNaN<Float>();
#ifndef MAGNUM_TARGET_GLES
_equalsFloatingPointNaN<Double>();
#endif
}
template<class T> void TypeTraitsTest::_equalsFloatingPointNaN() {
CORRADE_VERIFY(!TypeTraits<T>::equals(std::numeric_limits<T>::quiet_NaN(),
std::numeric_limits<T>::quiet_NaN()));
std::numeric_limits<T>::quiet_NaN()));
}
}}}

4
src/Magnum/Math/Test/UnitTest.cpp

@ -86,8 +86,8 @@ void UnitTest::constructConversion() {
}
void UnitTest::compare() {
CORRADE_VERIFY(Sec(25.0f + TypeTraits<Float>::epsilon()/2) == Sec(25.0f));
CORRADE_VERIFY(Sec(25.0f + TypeTraits<Float>::epsilon()*2) != Sec(25.0f));
CORRADE_VERIFY(Sec(25.0f + TypeTraits<Float>::epsilon()/2.0f) == Sec(25.0f));
CORRADE_VERIFY(Sec(25.0f + TypeTraits<Float>::epsilon()*75.0f) != Sec(25.0f));
constexpr bool c = Sec(3.0f) < Sec(3.0f);
constexpr bool d = Sec(3.0f) <= Sec(3.0f);

40
src/Magnum/Math/TypeTraits.h

@ -36,7 +36,7 @@
/** @brief Precision when testing floats for equality */
#ifndef FLOAT_EQUALITY_PRECISION
#define FLOAT_EQUALITY_PRECISION 1.0e-6f
#define FLOAT_EQUALITY_PRECISION 1.0e-5f
#endif
/** @brief Precision when testing doubles for equality */
@ -107,14 +107,6 @@ template<class T> struct TypeTraits: Implementation::TypeTraitsDefault<T> {
#endif
};
/** @bug Infinity comparison! */
/**
* @todo Implement better fuzzy comparison algorithm, like at
* http://floating-point-gui.de/errors/comparison/ or
* http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
*/
/* Integral scalar types */
namespace Implementation {
template<class T> struct TypeTraitsIntegral: TypeTraitsDefault<T> {
@ -160,13 +152,31 @@ template<> struct TypeTraits<Long>: Implementation::TypeTraitsIntegral<Long> {
/* Floating-point scalar types */
namespace Implementation {
template<class T> struct TypeTraitsFloatingPoint {
TypeTraitsFloatingPoint() = delete;
static bool equals(T a, T b) {
return std::abs(a - b) < TypeTraits<T>::epsilon();
}
};
template<class T> struct TypeTraitsFloatingPoint {
TypeTraitsFloatingPoint() = delete;
static bool equals(T a, T b);
};
/* Adapted from http://floating-point-gui.de/errors/comparison/ */
template<class T> bool TypeTraitsFloatingPoint<T>::equals(const T a, const T b) {
/* Shortcut for binary equality (also infinites) */
if (a == b) return true;
const T absA = std::abs(a);
const T absB = std::abs(b);
const T difference = std::abs(a - b);
/* One of the numbers is zero or both are extremely close to it, relative
error is meaningless */
if (a == T{} || b == T{} || difference < TypeTraits<T>::epsilon())
return difference < TypeTraits<T>::epsilon();
/* Relative error */
return difference/(absA + absB) < TypeTraits<T>::epsilon();
}
}
template<> struct TypeTraits<Float>: Implementation::TypeTraitsFloatingPoint<Float> {

2
src/Magnum/Mesh.cpp

@ -148,7 +148,7 @@ std::string Mesh::label() const {
#endif
}
Mesh& Mesh::setLabel(const std::string& label) {
Mesh& Mesh::setLabelInternal(const Containers::ArrayReference<const char> label) {
#ifndef MAGNUM_TARGET_GLES
Context::current()->state().debug->labelImplementation(GL_VERTEX_ARRAY, _id, label);
#else

11
src/Magnum/Mesh.h

@ -467,7 +467,14 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* @def_gl{VERTEX_ARRAY} or @fn_gl_extension2{LabelObject,EXT,debug_label}
* with @def_gl{VERTEX_ARRAY_OBJECT_EXT}
*/
Mesh& setLabel(const std::string& label);
Mesh& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Mesh& setLabelInternal(const char(&label)[size]) {
return setLabelInternal(label);
}
/**
* @brief Whether the mesh is indexed
@ -836,6 +843,8 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
#endif
#endif
Mesh& setLabelInternal(Containers::ArrayReference<const char> label);
/* Computing stride of interleaved vertex attributes */
template<UnsignedInt location, class T, class ...U> static GLsizei strideOfInterleaved(const AbstractShaderProgram::Attribute<location, T>& attribute, const U&... attributes) {
return attribute.vectorSize()*AbstractShaderProgram::Attribute<location, T>::VectorCount + strideOfInterleaved(attributes...);

4
src/Magnum/MeshTools/CMakeLists.txt

@ -54,7 +54,9 @@ set(MagnumMeshTools_HEADERS
# Set shared library flags for the objects, as they will be part of shared lib
# TODO: fix when CMake sets target_EXPORTS for OBJECT targets as well
add_library(MagnumMeshToolsObjects OBJECT ${MagnumMeshTools_SRCS})
add_library(MagnumMeshToolsObjects OBJECT
${MagnumMeshTools_SRCS}
${MagnumMeshTools_HEADERS})
if(NOT BUILD_SHARED OR BUILD_STATIC_PIC)
# TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property
set_target_properties(MagnumMeshToolsObjects PROPERTIES COMPILE_FLAGS "-DMagnumMeshToolsObjects_EXPORTS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")

4
src/Magnum/MultisampleTexture.h

@ -180,6 +180,10 @@ template<UnsignedInt dimensions> class MultisampleTexture: public AbstractTextur
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> MultisampleTexture<dimensions>& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
#endif
};

191
src/Magnum/Platform/CMakeLists.txt

@ -24,13 +24,16 @@
#
# Headers
set(Platform_HEADERS
set(MagnumPlatform_HEADERS
Platform.h
Screen.h
ScreenedApplication.h
ScreenedApplication.hpp)
install(FILES ${Platform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
# Files to display in project view of IDEs only (filled in below)
set(MagnumPlatform_FILES )
install(FILES ${MagnumPlatform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
# Android application
if(WITH_ANDROIDAPPLICATION)
@ -40,12 +43,21 @@ if(WITH_ANDROIDAPPLICATION)
include_directories(${ANDROID_NATIVE_APP_GLUE_INCLUDE_DIR})
add_library(MagnumAndroidApplication STATIC
set(MagnumAndroidApplication_SRCS
AndroidApplication.cpp
Implementation/Egl.cpp
Implementation/Egl.cpp)
set(MagnumAndroidApplication_HEADERS
AndroidApplication.h)
set(MagnumAndroidApplication_PRIVATE_HEADERS
Implementation/Egl.h)
add_library(MagnumAndroidApplication STATIC
${MagnumAndroidApplication_SRCS}
${MagnumAndroidApplication_HEADERS}
${MagnumAndroidApplication_PRIVATE_HEADERS}
${ANDROID_NATIVE_APP_GLUE_SRC})
set_target_properties(MagnumAndroidApplication PROPERTIES DEBUG_POSTFIX "-d")
install(FILES AndroidApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(FILES ${MagnumAndroidApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumAndroidApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
@ -55,34 +67,45 @@ endif()
# GLUT application
if(WITH_GLUTAPPLICATION)
find_package(GLUT)
if(GLUT_FOUND)
add_library(MagnumGlutApplication STATIC GlutApplication.cpp)
set_target_properties(MagnumGlutApplication PROPERTIES DEBUG_POSTFIX "-d")
install(FILES GlutApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumGlutApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else()
if(NOT GLUT_FOUND)
message(FATAL_ERROR "GLUT library, required by GlutApplication, was not found. Set WITH_GLUTAPPLICATION to OFF to skip building it.")
endif()
set(MagnumGlutApplication_SRCS GlutApplication.cpp)
set(MagnumGlutApplication_HEADERS GlutApplication.h)
add_library(MagnumGlutApplication STATIC
${MagnumGlutApplication_SRCS}
${MagnumGlutApplication_HEADERS})
set_target_properties(MagnumGlutApplication PROPERTIES DEBUG_POSTFIX "-d")
install(FILES ${MagnumGlutApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumGlutApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
endif()
# SDL2 application
if(WITH_SDL2APPLICATION)
find_package(SDL2)
if(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIR})
add_library(MagnumSdl2Application STATIC Sdl2Application.cpp)
set_target_properties(MagnumSdl2Application PROPERTIES DEBUG_POSTFIX "-d")
install(FILES Sdl2Application.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumSdl2Application
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
else()
if(NOT SDL2_FOUND)
message(FATAL_ERROR "SDL2 library, required by Sdl2Application, was not found. Set WITH_SDL2APPLICATION to OFF to skip building it.")
endif()
include_directories(${SDL2_INCLUDE_DIR})
set(MagnumSdl2Application_SRCS Sdl2Application.cpp)
set(MagnumSdl2Application_HEADERS Sdl2Application.h)
add_library(MagnumSdl2Application STATIC
${MagnumSdl2Application_SRCS}
${MagnumSdl2Application_HEADERS})
set_target_properties(MagnumSdl2Application PROPERTIES DEBUG_POSTFIX "-d")
install(FILES ${MagnumSdl2Application_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumSdl2Application
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
endif()
# NaCl application
@ -91,9 +114,14 @@ if(WITH_NACLAPPLICATION)
message(FATAL_ERROR "NaClApplication is available only when targeting Google Chrome Native Client. Set WITH_NACLAPPLICATION to OFF to skip building it.")
endif()
add_library(MagnumNaClApplication STATIC NaClApplication.cpp)
set(MagnumNaClApplication_SRCS NaClApplication.cpp)
set(MagnumNaClApplication_HEADERS NaClApplication.h)
add_library(MagnumNaClApplication STATIC
${MagnumNaClApplication_SRCS}
${MagnumNaClApplication_HEADERS})
set_target_properties(MagnumNaClApplication PROPERTIES DEBUG_POSTFIX "-d")
install(FILES NaClApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(FILES ${MagnumNaClApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumNaClApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
@ -106,9 +134,15 @@ if(WITH_WINDOWLESSNACLAPPLICATION)
message(FATAL_ERROR "WindowlessNaClApplication is available only when targeting Google Chrome Native Client. Set WITH_WINDOWLESSNACLAPPLICATION to OFF to skip building it.")
endif()
add_library(MagnumWindowlessNaClApplication STATIC WindowlessNaClApplication.cpp)
set(MagnumWindowlessNaClApplication_SRCS WindowlessNaClApplication.cpp)
set(MagnumWindowlessNaClApplication_HEADERS WindowlessNaClApplication.h)
add_library(MagnumWindowlessNaClApplication STATIC
${MagnumWindowlessNaClApplication_SRCS}
${MagnumWindowlessNaClApplication_HEADERS})
set_target_properties(MagnumWindowlessNaClApplication PROPERTIES DEBUG_POSTFIX "-d")
install(FILES WindowlessNaClApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
target_link_libraries(MagnumWindowlessNaClApplication Magnum ppapi_cpp ppapi)
install(FILES ${MagnumWindowlessNaClApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumWindowlessNaClApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
@ -117,24 +151,38 @@ endif()
# JavaScript and CSS stuff for NaCl
if(WITH_NACLAPPLICATION OR WITH_WINDOWLESSNACLAPPLICATION)
install(FILES NaClApplication.js WebApplication.css DESTINATION ${MAGNUM_DATA_INSTALL_DIR})
set(MagnumNaClApplication_FILES
NaClApplication.js
WebApplication.css)
list(APPEND MagnumPlatform_FILES ${MagnumNaClApplication_FILES})
install(FILES ${MagnumNaClApplication_FILES} DESTINATION ${MAGNUM_DATA_INSTALL_DIR})
endif()
# JavaScript and CSS stuff for Emscripten
if(WITH_SDL2APPLICATION AND CORRADE_TARGET_EMSCRIPTEN)
install(FILES EmscriptenApplication.js WebApplication.css DESTINATION ${MAGNUM_DATA_INSTALL_DIR})
set(MagnumSdl2Application_FILES
EmscriptenApplication.js
WebApplication.css)
list(APPEND MagnumPlatform_FILES ${MagnumSdl2Application_FILES})
install(FILES ${MagnumSdl2Application_FILES} DESTINATION ${MAGNUM_DATA_INSTALL_DIR})
endif()
# GLX application
if(WITH_GLXAPPLICATION)
set(NEED_ABSTRACTXAPPLICATION 1)
set(NEED_GLXCONTEXT 1)
add_library(MagnumGlxApplication STATIC
set(MagnumGlxApplication_SRCS
$<TARGET_OBJECTS:MagnumAbstractXApplication>
$<TARGET_OBJECTS:MagnumGlxContextHandler>
GlxApplication.cpp)
set(MagnumGlxApplication_HEADERS GlxApplication.h)
add_library(MagnumGlxApplication STATIC
${MagnumGlxApplication_SRCS}
${MagnumGlxApplication_HEADERS})
set_target_properties(MagnumGlxApplication PROPERTIES DEBUG_POSTFIX "-d")
install(FILES GlxApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(FILES ${MagnumGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumGlxApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
@ -145,12 +193,18 @@ endif()
if(WITH_XEGLAPPLICATION)
set(NEED_ABSTRACTXAPPLICATION 1)
set(NEED_EGLCONTEXT 1)
add_library(MagnumXEglApplication STATIC
set(MagnumXEglApplication_SRCS
$<TARGET_OBJECTS:MagnumAbstractXApplication>
$<TARGET_OBJECTS:MagnumEglContextHandler>
XEglApplication.cpp)
set(MagnumXEglApplication_HEADERS XEglApplication.h)
add_library(MagnumXEglApplication STATIC
${MagnumXEglApplication_SRCS}
${MagnumXEglApplication_HEADERS})
set_target_properties(MagnumXEglApplication PROPERTIES DEBUG_POSTFIX "-d")
install(FILES XEglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(FILES ${MagnumXEglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumXEglApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
@ -166,12 +220,18 @@ endif()
# Windowless GLX application
if(WITH_WINDOWLESSGLXAPPLICATION)
add_library(MagnumWindowlessGlxApplication STATIC WindowlessGlxApplication.cpp)
set(MagnumWindowlessGlxApplication_SRCS WindowlessGlxApplication.cpp)
set(MagnumWindowlessGlxApplication_HEADERS WindowlessGlxApplication.h)
add_library(MagnumWindowlessGlxApplication STATIC
${MagnumWindowlessGlxApplication_SRCS}
${MagnumWindowlessGlxApplication_HEADERS})
# X11 macros are a mess, disable warnings for C-style casts
set_target_properties(MagnumWindowlessGlxApplication PROPERTIES
COMPILE_FLAGS "-Wno-old-style-cast"
DEBUG_POSTFIX "-d")
install(FILES WindowlessGlxApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
target_link_libraries(MagnumWindowlessGlxApplication Magnum ${X11_LIBRARIES})
install(FILES ${MagnumWindowlessGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumWindowlessGlxApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
@ -180,11 +240,17 @@ endif()
# Windowless WGL application
if(WITH_WINDOWLESSWGLAPPLICATION)
add_library(MagnumWindowlessWglApplication STATIC WindowlessWglApplication.cpp)
set(MagnumWindowlessWglApplication_SRCS WindowlessWglApplication.cpp)
set(MagnumWindowlessWglApplication_HEADERS WindowlessWglApplication.h)
add_library(MagnumWindowlessWglApplication STATIC
${MagnumWindowlessWglApplication_SRCS}
${MagnumWindowlessWglApplication_HEADERS})
set_target_properties(MagnumWindowlessWglApplication PROPERTIES
COMPILE_FLAGS "-DUNICODE"
DEBUG_POSTFIX "-d")
install(FILES WindowlessWglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
target_link_libraries(MagnumWindowlessWglApplication Magnum)
install(FILES ${MagnumWindowlessWglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumWindowlessWglApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
@ -193,8 +259,15 @@ endif()
# Windowless CGL application
if(WITH_WINDOWLESSCGLAPPLICATION)
add_library(MagnumWindowlessCglApplication STATIC WindowlessCglApplication.cpp)
install(FILES WindowlessCglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
set(MagnumWindowlessCglApplication_SRCS WindowlessCglApplication.cpp)
set(MagnumWindowlessCglApplication_HEADERS WindowlessCglApplication.h)
add_library(MagnumWindowlessCglApplication STATIC
${MagnumWindowlessCglApplication_SRCS}
${MagnumWindowlessCglApplication_HEADERS})
set_target_properties(MagnumWindowlessCglApplication PROPERTIES DEBUG_POSTFIX "-d")
target_link_libraries(MagnumWindowlessCglApplication Magnum)
install(FILES ${MagnumWindowlessGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(TARGETS MagnumWindowlessCglApplication
RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
@ -203,15 +276,28 @@ endif()
# Abstract X application
if(NEED_ABSTRACTXAPPLICATION)
add_library(MagnumAbstractXApplication OBJECT AbstractXApplication.cpp)
set(MagnumAbstractXApplication_SRCS AbstractXApplication.cpp)
set(MagnumAbstractXApplication_HEADERS AbstractXApplication.h)
add_library(MagnumAbstractXApplication OBJECT
${MagnumAbstractXApplication_SRCS}
${MagnumAbstractXApplication_HEADERS})
# X11 macros are a mess, disable warnings for C-style casts
set_target_properties(MagnumAbstractXApplication PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast")
install(FILES AbstractXApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
install(FILES ${MagnumAbstractXApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform)
endif()
# GLX context
if(NEED_GLXCONTEXT)
add_library(MagnumGlxContextHandler OBJECT Implementation/GlxContextHandler.cpp)
set(MagnumGlxContextHandler_SRCS
Implementation/GlxContextHandler.cpp)
set(MagnumGlxContextHandler_PRIVATE_HEADERS
Implementation/AbstractContextHandler.h
Implementation/GlxContextHandler.h)
add_library(MagnumGlxContextHandler OBJECT
${MagnumGlxContextHandler_SRCS}
${MagnumGlxContextHandler_PRIVATE_HEADERS})
# X11 macros are a mess, disable warnings for C-style casts
set_target_properties(MagnumGlxContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast")
endif()
@ -222,9 +308,18 @@ if(NEED_EGLCONTEXT)
if(NOT EGL_FOUND)
message(FATAL_ERROR "EGL library, required by some window contexts, was not found. Set WITH_*EGL*APPLICATION to OFF to skip building them.")
endif()
add_library(MagnumEglContextHandler OBJECT
set(MagnumEglContextHandler_SRCS
Implementation/EglContextHandler.cpp
Implementation/Egl.cpp)
set(MagnumEglContextHandler_PRIVATE_HEADERS
Implementation/AbstractContextHandler.h
Implementation/EglContextHandler.h
Implementation/Egl.h)
add_library(MagnumEglContextHandler OBJECT
${MagnumEglContextHandler_SRCS}
${MagnumEglContextHandler_PRIVATE_HEADERS})
# X11 macros are a mess, disable warnings for C-style casts
set_target_properties(MagnumEglContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast")
endif()
@ -235,9 +330,9 @@ if(WITH_MAGNUMINFO)
if(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-info MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_NACL)
target_link_libraries(magnum-info MagnumWindowlessNaClApplication ppapi_cpp ppapi)
target_link_libraries(magnum-info MagnumWindowlessNaClApplication)
elseif(CORRADE_TARGET_UNIX)
target_link_libraries(magnum-info MagnumWindowlessGlxApplication ${X11_LIBRARIES})
target_link_libraries(magnum-info MagnumWindowlessGlxApplication)
elseif(CORRADE_TARGET_WINDOWS)
target_link_libraries(magnum-info MagnumWindowlessWglApplication)
else()
@ -249,5 +344,9 @@ if(WITH_MAGNUMINFO)
if(CORRADE_TARGET_NACL)
install(FILES magnum-info-nacl.html DESTINATION ${MAGNUM_DATA_INSTALL_DIR} RENAME magnum-info.html)
install(FILES magnum-info-nacl.nmf DESTINATION ${MAGNUM_DATA_INSTALL_DIR} RENAME magnum-info.nmf)
list(APPEND MagnumPlatform_FILES magnum-info-nacl.html magnum-info-nacl.nmf)
endif()
endif()
# Force IDEs display also all header files and additional files in project view
add_custom_target(MagnumPlatform SOURCES ${MagnumPlatform_HEADERS} ${MagnumPlatform_FILES})

10
src/Magnum/Primitives/CMakeLists.txt

@ -52,7 +52,15 @@ set(MagnumPrimitives_HEADERS
visibility.h)
add_library(MagnumPrimitives ${SHARED_OR_STATIC} ${MagnumPrimitives_SRCS})
# Header files to display in project view of IDEs only
set(MagnumPrimitives_PRIVATE_HEADERS
Implementation/Spheroid.h
Implementation/WireframeSpheroid.h)
add_library(MagnumPrimitives ${SHARED_OR_STATIC}
${MagnumPrimitives_SRCS}
${MagnumPrimitives_HEADERS}
${MagnumPrimitives_PRIVATE_HEADERS})
set_target_properties(MagnumPrimitives PROPERTIES DEBUG_POSTFIX "-d")
if(BUILD_STATIC_PIC)
# TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property

2
src/Magnum/Query.cpp

@ -66,7 +66,7 @@ std::string AbstractQuery::label() const {
#endif
}
AbstractQuery& AbstractQuery::setLabel(const std::string& label) {
AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayReference<const char> label) {
#ifndef MAGNUM_TARGET_GLES
Context::current()->state().debug->labelImplementation(GL_QUERY, _id, label);
#else

24
src/Magnum/Query.h

@ -29,6 +29,7 @@
* @brief Class @ref Magnum::AbstractQuery, @ref Magnum::PrimitiveQuery, @ref Magnum::SampleQuery, @ref Magnum::TimeQuery
*/
#include <Corrade/Containers/Array.h>
#include <Corrade/Utility/Assert.h>
#include "Magnum/AbstractObject.h"
@ -84,7 +85,14 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
* @def_gl{QUERY} or @fn_gl_extension2{LabelObject,EXT,debug_label}
* with @def_gl{QUERY_OBJECT_EXT}
*/
AbstractQuery& setLabel(const std::string& label);
AbstractQuery& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> AbstractQuery& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
}
/**
* @brief Whether the result is available
@ -140,6 +148,8 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
void begin(GLenum target);
private:
AbstractQuery& setLabelInternal(Containers::ArrayReference<const char> label);
GLuint _id;
GLenum target;
};
@ -227,6 +237,10 @@ class PrimitiveQuery: public AbstractQuery {
AbstractQuery::setLabel(label);
return *this;
}
template<std::size_t size> PrimitiveQuery& setLabel(const char(&label)[size]) {
AbstractQuery::setLabel<size>(label);
return *this;
}
#endif
};
#endif
@ -387,6 +401,10 @@ class SampleQuery: public AbstractQuery {
AbstractQuery::setLabel(label);
return *this;
}
template<std::size_t size> SampleQuery& setLabel(const char(&label)[size]) {
AbstractQuery::setLabel<size>(label);
return *this;
}
#endif
};
@ -476,6 +494,10 @@ class TimeQuery: public AbstractQuery {
AbstractQuery::setLabel(label);
return *this;
}
template<std::size_t size> TimeQuery& setLabel(const char(&label)[size]) {
AbstractQuery::setLabel<size>(label);
return *this;
}
#endif
};

4
src/Magnum/RectangleTexture.h

@ -404,6 +404,10 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> RectangleTexture& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
#endif
};

2
src/Magnum/Renderbuffer.cpp

@ -81,7 +81,7 @@ std::string Renderbuffer::label() const {
return Context::current()->state().debug->getLabelImplementation(GL_RENDERBUFFER, _id);
}
Renderbuffer& Renderbuffer::setLabel(const std::string& label) {
Renderbuffer& Renderbuffer::setLabelInternal(const Containers::ArrayReference<const char> label) {
Context::current()->state().debug->labelImplementation(GL_RENDERBUFFER, _id, label);
return *this;
}

13
src/Magnum/Renderbuffer.h

@ -29,6 +29,8 @@
* @brief Class @ref Magnum::Renderbuffer
*/
#include <Corrade/Containers/Array.h>
#include "Magnum/AbstractObject.h"
#include "Magnum/Magnum.h"
@ -139,7 +141,14 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject {
* @fn_gl_extension2{LabelObject,EXT,debug_label} with
* @def_gl{RENDERBUFFER}
*/
Renderbuffer& setLabel(const std::string& label);
Renderbuffer& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Renderbuffer& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
}
/**
* @brief Set renderbuffer storage
@ -173,6 +182,8 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject {
void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size);
private:
Renderbuffer& setLabelInternal(Containers::ArrayReference<const char> label);
void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size);

10
src/Magnum/Renderer.cpp

@ -35,8 +35,16 @@
namespace Magnum {
void Renderer::enable(const Feature feature) {
glEnable(GLenum(feature));
}
void Renderer::disable(const Feature feature) {
glDisable(GLenum(feature));
}
void Renderer::setFeature(const Feature feature, const bool enabled) {
enabled ? glEnable(GLenum(feature)) : glDisable(GLenum(feature));
enabled ? enable(feature) : disable(feature);
}
void Renderer::setHint(const Hint target, const HintMode mode) {

25
src/Magnum/Renderer.h

@ -74,7 +74,7 @@ class MAGNUM_EXPORT Renderer {
* @brief Features
*
* All features are disabled by default unless specified otherwise.
* @see @ref setFeature()
* @see @ref enable(), @ref disable(), @ref setFeature()
*/
enum class Feature: GLenum {
/**
@ -219,9 +219,28 @@ class MAGNUM_EXPORT Renderer {
};
/**
* @brief Set feature
* @brief Enable feature
*
* @see @fn_gl{Enable}/@fn_gl{Disable}
* @see @ref disable(), @ref setFeature(), @fn_gl{Enable}
*/
static void enable(Feature feature);
/**
* @brief Disable feature
*
* @see @ref enable(), @ref setFeature(), @fn_gl{Disable}
*/
static void disable(Feature feature);
/**
* @brief Enable or disable feature
*
* Convenience equivalent to the following:
* @code
* enabled ? Renderer::enable(feature) : Renderer::disable(feature)
* @endcode
* Prefer to use @ref enable() and @ref disable() directly to avoid
* unnecessary branching.
*/
static void setFeature(Feature feature, bool enabled);

4
src/Magnum/SceneGraph/CMakeLists.txt

@ -71,7 +71,9 @@ set(MagnumSceneGraph_HEADERS
# Set shared library flags for the objects, as they will be part of shared lib
# TODO: fix when CMake sets target_EXPORTS for OBJECT targets as well
add_library(MagnumSceneGraphObjects OBJECT ${MagnumSceneGraph_SRCS})
add_library(MagnumSceneGraphObjects OBJECT
${MagnumSceneGraph_SRCS}
${MagnumSceneGraph_HEADERS})
if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
# TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property
set_target_properties(MagnumSceneGraphObjects PROPERTIES COMPILE_FLAGS "-DMagnumSceneGraphObjects_EXPORTS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")

4
src/Magnum/SceneGraph/Drawable.h

@ -109,9 +109,9 @@ void MyApplication::drawEvent() {
.setAmbientColor(ambientColor);
camera.draw(phongObjects);
Renderer::setFeature(Renderer::Feature::Blending, true);
Renderer::enable(Renderer::Feature::Blending);
camera.draw(transparentObjects);
Renderer::setFeature(Renderer::Feature::Blending, false);
Renderer::disable(Renderer::Feature::Blending);
// ...
}

2
src/Magnum/Shader.cpp

@ -581,7 +581,7 @@ std::string Shader::label() const {
#endif
}
Shader& Shader::setLabel(const std::string& label) {
Shader& Shader::setLabelInternal(const Containers::ArrayReference<const char> label) {
#ifndef MAGNUM_TARGET_GLES
Context::current()->state().debug->labelImplementation(GL_SHADER, _id, label);
#else

12
src/Magnum/Shader.h

@ -32,6 +32,7 @@
#include <functional>
#include <string>
#include <vector>
#include <Corrade/Containers/Array.h>
#include "Magnum/AbstractObject.h"
#include "Magnum/Magnum.h"
@ -508,7 +509,14 @@ class MAGNUM_EXPORT Shader: public AbstractObject {
* @def_gl{SHADER} or @fn_gl_extension2{LabelObject,EXT,debug_label}
* with @def_gl{SHADER_OBJECT_EXT}
*/
Shader& setLabel(const std::string& label);
Shader& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Shader& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
}
/** @brief %Shader type */
Type type() const { return _type; }
@ -552,6 +560,8 @@ class MAGNUM_EXPORT Shader: public AbstractObject {
}
private:
Shader& setLabelInternal(Containers::ArrayReference<const char> label);
Type _type;
GLuint _id;

10
src/Magnum/Shaders/CMakeLists.txt

@ -34,8 +34,6 @@ set(MagnumShaders_SRCS
Vector.cpp
VertexColor.cpp
Implementation/CreateCompatibilityShader.cpp
${MagnumShaders_RCS})
set(MagnumShaders_HEADERS
@ -51,6 +49,9 @@ set(MagnumShaders_HEADERS
visibility.h)
# Header files to display in project view of IDEs only
set(MagnumShaders_PRIVATE_HEADERS Implementation/CreateCompatibilityShader.h)
if(BUILD_STATIC)
set(MagnumShaders_HEADERS ${MagnumShaders_HEADERS} resourceImport.hpp)
@ -59,7 +60,10 @@ if(BUILD_STATIC)
endif()
endif()
add_library(MagnumShaders ${SHARED_OR_STATIC} ${MagnumShaders_SRCS})
add_library(MagnumShaders ${SHARED_OR_STATIC}
${MagnumShaders_SRCS}
${MagnumShaders_HEADERS}
${MagnumShaders_PRIVATE_HEADERS})
set_target_properties(MagnumShaders PROPERTIES DEBUG_POSTFIX "-d")
if(BUILD_STATIC_PIC)
# TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property

3
src/Magnum/Shaders/DistanceFieldVector.cpp

@ -65,8 +65,7 @@ template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldV
std::initializer_list<std::reference_wrapper<Shader>> ss{std::ref(frag), std::ref(vert)};
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile(ss));
AbstractShaderProgram::attachShader(frag);
AbstractShaderProgram::attachShader(vert);
AbstractShaderProgram::attachShaders({frag, vert});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))

3
src/Magnum/Shaders/Flat.cpp

@ -70,8 +70,7 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): tran
std::initializer_list<std::reference_wrapper<Shader>> ss{std::ref(frag), std::ref(vert)};
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile(ss));
attachShader(vert);
attachShader(frag);
attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))

58
src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp

@ -1,58 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
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.
*/
#include "CreateCompatibilityShader.h"
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
namespace Magnum { namespace Shaders { namespace Implementation {
Shader createCompatibilityShader(const Version version, const Shader::Type type) {
Shader shader(version, type);
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionDisabled<Extensions::GL::ARB::explicit_attrib_location>(version))
shader.addSource("#define DISABLE_GL_ARB_explicit_attrib_location\n");
if(Context::current()->isExtensionDisabled<Extensions::GL::ARB::shading_language_420pack>(version))
shader.addSource("#define DISABLE_GL_ARB_shading_language_420pack\n");
if(Context::current()->isExtensionDisabled<Extensions::GL::ARB::explicit_uniform_location>(version))
shader.addSource("#define DISABLE_GL_ARB_explicit_uniform_location\n");
#endif
/* My Android emulator (running on NVidia) doesn't define GL_ES
preprocessor macro, thus *all* the stock shaders fail to compile */
/** @todo remove this when Android emulator is sane */
#ifdef CORRADE_TARGET_ANDROID
shader.addSource("#ifndef GL_ES\n#define GL_ES 1\n#endif\n");
#endif
shader.addSource(Utility::Resource("MagnumShaders").get("compatibility.glsl"));
return shader;
}
}}}

27
src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h

@ -25,11 +25,36 @@
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/Utility/Resource.h>
#include "Magnum/Context.h"
#include "Magnum/Extensions.h"
#include "Magnum/Shader.h"
namespace Magnum { namespace Shaders { namespace Implementation {
Shader createCompatibilityShader(Version version, Shader::Type type);
inline Shader createCompatibilityShader(Version version, Shader::Type type) {
Shader shader(version, type);
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionDisabled<Extensions::GL::ARB::explicit_attrib_location>(version))
shader.addSource("#define DISABLE_GL_ARB_explicit_attrib_location\n");
if(Context::current()->isExtensionDisabled<Extensions::GL::ARB::shading_language_420pack>(version))
shader.addSource("#define DISABLE_GL_ARB_shading_language_420pack\n");
if(Context::current()->isExtensionDisabled<Extensions::GL::ARB::explicit_uniform_location>(version))
shader.addSource("#define DISABLE_GL_ARB_explicit_uniform_location\n");
#endif
/* My Android emulator (running on NVidia) doesn't define GL_ES
preprocessor macro, thus *all* the stock shaders fail to compile */
/** @todo remove this when Android emulator is sane */
#ifdef CORRADE_TARGET_ANDROID
shader.addSource("#ifndef GL_ES\n#define GL_ES 1\n#endif\n");
#endif
shader.addSource(Utility::Resource("MagnumShaders").get("compatibility.glsl"));
return shader;
}
}}}

3
src/Magnum/Shaders/MeshVisualizer.cpp

@ -88,8 +88,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP
#endif
Shader::compile({std::ref(vert), std::ref(frag)});
attachShader(vert);
attachShader(frag);
attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(geom) attachShader(*geom);
#endif

3
src/Magnum/Shaders/Phong.cpp

@ -67,8 +67,7 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri
/* GCC 4.4 has explicit std::reference_wrapper constructor */
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({std::ref(vert), std::ref(frag)}));
attachShader(vert);
attachShader(frag);
attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))

3
src/Magnum/Shaders/Vector.cpp

@ -65,8 +65,7 @@ template<UnsignedInt dimensions> Vector<dimensions>::Vector(): transformationPro
std::initializer_list<std::reference_wrapper<Shader>> ss{std::ref(frag), std::ref(vert)};
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile(ss));
AbstractShaderProgram::attachShader(vert);
AbstractShaderProgram::attachShader(frag);
AbstractShaderProgram::attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))

3
src/Magnum/Shaders/VertexColor.cpp

@ -73,8 +73,7 @@ template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor(): transfo
std::initializer_list<std::reference_wrapper<Shader>> ss{std::ref(frag), std::ref(vert)};
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile(ss));
attachShader(vert);
attachShader(frag);
attachShaders({vert, frag});
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version))

8
src/Magnum/Shapes/CMakeLists.txt

@ -61,7 +61,13 @@ set(MagnumShapes_HEADERS
shapeImplementation.h
visibility.h)
add_library(MagnumShapes ${SHARED_OR_STATIC} ${MagnumShapes_SRCS})
# Header files to display in project view of IDEs only
set(MagnumShapes_PRIVATE_HEADERS Implementation/CollisionDispatch.h)
add_library(MagnumShapes ${SHARED_OR_STATIC}
${MagnumShapes_SRCS}
${MagnumShapes_HEADERS}
${MagnumShapes_PRIVATE_HEADERS})
set_target_properties(MagnumShapes PROPERTIES DEBUG_POSTFIX "-d")
if(BUILD_STATIC_PIC)
# TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property

4
src/Magnum/Test/AbstractOpenGLTester.h

@ -54,8 +54,8 @@ class AbstractOpenGLTester: public TestSuite::Tester, public Platform::Windowles
AbstractOpenGLTester::AbstractOpenGLTester(): Platform::WindowlessApplication({zero, nullptr}) {
if(Context::current()->isExtensionSupported<Extensions::GL::KHR::debug>()) {
Renderer::setFeature(Renderer::Feature::DebugOutput, true);
Renderer::setFeature(Renderer::Feature::DebugOutputSynchronous, true);
Renderer::enable(Renderer::Feature::DebugOutput);
Renderer::enable(Renderer::Feature::DebugOutputSynchronous);
DebugMessage::setDefaultCallback();
}
}

8
src/Magnum/Test/AbstractQueryGLTest.cpp

@ -113,7 +113,15 @@ void AbstractQueryGLTest::label() {
!Context::current()->isExtensionSupported<Extensions::GL::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
{
/** @todo Is this even legal optimization? */
CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
SampleQuery query;
query.begin(SampleQuery::Target::AnySamplesPassed);
query.end();
CORRADE_COMPARE(query.label(), "");
query.setLabel("MyQuery");

29
src/Magnum/Test/AbstractShaderProgramGLTest.cpp

@ -155,7 +155,7 @@ void AbstractShaderProgramGLTest::label() {
namespace {
struct MyPublicShader: AbstractShaderProgram {
using AbstractShaderProgram::attachShader;
using AbstractShaderProgram::attachShaders;
using AbstractShaderProgram::bindAttributeLocation;
#ifndef MAGNUM_TARGET_GLES
using AbstractShaderProgram::bindFragmentDataLocationIndexed;
@ -190,8 +190,7 @@ void AbstractShaderProgramGLTest::create() {
CORRADE_VERIFY(fragCompiled);
MyPublicShader program;
program.attachShader(vert);
program.attachShader(frag);
program.attachShaders({vert, frag});
MAGNUM_VERIFY_NO_ERROR();
@ -232,8 +231,7 @@ void AbstractShaderProgramGLTest::createMultipleOutputs() {
CORRADE_VERIFY(fragCompiled);
MyPublicShader program;
program.attachShader(vert);
program.attachShader(frag);
program.attachShaders({vert, frag});
MAGNUM_VERIFY_NO_ERROR();
@ -270,8 +268,7 @@ void AbstractShaderProgramGLTest::createMultipleOutputsIndexed() {
CORRADE_VERIFY(fragCompiled);
MyPublicShader program;
program.attachShader(vert);
program.attachShader(frag);
program.attachShaders({vert, frag});
MAGNUM_VERIFY_NO_ERROR();
@ -306,21 +303,17 @@ MyShader::MyShader() {
#ifndef MAGNUM_TARGET_GLES
Shader vert(Version::GL210, Shader::Type::Vertex);
#else
Shader vert(Version::GLES200, Shader::Type::Vertex);
#endif
vert.addSource(rs.get("MyShader.vert"))
.compile();
attachShader(vert);
#ifndef MAGNUM_TARGET_GLES
Shader frag(Version::GL210, Shader::Type::Fragment);
#else
Shader vert(Version::GLES200, Shader::Type::Vertex);
Shader frag(Version::GLES200, Shader::Type::Fragment);
#endif
frag.addSource(rs.get("MyShader.frag"))
.compile();
attachShader(frag);
vert.addSource(rs.get("MyShader.vert"));
frag.addSource(rs.get("MyShader.frag"));
Shader::compile({vert, frag});
attachShaders({vert, frag});
bindAttributeLocation(0, "position");
link();

7
src/Magnum/Test/AbstractTextureGLTest.cpp

@ -100,7 +100,14 @@ void AbstractTextureGLTest::label() {
!Context::current()->isExtensionSupported<Extensions::GL::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
{
/** @todo Is this even legal optimization? */
CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
Texture2D texture;
texture.setMinificationFilter(Sampler::Filter::Linear);
CORRADE_COMPARE(texture.label(), "");
texture.setLabel("MyTexture");

7
src/Magnum/Test/BufferGLTest.cpp

@ -125,7 +125,14 @@ void BufferGLTest::label() {
!Context::current()->isExtensionSupported<Extensions::GL::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
{
/** @todo Is this even legal optimization? */
CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
Buffer buffer;
buffer.setData({nullptr, 3}, BufferUsage::StaticDraw);
CORRADE_COMPARE(buffer.label(), "");
buffer.setLabel("MyBuffer");

2
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -467,7 +467,7 @@ void CubeMapTextureGLTest::invalidateImage() {
void CubeMapTextureGLTest::invalidateSubImage() {
CubeMapTexture texture;
texture.setStorage(2, TextureFormat::RGBA8, Vector2i(32));
texture.invalidateSubImage(1, Vector3i(2), Vector3i(8));
texture.invalidateSubImage(1, Vector3i(2), Vector3i(Vector2i(8), 4));
MAGNUM_VERIFY_NO_ERROR();
}

6
src/Magnum/Test/DebugGLTest.cpp

@ -77,16 +77,16 @@ void DebugGLTest::insertMessage() {
if(!Context::current()->isExtensionSupported<Extensions::GL::KHR::debug>())
CORRADE_SKIP(Extensions::GL::KHR::debug::string() + std::string(" is not supported"));
Renderer::setFeature(Renderer::Feature::DebugOutput, true);
Renderer::enable(Renderer::Feature::DebugOutput);
Renderer::setFeature(Renderer::Feature::DebugOutputSynchronous, true);
Renderer::enable(Renderer::Feature::DebugOutputSynchronous);
std::ostringstream out;
Debug::setOutput(&out);
DebugMessage::setDefaultCallback();
DebugMessage::insert(DebugMessage::Source::Application, DebugMessage::Type::Marker,
1337, DebugMessage::Severity::Notification, "Hello from OpenGL command stream!");
Renderer::setFeature(Renderer::Feature::DebugOutput, false);
Renderer::enable(Renderer::Feature::DebugOutput);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(out.str(),

22
src/Magnum/Test/FramebufferGLTest.cpp

@ -206,7 +206,19 @@ void FramebufferGLTest::label() {
!Context::current()->isExtensionSupported<Extensions::GL::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
{
/** @todo Is this even legal optimization? */
CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
Renderbuffer renderbuffer;
#ifndef MAGNUM_TARGET_GLES2
renderbuffer.setStorage(RenderbufferFormat::RGBA8, {128, 128});
#else
renderbuffer.setStorage(RenderbufferFormat::RGBA4, {128, 128});
#endif
Framebuffer framebuffer({{}, Vector2i(32)});
framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment(Framebuffer::BufferAttachment::Depth), renderbuffer);
CORRADE_COMPARE(framebuffer.label(), "");
MAGNUM_VERIFY_NO_ERROR();
@ -638,11 +650,6 @@ void FramebufferGLTest::invalidate() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::invalidate_subdata>())
CORRADE_SKIP(Extensions::GL::ARB::invalidate_subdata::string() + std::string(" is not available."));
#elif defined(MAGNUM_TARGET_GLES2)
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::discard_framebuffer>())
CORRADE_SKIP(Extensions::GL::EXT::discard_framebuffer::string() + std::string(" is not available."));
#endif
Renderbuffer color;
@ -670,11 +677,6 @@ void FramebufferGLTest::invalidateSub() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::invalidate_subdata>())
CORRADE_SKIP(Extensions::GL::ARB::invalidate_subdata::string() + std::string(" is not available."));
#elif defined(MAGNUM_TARGET_GLES2)
if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::discard_framebuffer>())
CORRADE_SKIP(Extensions::GL::EXT::discard_framebuffer::string() + std::string(" is not available."));
#endif
Renderbuffer color;

24
src/Magnum/Test/MeshGLTest.cpp

@ -302,7 +302,15 @@ void MeshGLTest::label() {
!Context::current()->isExtensionSupported<Extensions::GL::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
{
/** @todo Is this even legal optimization? */
CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
Buffer buffer{Buffer::Target::ElementArray};
Mesh mesh;
mesh.setIndexBuffer(buffer, 0, Mesh::IndexType::UnsignedShort);
CORRADE_COMPARE(mesh.label(), "");
mesh.setLabel("MyMesh");
@ -377,8 +385,8 @@ FloatShader::FloatShader(const std::string& type, const std::string& conversion)
/* GCC 4.4 has explicit std::reference_wrapper constructor */
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({std::ref(vert), std::ref(frag)}));
attachShader(vert);
attachShader(frag);
attachShaders({vert, frag});
bindAttributeLocation(0, "value");
@ -407,8 +415,8 @@ IntegerShader::IntegerShader(const std::string& type) {
/* GCC 4.4 has explicit std::reference_wrapper constructor */
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({std::ref(vert), std::ref(frag)}));
attachShader(vert);
attachShader(frag);
attachShaders({vert, frag});
bindAttributeLocation(0, "value");
@ -433,8 +441,8 @@ DoubleShader::DoubleShader(const std::string& type, const std::string& outputTyp
/* GCC 4.4 has explicit std::reference_wrapper constructor */
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({std::ref(vert), std::ref(frag)}));
attachShader(vert);
attachShader(frag);
attachShaders({vert, frag});
bindAttributeLocation(0, "value");
@ -1106,8 +1114,8 @@ MultipleShader::MultipleShader() {
/* GCC 4.4 has explicit std::reference_wrapper constructor */
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({std::ref(vert), std::ref(frag)}));
attachShader(vert);
attachShader(frag);
attachShaders({vert, frag});
bindAttributeLocation(Position::Location, "position");
bindAttributeLocation(Normal::Location, "normal");

13
src/Magnum/Test/PrimitiveQueryGLTest.cpp

@ -62,15 +62,16 @@ void PrimitiveQueryGLTest::query() {
explicit MyShader() {
Utility::Resource rs("QueryGLTest");
Shader vert(Version::GL210, Shader::Type::Vertex);
vert.addSource(rs.get("MyShader.vert"));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
attachShader(vert);
Shader vert(Version::GL210, Shader::Type::Vertex);
Shader frag(Version::GL210, Shader::Type::Fragment);
vert.addSource(rs.get("MyShader.vert"));
frag.addSource(rs.get("MyShader.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile());
attachShader(frag);
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
attachShaders({vert, frag});
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
}

11
src/Magnum/Test/RenderbufferGLTest.cpp

@ -123,7 +123,18 @@ void RenderbufferGLTest::label() {
!Context::current()->isExtensionSupported<Extensions::GL::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
{
/** @todo Is this even legal optimization? */
CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
Renderbuffer renderbuffer;
#ifndef MAGNUM_TARGET_GLES2
renderbuffer.setStorage(RenderbufferFormat::RGBA8, {128, 128});
#else
renderbuffer.setStorage(RenderbufferFormat::RGBA4, {128, 128});
#endif
CORRADE_COMPARE(renderbuffer.label(), "");
renderbuffer.setLabel("MyRenderbuffer");

18
src/Magnum/Test/SampleQueryGLTest.cpp

@ -68,23 +68,21 @@ namespace {
#ifndef DOXYGEN_GENERATING_OUTPUT
MyShader::MyShader() {
Utility::Resource rs("QueryGLTest");
#ifndef MAGNUM_TARGET_GLES
Shader vert(Version::GL210, Shader::Type::Vertex);
#else
Shader vert(Version::GLES200, Shader::Type::Vertex);
#endif
vert.addSource(rs.get("MyShader.vert"));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
attachShader(vert);
#ifndef MAGNUM_TARGET_GLES
Shader vert(Version::GL210, Shader::Type::Vertex);
Shader frag(Version::GL210, Shader::Type::Fragment);
#else
Shader vert(Version::GLES200, Shader::Type::Vertex);
Shader frag(Version::GLES200, Shader::Type::Fragment);
#endif
vert.addSource(rs.get("MyShader.vert"));
frag.addSource(rs.get("MyShader.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile());
attachShader(frag);
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
attachShaders({vert, frag});
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
}

4
src/Magnum/Test/TimeQueryGLTest.cpp

@ -60,7 +60,7 @@ void TimeQueryGLTest::queryTime() {
TimeQuery q2;
q2.begin(TimeQuery::Target::TimeElapsed);
Renderer::setFeature(Renderer::Feature::Blending, true);
Renderer::enable(Renderer::Feature::Blending);
Renderer::finish();
q2.end();
const auto result2 = q2.result<UnsignedInt>();
@ -80,7 +80,7 @@ void TimeQueryGLTest::queryTimestamp() {
q1.timestamp();
q.begin(TimeQuery::Target::TimeElapsed);
Renderer::setFeature(Renderer::Feature::Blending, true);
Renderer::enable(Renderer::Feature::Blending);
Renderer::finish();
q.end();

2
src/Magnum/Text/AbstractFont.h

@ -71,6 +71,8 @@ checked by the implementation:
@ref Feature::OpenData is supported.
- All `do*()` implementations working on opened file are called only if
there is any file opened.
Plugin interface string is `"cz.mosra.magnum.Text.AbstractFont/0.2.3"`.
*/
class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Text.AbstractFont/0.2.3")

2
src/Magnum/Text/AbstractFontConverter.h

@ -67,6 +67,8 @@ checked by the implementation:
if @ref Feature::ConvertData is supported.
- Function `doImport*FromData()` is called only if there is at least one data
array passed.
Plugin interface string is `"cz.mosra.magnum.Text.AbstractFontConverter/0.1.1"`.
*/
class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPlugin {
CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Text.AbstractFontConverter/0.1.1")

10
src/Magnum/Text/CMakeLists.txt

@ -45,7 +45,9 @@ if(MAGNUM_BUILD_DEPRECATED)
TextRenderer.h)
endif()
add_library(MagnumText ${SHARED_OR_STATIC} ${MagnumText_SRCS})
add_library(MagnumText ${SHARED_OR_STATIC}
${MagnumText_SRCS}
${MagnumText_HEADERS})
set_target_properties(MagnumText PROPERTIES DEBUG_POSTFIX "-d")
if(BUILD_STATIC_PIC)
# TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property
@ -68,11 +70,11 @@ if(WITH_FONTCONVERTER)
add_executable(magnum-fontconverter fontconverter.cpp)
if(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessCglApplication)
target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES)
target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES})
target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessGlxApplication)
elseif(CORRADE_TARGET_WINDOWS)
target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessWglApplication)
target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessWglApplication)
else()
message(FATAL_ERROR "magnum-fontconverter is not available on this platform. Set WITH_FONTCONVERTER to OFF to suppress this warning.")
endif()

4
src/Magnum/Texture.h

@ -769,6 +769,10 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> Texture<dimensions>& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
#endif
};

4
src/Magnum/TextureArray.h

@ -389,6 +389,10 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> TextureArray<dimensions>& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
#endif
};

10
src/Magnum/TextureTools/CMakeLists.txt

@ -40,7 +40,9 @@ if(BUILD_STATIC)
set(MagnumTextureTools_HEADERS ${MagnumTextureTools_HEADERS} magnumTextureToolsResourceImport.hpp)
endif()
add_library(MagnumTextureTools ${SHARED_OR_STATIC} ${MagnumTextureTools_SRCS})
add_library(MagnumTextureTools ${SHARED_OR_STATIC}
${MagnumTextureTools_SRCS}
${MagnumTextureTools_HEADERS})
set_target_properties(MagnumTextureTools PROPERTIES DEBUG_POSTFIX "-d")
if(BUILD_STATIC_PIC)
# TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property
@ -57,11 +59,11 @@ if(WITH_DISTANCEFIELDCONVERTER)
add_executable(magnum-distancefieldconverter distancefieldconverter.cpp)
if(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessCglApplication Magnum)
target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES)
target_link_libraries(magnum-distancefieldconverter MagnumTextureTools Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES})
target_link_libraries(magnum-distancefieldconverter MagnumTextureTools Magnum MagnumWindowlessGlxApplication)
elseif(CORRADE_TARGET_WINDOWS)
target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessWglApplication Magnum)
target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessWglApplication)
else()
message(FATAL_ERROR "magnum-distancefieldconverter is not available on this platform. Set WITH_DISTANCEFIELDCONVERTER to OFF to suppress this warning.")
endif()

21
src/Magnum/TextureTools/DistanceField.cpp

@ -36,6 +36,7 @@
#include "Magnum/Mesh.h"
#include "Magnum/Shader.h"
#include "Magnum/Texture.h"
#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h"
namespace Magnum { namespace TextureTools {
@ -84,18 +85,16 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1)
const Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200});
#endif
Shader vert(v, Shader::Type::Vertex);
vert.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get("FullScreenTriangle.glsl"))
Shader vert = Shaders::Implementation::createCompatibilityShader(v, Shader::Type::Vertex);
Shader frag = Shaders::Implementation::createCompatibilityShader(v, Shader::Type::Fragment);
vert.addSource(rs.get("FullScreenTriangle.glsl"))
.addSource(rs.get("DistanceFieldShader.vert"));
CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile());
attachShader(vert);
Shader frag(v, Shader::Type::Fragment);
frag.addSource(rs.get("compatibility.glsl"))
.addSource(rs.get("DistanceFieldShader.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile());
attachShader(frag);
frag.addSource(rs.get("DistanceFieldShader.frag"));
CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag}));
attachShaders({vert, frag});
/* Older GLSL doesn't have gl_VertexID, vertices must be supplied explicitly */
#ifndef MAGNUM_TARGET_GLES

5
src/Magnum/TextureTools/DistanceFieldShader.frag

@ -26,10 +26,13 @@
#ifndef NEW_GLSL
#define in varying
#define value gl_FragColor.x
#define const
#define texture texture2D
#endif
#ifndef RUNTIME_CONST
#define const
#endif
#if (defined(GL_ES) && __VERSION__ >= 300) || (!defined(GL_ES) && __VERSION__ >= 150)
#define TEXELFETCH_USABLE
#endif

2
src/Magnum/Trade/AbstractImageConverter.h

@ -55,6 +55,8 @@ checked by the implementation:
- Functions @ref doExportToImage() or @ref doExportToData() are called only
if @ref Feature::ConvertImage or @ref Feature::ConvertData is supported.
Plugin interface string is `"cz.mosra.magnum.Trade.AbstractImageConverter/0.2.1"`.
*/
class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin {
CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImageConverter/0.2.1")

5
src/Magnum/Trade/AbstractImporter.cpp

@ -26,6 +26,7 @@
#include "AbstractImporter.h"
#include <Corrade/Containers/Array.h>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Directory.h>
@ -44,7 +45,9 @@ namespace Magnum { namespace Trade {
AbstractImporter::AbstractImporter() = default;
AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, std::string plugin): AbstractPlugin(manager, std::move(plugin)) {}
AbstractImporter::AbstractImporter(PluginManager::Manager<AbstractImporter>& manager): AbstractManagingPlugin{manager} {}
AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, std::string plugin): AbstractManagingPlugin(manager, std::move(plugin)) {}
bool AbstractImporter::openData(Containers::ArrayReference<const unsigned char> data) {
CORRADE_ASSERT(features() & Feature::OpenData,

9
src/Magnum/Trade/AbstractImporter.h

@ -31,7 +31,7 @@
#include <memory>
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/PluginManager/AbstractPlugin.h>
#include <Corrade/PluginManager/AbstractManagingPlugin.h>
#include "Magnum/Magnum.h"
#include "Magnum/visibility.h"
@ -72,9 +72,11 @@ checked by the implementation:
- All `do*()` implementations taking data ID as parameter are called only if
the ID is from valid range.
Plugin interface string is `"cz.mosra.magnum.Trade.AbstractImporter/0.3"`.
@todo How to handle casting from std::unique_ptr<> in more convenient way?
*/
class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractPlugin {
class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlugin<AbstractImporter> {
CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImporter/0.3")
public:
@ -94,6 +96,9 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractPlugin {
/** @brief Default constructor */
explicit AbstractImporter();
/** @brief Constructor with access to plugin manager */
explicit AbstractImporter(PluginManager::Manager<AbstractImporter>& manager);
/** @brief Plugin manager constructor */
explicit AbstractImporter(PluginManager::AbstractManager& manager, std::string plugin);

3
src/Magnum/Trade/CMakeLists.txt

@ -41,6 +41,9 @@ set(MagnumTrade_HEADERS
TextureData.h
Trade.h)
# Force IDEs to display all header files in project view
add_custom_target(MagnumTrade SOURCES ${MagnumTrade_HEADERS})
install(FILES ${MagnumTrade_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Trade)
if(BUILD_TESTS)

2
src/MagnumExternal/OpenGL/GL/CMakeLists.txt vendored

@ -25,7 +25,7 @@
add_library(MagnumGLLoadGenObjects OBJECT gl_magnum.c)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang")
set_target_properties(MagnumGLLoadGenObjects PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fvisibility=hidden -DGLLoadGen_EXPORTS")
else()
set_target_properties(MagnumGLLoadGenObjects PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -DGLLoadGen_EXPORTS")

4
src/MagnumPlugins/TgaImporter/TgaImporter.conf

@ -1,4 +0,0 @@
author=Vladimír Vondruš <mosra@centrum.cz>
[metadata]
name=TGA image importer

4
src/MagnumPlugins/TgaImporter/TgaImporter.cpp

@ -91,9 +91,9 @@ UnsignedInt TgaImporter::doImage2DCount() const { return 1; }
std::optional<ImageData2D> TgaImporter::doImage2D(UnsignedInt) {
/* Check if the file is long enough */
in->seekg(0, std::istream::end);
std::streampos filesize = in->tellg();
std::streamoff filesize = in->tellg();
in->seekg(0, std::istream::beg);
if(filesize < std::streampos(sizeof(TgaHeader))) {
if(filesize < std::streamoff(sizeof(TgaHeader))) {
Error() << "Trade::TgaImporter::image2D(): the file is too short:" << filesize << "bytes";
return std::nullopt;
}

Loading…
Cancel
Save