diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bae726f1..b400342aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ cmake_minimum_required(VERSION 2.8) project(Magnum) # Find Corrade first so we can check on the target +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules/") find_package(Corrade REQUIRED) include(CMakeDependentOption) @@ -66,8 +67,6 @@ if(BUILD_TESTS) enable_testing() endif() -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules/") - if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_LESS 2.8.8) set(CMAKE_NO_OBJECT_TARGET 1) message(WARNING "CMake version < 2.8.8 is used, compilation with tests enabled will take a lot more time.") diff --git a/PKGBUILD-nacl-newlib b/PKGBUILD-nacl-newlib index f43f768d2..4497ae870 100644 --- a/PKGBUILD-nacl-newlib +++ b/PKGBUILD-nacl-newlib @@ -23,7 +23,6 @@ build() { -DWITH_MAGNUMINFO=ON \ -DWITH_NACLAPPLICATION=ON \ -DWITH_WINDOWLESSNACLAPPLICATION=ON \ - -DBUILD_STATIC=ON \ -DLIB_SUFFIX=/32 make @@ -38,8 +37,7 @@ build() { -DCMAKE_INSTALL_PREFIX=/usr/nacl \ -DWITH_MAGNUMINFO=ON \ -DWITH_NACLAPPLICATION=ON \ - -DWITH_WINDOWLESSNACLAPPLICATION=ON \ - -DBUILD_STATIC=ON + -DWITH_WINDOWLESSNACLAPPLICATION=ON make } diff --git a/modules/FindCorrade.cmake b/modules/FindCorrade.cmake index 7f9d4a247..3a936bfcb 100644 --- a/modules/FindCorrade.cmake +++ b/modules/FindCorrade.cmake @@ -19,12 +19,14 @@ # hidden visibility by default. # # Features of found Corrade library are exposed in these variables: -# CORRADE_GCC46_COMPATIBILITY - Defined if compiled with compatibility -# mode for GCC 4.6 -# CORRADE_GCC45_COMPATIBILITY - Defined if compiled with compatibility -# mode for GCC 4.5 # CORRADE_GCC44_COMPATIBILITY - Defined if compiled with compatibility # mode for GCC 4.4 +# CORRADE_GCC45_COMPATIBILITY - Defined if compiled with compatibility +# mode for GCC 4.5 +# CORRADE_GCC46_COMPATIBILITY - Defined if compiled with compatibility +# mode for GCC 4.6 +# CORRADE_GCC47_COMPATIBILITY - Defined if compiled with compatibility +# mode for GCC 4.7 # CORRADE_BUILD_STATIC - Defined if compiled as static libraries # CORRADE_TARGET_NACL - Defined if compiled for Google Chrome # Native Client @@ -48,16 +50,14 @@ # # # Compile data resources into application binary. -# corrade_add_resource(name group_name -# file [ALIAS alias] -# [file1 [ALIAS alias1]...]) +# corrade_add_resource(name resources.conf) # Depends on corrade-rc, which is part of Corrade utilities. This command -# generates resource file with group group_name from given files in current -# build directory. Argument name is name under which the resources can be -# explicitly loaded. Variable `name` contains compiled resource filename, -# which is then used for compiling library / executable. Example usage: -# corrade_add_resource(name group_name file1 ALIAS alias1 file2 file3) -# add_executable(app source1 source2 ... ${name}) +# generates resource data using given configuration file in current build +# directory. Argument name is name under which the resources can be explicitly +# loaded. Variable `name` contains compiled resource filename, which is then +# used for compiling library / executable. Example usage: +# corrade_add_resource(app_resources resources.conf) +# add_executable(app source1 source2 ... ${app_resources}) # # Add dynamic plugin. # corrade_add_plugin(plugin_name install_dir metadata_file @@ -69,27 +69,12 @@ # # # Add static plugin. -# corrade_add_static_plugin(static_plugins_variable -# plugin_name metadata_file +# corrade_add_static_plugin(plugin_name install_dir metadata_file # sources...) # The macro adds preprocessor directive CORRADE_STATIC_PLUGIN. Additional -# libraries can be linked in via target_link_libraries(plugin_name ...). Plugin -# library name will be appended to static_plugins_variable and the variable is -# meant to be used for linking plugins to main executable/library, e.g: -# target_link_libraries(app lib1 lib2 ... ${static_plugins_variable}) -# This variable is set with parent scope to be available in parent directory. -# If there are more intermediate directories between plugin directory and main -# executable directory, the variable can be propagated to parent scope like -# this: -# set(static_plugins_variable ${static_plugins_variable} PARENT_SCOPE) -# -# Find and install DLLs for bundling with Windows build. -# corrade_bundle_dlls(library_install_dir -# dlls... -# [PATHS paths...]) -# It is possible to specify also additional paths for searching. DLL names can -# also contain paths, they will be installed into exact specified path. If an -# DLL is not found, fatal error message is printed. +# libraries can be linked in via target_link_libraries(plugin_name ...). If +# install_dir is set to CMAKE_CURRENT_BINARY_DIR (e.g. for testing purposes), +# no installation is performed. # # # Additionally these variables are defined for internal usage: @@ -169,6 +154,10 @@ string(FIND "${_corradeConfigure}" "#define CORRADE_GCC46_COMPATIBILITY" _GCC46_ if(NOT _GCC46_COMPATIBILITY EQUAL -1) set(CORRADE_GCC46_COMPATIBILITY 1) endif() +string(FIND "${_corradeConfigure}" "#define CORRADE_GCC47_COMPATIBILITY" _GCC47_COMPATIBILITY) +if(NOT _GCC47_COMPATIBILITY EQUAL -1) + set(CORRADE_GCC47_COMPATIBILITY 1) +endif() string(FIND "${_corradeConfigure}" "#define CORRADE_BUILD_STATIC" _BUILD_STATIC) if(NOT _BUILD_STATIC EQUAL -1) set(CORRADE_BUILD_STATIC 1) diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index 158d23513..6d4eb95d9 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -258,14 +258,14 @@ template T MatrixDeterminant::operator()(con template class MatrixDeterminant<2, T> { public: - constexpr T operator()(const Matrix<2, T>& m) { + constexpr T operator()(const Matrix<2, T>& m) const { return m[0][0]*m[1][1] - m[1][0]*m[0][1]; } }; template class MatrixDeterminant<1, T> { public: - constexpr T operator()(const Matrix<1, T>& m) { + constexpr T operator()(const Matrix<1, T>& m) const { return m[0][0]; } }; diff --git a/src/SceneGraph/instantiation.cpp b/src/SceneGraph/instantiation.cpp index ce04fb137..4c731c268 100644 --- a/src/SceneGraph/instantiation.cpp +++ b/src/SceneGraph/instantiation.cpp @@ -37,20 +37,20 @@ namespace Magnum { namespace SceneGraph { #ifndef DOXYGEN_GENERATING_OUTPUT -template class AbstractBasicObject<2, Float>; -template class AbstractBasicObject<3, Float>; -template class AbstractBasicTransformation<2, Float>; -template class AbstractBasicTransformation<3, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicObject<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicObject<3, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<3, Float>; -template class AbstractBasicFeatureGroup<2, Float>; -template class AbstractBasicFeatureGroup<3, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeatureGroup<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeatureGroup<3, Float>; template class AbstractBasicCamera<2, Float>; template class AbstractBasicCamera<3, Float>; -template class BasicCamera2D; -template class BasicCamera3D; +template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D; +template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D; template class MAGNUM_SCENEGRAPH_EXPORT Object>; template class MAGNUM_SCENEGRAPH_EXPORT Object>; diff --git a/src/Text/Test/AbstractFontConverterTest.cpp b/src/Text/Test/AbstractFontConverterTest.cpp index 5f0187117..e7d3e2f7b 100644 --- a/src/Text/Test/AbstractFontConverterTest.cpp +++ b/src/Text/Test/AbstractFontConverterTest.cpp @@ -72,7 +72,7 @@ void AbstractFontConverterTest::convertGlyphs() { Containers::Array doExportFontToSingleData(AbstractFont*, GlyphCache*, const std::u32string& characters) const override { this->characters = characters; - return {}; + return nullptr; } std::u32string& characters; diff --git a/src/Text/Test/GlyphCacheGLTest.cpp b/src/Text/Test/GlyphCacheGLTest.cpp index 63b83feab..cd2a79cba 100644 --- a/src/Text/Test/GlyphCacheGLTest.cpp +++ b/src/Text/Test/GlyphCacheGLTest.cpp @@ -46,7 +46,9 @@ void GlyphCacheGLTest::initialize() { Text::GlyphCache cache({1024, 2048}); MAGNUM_VERIFY_NO_ERROR(); + #ifndef MAGNUM_TARGET_GLES CORRADE_COMPARE(cache.texture()->imageSize(0), Vector2i(1024, 2048)); + #endif } void GlyphCacheGLTest::access() { diff --git a/src/Text/Test/TextRendererGLTest.cpp b/src/Text/Test/TextRendererGLTest.cpp index 22f32a8d4..fdfc9f5c8 100644 --- a/src/Text/Test/TextRendererGLTest.cpp +++ b/src/Text/Test/TextRendererGLTest.cpp @@ -168,6 +168,8 @@ void TextRendererGLTest::renderMesh() { std::tie(mesh, bounds) = Text::TextRenderer3D::render(&font, nullptr, 0.25f, "abc", &vertexBuffer, &indexBuffer, Buffer::Usage::StaticDraw); MAGNUM_VERIFY_NO_ERROR(); + /** @todo How to verify this on ES? */ + #ifndef MAGNUM_TARGET_GLES /* Vertex buffer contents */ Containers::Array vertices = vertexBuffer.data(); CORRADE_COMPARE(std::vector(vertices.begin(), vertices.end()), (std::vector{ @@ -193,6 +195,7 @@ void TextRendererGLTest::renderMesh() { 4, 5, 6, 5, 7, 6, 8, 9, 10, 9, 11, 10 })); + #endif /* Bounds */ CORRADE_COMPARE(bounds, Rectangle({0.0f, -0.5f}, {5.0f, 1.0f})); @@ -209,6 +212,8 @@ void TextRendererGLTest::mutableText() { renderer.reserve(4, Buffer::Usage::StaticDraw, Buffer::Usage::StaticDraw); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(renderer.capacity(), 4); + /** @todo How to verify this on ES? */ + #ifndef MAGNUM_TARGET_GLES Containers::Array indices = renderer.indexBuffer()->data(); CORRADE_COMPARE(std::vector(indices.begin(), indices.end()), (std::vector{ 0, 1, 2, 1, 3, 2, @@ -216,10 +221,13 @@ void TextRendererGLTest::mutableText() { 8, 9, 10, 9, 11, 10, 12, 13, 14, 13, 15, 14 })); + #endif /* Render text */ renderer.render("abc"); MAGNUM_VERIFY_NO_ERROR(); + /** @todo How to verify this on ES? */ + #ifndef MAGNUM_TARGET_GLES Containers::Array vertices = renderer.vertexBuffer()->subData(0, 48); CORRADE_COMPARE(std::vector(vertices.begin(), vertices.end()), (std::vector{ 0.0f, 0.5f, 0.0f, 10.0f, @@ -237,6 +245,7 @@ void TextRendererGLTest::mutableText() { 5.0f, 1.0f, 18.0f, 10.0f, 5.0f, -0.5f, 18.0f, 0.0f })); + #endif /* Updated bounds */ CORRADE_COMPARE(renderer.rectangle(), Rectangle({0.0f, -0.5f}, {5.0f, 1.0f})); diff --git a/src/Text/TextRenderer.cpp b/src/Text/TextRenderer.cpp index 19833c636..c2d7d0686 100644 --- a/src/Text/TextRenderer.cpp +++ b/src/Text/TextRenderer.cpp @@ -208,10 +208,13 @@ template std::tuple TextRendererisExtensionSupported()) { + MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::mapbuffer); + Warning() << "Text::TextRenderer:" << Extensions::GL::EXT::map_buffer_range::string() + << "is not supported, using less efficient" << Extensions::GL::OES::mapbuffer::string() + << "instead"; + } #endif /* Vertex buffer configuration depends on dimension count, done in subclass */ @@ -254,8 +257,18 @@ void AbstractTextRenderer::reserve(const uint32_t glyphCount, const Buffer::Usag _mesh.setIndexCount(0) ->setIndexBuffer(&_indexBuffer, 0, indexType, 0, vertexCount); + /* Map buffer for filling */ + void* indices; + #ifdef MAGNUM_TARGET_GLES2 + if(Context::current()->isExtensionSupported()) + #endif + CORRADE_INTERNAL_ASSERT_OUTPUT(indices = _indexBuffer.map(0, indicesSize, + Buffer::MapFlag::InvalidateBuffer|Buffer::MapFlag::Write)); + #ifdef MAGNUM_TARGET_GLES2 + else CORRADE_INTERNAL_ASSERT_OUTPUT(indices = _indexBuffer.map(Buffer::MapAccess::WriteOnly)); + #endif + /* Prefill index buffer */ - void* indices = _indexBuffer.map(0, indicesSize, Buffer::MapFlag::InvalidateBuffer|Buffer::MapFlag::Write); if(vertexCount < 255) createIndices(indices, glyphCount); else if(vertexCount < 65535) @@ -274,9 +287,20 @@ void AbstractTextRenderer::render(const std::string& text) { /* Reset rendered rectangle */ _rectangle = {}; + /* Map buffer for rendering */ + Vertex* vertices; + #ifdef MAGNUM_TARGET_GLES2 + if(Context::current()->isExtensionSupported()) + #endif + CORRADE_INTERNAL_ASSERT_OUTPUT(vertices = static_cast(_vertexBuffer.map(0, + layouter->glyphCount()*4*sizeof(Vertex), + Buffer::MapFlag::InvalidateBuffer|Buffer::MapFlag::Write))); + #ifdef MAGNUM_TARGET_GLES2 + else CORRADE_INTERNAL_ASSERT_OUTPUT(vertices = + static_cast(_vertexBuffer.map(Buffer::MapAccess::WriteOnly))); + #endif + /* Render all glyphs */ - Vertex* const vertices = static_cast(_vertexBuffer.map(0, layouter->glyphCount()*4*sizeof(Vertex), - Buffer::MapFlag::InvalidateBuffer|Buffer::MapFlag::Write)); Vector2 cursorPosition; for(UnsignedInt i = 0; i != layouter->glyphCount(); ++i) { /* Position of the texture in the resulting glyph, texture coordinates */ diff --git a/src/Text/TextRenderer.h b/src/Text/TextRenderer.h index 57ba2d6fa..289d44940 100644 --- a/src/Text/TextRenderer.h +++ b/src/Text/TextRenderer.h @@ -197,9 +197,10 @@ renderer.mesh().draw(); @section TextRenderer-extensions Required OpenGL functionality -Mutable text rendering requires @extension{ARB,map_buffer_range} (also part of -OpenGL ES 3.0 or available as @es_extension{EXT,map_buffer_range} in ES 2.0) -for asynchronous buffer updates. +Mutable text rendering requires @extension{ARB,map_buffer_range} on desktop +OpenGL (also part of OpenGL ES 3.0). If @es_extension{EXT,map_buffer_range} is +not available in ES 2.0, at least @es_extension{OES,mapbuffer} must be +supported for asynchronous buffer updates. @see TextRenderer2D, TextRenderer3D, Font, Shaders::AbstractVectorShader */