Browse Source

Merge branch 'master' into compatibility

Conflicts:
	CMakeLists.txt
	modules/FindCorrade.cmake
Vladimír Vondruš 13 years ago
parent
commit
768f3011dd
  1. 3
      CMakeLists.txt
  2. 4
      PKGBUILD-nacl-newlib
  3. 53
      modules/FindCorrade.cmake
  4. 4
      src/Math/Matrix.h
  5. 16
      src/SceneGraph/instantiation.cpp
  6. 2
      src/Text/Test/AbstractFontConverterTest.cpp
  7. 2
      src/Text/Test/GlyphCacheGLTest.cpp
  8. 9
      src/Text/Test/TextRendererGLTest.cpp
  9. 38
      src/Text/TextRenderer.cpp
  10. 7
      src/Text/TextRenderer.h

3
CMakeLists.txt

@ -27,6 +27,7 @@ cmake_minimum_required(VERSION 2.8)
project(Magnum) project(Magnum)
# Find Corrade first so we can check on the target # 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) find_package(Corrade REQUIRED)
include(CMakeDependentOption) include(CMakeDependentOption)
@ -66,8 +67,6 @@ if(BUILD_TESTS)
enable_testing() enable_testing()
endif() 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) if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_LESS 2.8.8)
set(CMAKE_NO_OBJECT_TARGET 1) 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.") message(WARNING "CMake version < 2.8.8 is used, compilation with tests enabled will take a lot more time.")

4
PKGBUILD-nacl-newlib

@ -23,7 +23,6 @@ build() {
-DWITH_MAGNUMINFO=ON \ -DWITH_MAGNUMINFO=ON \
-DWITH_NACLAPPLICATION=ON \ -DWITH_NACLAPPLICATION=ON \
-DWITH_WINDOWLESSNACLAPPLICATION=ON \ -DWITH_WINDOWLESSNACLAPPLICATION=ON \
-DBUILD_STATIC=ON \
-DLIB_SUFFIX=/32 -DLIB_SUFFIX=/32
make make
@ -38,8 +37,7 @@ build() {
-DCMAKE_INSTALL_PREFIX=/usr/nacl \ -DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_MAGNUMINFO=ON \ -DWITH_MAGNUMINFO=ON \
-DWITH_NACLAPPLICATION=ON \ -DWITH_NACLAPPLICATION=ON \
-DWITH_WINDOWLESSNACLAPPLICATION=ON \ -DWITH_WINDOWLESSNACLAPPLICATION=ON
-DBUILD_STATIC=ON
make make
} }

53
modules/FindCorrade.cmake

@ -19,12 +19,14 @@
# hidden visibility by default. # hidden visibility by default.
# #
# Features of found Corrade library are exposed in these variables: # 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 # CORRADE_GCC44_COMPATIBILITY - Defined if compiled with compatibility
# mode for GCC 4.4 # 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_BUILD_STATIC - Defined if compiled as static libraries
# CORRADE_TARGET_NACL - Defined if compiled for Google Chrome # CORRADE_TARGET_NACL - Defined if compiled for Google Chrome
# Native Client # Native Client
@ -48,16 +50,14 @@
# #
# #
# Compile data resources into application binary. # Compile data resources into application binary.
# corrade_add_resource(name group_name # corrade_add_resource(name resources.conf)
# file [ALIAS alias]
# [file1 [ALIAS alias1]...])
# Depends on corrade-rc, which is part of Corrade utilities. This command # Depends on corrade-rc, which is part of Corrade utilities. This command
# generates resource file with group group_name from given files in current # generates resource data using given configuration file in current build
# build directory. Argument name is name under which the resources can be # directory. Argument name is name under which the resources can be explicitly
# explicitly loaded. Variable `name` contains compiled resource filename, # loaded. Variable `name` contains compiled resource filename, which is then
# which is then used for compiling library / executable. Example usage: # used for compiling library / executable. Example usage:
# corrade_add_resource(name group_name file1 ALIAS alias1 file2 file3) # corrade_add_resource(app_resources resources.conf)
# add_executable(app source1 source2 ... ${name}) # add_executable(app source1 source2 ... ${app_resources})
# #
# Add dynamic plugin. # Add dynamic plugin.
# corrade_add_plugin(plugin_name install_dir metadata_file # corrade_add_plugin(plugin_name install_dir metadata_file
@ -69,27 +69,12 @@
# #
# #
# Add static plugin. # Add static plugin.
# corrade_add_static_plugin(static_plugins_variable # corrade_add_static_plugin(plugin_name install_dir metadata_file
# plugin_name metadata_file
# sources...) # sources...)
# The macro adds preprocessor directive CORRADE_STATIC_PLUGIN. Additional # The macro adds preprocessor directive CORRADE_STATIC_PLUGIN. Additional
# libraries can be linked in via target_link_libraries(plugin_name ...). Plugin # libraries can be linked in via target_link_libraries(plugin_name ...). If
# library name will be appended to static_plugins_variable and the variable is # install_dir is set to CMAKE_CURRENT_BINARY_DIR (e.g. for testing purposes),
# meant to be used for linking plugins to main executable/library, e.g: # no installation is performed.
# 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.
# #
# #
# Additionally these variables are defined for internal usage: # 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) if(NOT _GCC46_COMPATIBILITY EQUAL -1)
set(CORRADE_GCC46_COMPATIBILITY 1) set(CORRADE_GCC46_COMPATIBILITY 1)
endif() 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) string(FIND "${_corradeConfigure}" "#define CORRADE_BUILD_STATIC" _BUILD_STATIC)
if(NOT _BUILD_STATIC EQUAL -1) if(NOT _BUILD_STATIC EQUAL -1)
set(CORRADE_BUILD_STATIC 1) set(CORRADE_BUILD_STATIC 1)

4
src/Math/Matrix.h

@ -258,14 +258,14 @@ template<std::size_t size, class T> T MatrixDeterminant<size, T>::operator()(con
template<class T> class MatrixDeterminant<2, T> { template<class T> class MatrixDeterminant<2, T> {
public: 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]; return m[0][0]*m[1][1] - m[1][0]*m[0][1];
} }
}; };
template<class T> class MatrixDeterminant<1, T> { template<class T> class MatrixDeterminant<1, T> {
public: public:
constexpr T operator()(const Matrix<1, T>& m) { constexpr T operator()(const Matrix<1, T>& m) const {
return m[0][0]; return m[0][0];
} }
}; };

16
src/SceneGraph/instantiation.cpp

@ -37,20 +37,20 @@
namespace Magnum { namespace SceneGraph { namespace Magnum { namespace SceneGraph {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template class AbstractBasicObject<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicObject<2, Float>;
template class AbstractBasicObject<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicObject<3, Float>;
template class AbstractBasicTransformation<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation<2, Float>;
template class AbstractBasicTransformation<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation<3, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<2, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<3, Float>;
template class AbstractBasicFeatureGroup<2, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeatureGroup<2, Float>;
template class AbstractBasicFeatureGroup<3, Float>; template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeatureGroup<3, Float>;
template class AbstractBasicCamera<2, Float>; template class AbstractBasicCamera<2, Float>;
template class AbstractBasicCamera<3, Float>; template class AbstractBasicCamera<3, Float>;
template class BasicCamera2D<Float>; template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D<Float>;
template class BasicCamera3D<Float>; template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D<Float>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicDualComplexTransformation<Float>>; template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicDualComplexTransformation<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicDualQuaternionTransformation<Float>>; template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicDualQuaternionTransformation<Float>>;

2
src/Text/Test/AbstractFontConverterTest.cpp

@ -72,7 +72,7 @@ void AbstractFontConverterTest::convertGlyphs() {
Containers::Array<unsigned char> doExportFontToSingleData(AbstractFont*, GlyphCache*, const std::u32string& characters) const override { Containers::Array<unsigned char> doExportFontToSingleData(AbstractFont*, GlyphCache*, const std::u32string& characters) const override {
this->characters = characters; this->characters = characters;
return {}; return nullptr;
} }
std::u32string& characters; std::u32string& characters;

2
src/Text/Test/GlyphCacheGLTest.cpp

@ -46,7 +46,9 @@ void GlyphCacheGLTest::initialize() {
Text::GlyphCache cache({1024, 2048}); Text::GlyphCache cache({1024, 2048});
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(cache.texture()->imageSize(0), Vector2i(1024, 2048)); CORRADE_COMPARE(cache.texture()->imageSize(0), Vector2i(1024, 2048));
#endif
} }
void GlyphCacheGLTest::access() { void GlyphCacheGLTest::access() {

9
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); std::tie(mesh, bounds) = Text::TextRenderer3D::render(&font, nullptr, 0.25f, "abc", &vertexBuffer, &indexBuffer, Buffer::Usage::StaticDraw);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
/** @todo How to verify this on ES? */
#ifndef MAGNUM_TARGET_GLES
/* Vertex buffer contents */ /* Vertex buffer contents */
Containers::Array<Float> vertices = vertexBuffer.data<Float>(); Containers::Array<Float> vertices = vertexBuffer.data<Float>();
CORRADE_COMPARE(std::vector<Float>(vertices.begin(), vertices.end()), (std::vector<Float>{ CORRADE_COMPARE(std::vector<Float>(vertices.begin(), vertices.end()), (std::vector<Float>{
@ -193,6 +195,7 @@ void TextRendererGLTest::renderMesh() {
4, 5, 6, 5, 7, 6, 4, 5, 6, 5, 7, 6,
8, 9, 10, 9, 11, 10 8, 9, 10, 9, 11, 10
})); }));
#endif
/* Bounds */ /* Bounds */
CORRADE_COMPARE(bounds, Rectangle({0.0f, -0.5f}, {5.0f, 1.0f})); 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); renderer.reserve(4, Buffer::Usage::StaticDraw, Buffer::Usage::StaticDraw);
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
CORRADE_COMPARE(renderer.capacity(), 4); CORRADE_COMPARE(renderer.capacity(), 4);
/** @todo How to verify this on ES? */
#ifndef MAGNUM_TARGET_GLES
Containers::Array<UnsignedByte> indices = renderer.indexBuffer()->data<UnsignedByte>(); Containers::Array<UnsignedByte> indices = renderer.indexBuffer()->data<UnsignedByte>();
CORRADE_COMPARE(std::vector<UnsignedByte>(indices.begin(), indices.end()), (std::vector<UnsignedByte>{ CORRADE_COMPARE(std::vector<UnsignedByte>(indices.begin(), indices.end()), (std::vector<UnsignedByte>{
0, 1, 2, 1, 3, 2, 0, 1, 2, 1, 3, 2,
@ -216,10 +221,13 @@ void TextRendererGLTest::mutableText() {
8, 9, 10, 9, 11, 10, 8, 9, 10, 9, 11, 10,
12, 13, 14, 13, 15, 14 12, 13, 14, 13, 15, 14
})); }));
#endif
/* Render text */ /* Render text */
renderer.render("abc"); renderer.render("abc");
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
/** @todo How to verify this on ES? */
#ifndef MAGNUM_TARGET_GLES
Containers::Array<Float> vertices = renderer.vertexBuffer()->subData<Float>(0, 48); Containers::Array<Float> vertices = renderer.vertexBuffer()->subData<Float>(0, 48);
CORRADE_COMPARE(std::vector<Float>(vertices.begin(), vertices.end()), (std::vector<Float>{ CORRADE_COMPARE(std::vector<Float>(vertices.begin(), vertices.end()), (std::vector<Float>{
0.0f, 0.5f, 0.0f, 10.0f, 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, 1.0f, 18.0f, 10.0f,
5.0f, -0.5f, 18.0f, 0.0f 5.0f, -0.5f, 18.0f, 0.0f
})); }));
#endif
/* Updated bounds */ /* Updated bounds */
CORRADE_COMPARE(renderer.rectangle(), Rectangle({0.0f, -0.5f}, {5.0f, 1.0f})); CORRADE_COMPARE(renderer.rectangle(), Rectangle({0.0f, -0.5f}, {5.0f, 1.0f}));

38
src/Text/TextRenderer.cpp

@ -208,10 +208,13 @@ template<UnsignedInt dimensions> std::tuple<Mesh, Rectangle> TextRenderer<dimens
AbstractTextRenderer::AbstractTextRenderer(AbstractFont* const font, const GlyphCache* const cache, Float size): _vertexBuffer(Buffer::Target::Array), _indexBuffer(Buffer::Target::ElementArray), font(font), cache(cache), size(size), _capacity(0) { AbstractTextRenderer::AbstractTextRenderer(AbstractFont* const font, const GlyphCache* const cache, Float size): _vertexBuffer(Buffer::Target::Array), _indexBuffer(Buffer::Target::ElementArray), font(font), cache(cache), size(size), _capacity(0) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::map_buffer_range); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::map_buffer_range);
#else #elif defined(MAGNUM_TARGET_GLES2)
#ifdef MAGNUM_TARGET_GLES2 if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::map_buffer_range>()) {
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::EXT::map_buffer_range); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::mapbuffer);
#endif Warning() << "Text::TextRenderer:" << Extensions::GL::EXT::map_buffer_range::string()
<< "is not supported, using less efficient" << Extensions::GL::OES::mapbuffer::string()
<< "instead";
}
#endif #endif
/* Vertex buffer configuration depends on dimension count, done in subclass */ /* 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) _mesh.setIndexCount(0)
->setIndexBuffer(&_indexBuffer, 0, indexType, 0, vertexCount); ->setIndexBuffer(&_indexBuffer, 0, indexType, 0, vertexCount);
/* Map buffer for filling */
void* indices;
#ifdef MAGNUM_TARGET_GLES2
if(Context::current()->isExtensionSupported<Extensions::GL::EXT::map_buffer_range>())
#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 */ /* Prefill index buffer */
void* indices = _indexBuffer.map(0, indicesSize, Buffer::MapFlag::InvalidateBuffer|Buffer::MapFlag::Write);
if(vertexCount < 255) if(vertexCount < 255)
createIndices<UnsignedByte>(indices, glyphCount); createIndices<UnsignedByte>(indices, glyphCount);
else if(vertexCount < 65535) else if(vertexCount < 65535)
@ -274,9 +287,20 @@ void AbstractTextRenderer::render(const std::string& text) {
/* Reset rendered rectangle */ /* Reset rendered rectangle */
_rectangle = {}; _rectangle = {};
/* Map buffer for rendering */
Vertex* vertices;
#ifdef MAGNUM_TARGET_GLES2
if(Context::current()->isExtensionSupported<Extensions::GL::EXT::map_buffer_range>())
#endif
CORRADE_INTERNAL_ASSERT_OUTPUT(vertices = static_cast<Vertex*>(_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<Vertex*>(_vertexBuffer.map(Buffer::MapAccess::WriteOnly)));
#endif
/* Render all glyphs */ /* Render all glyphs */
Vertex* const vertices = static_cast<Vertex*>(_vertexBuffer.map(0, layouter->glyphCount()*4*sizeof(Vertex),
Buffer::MapFlag::InvalidateBuffer|Buffer::MapFlag::Write));
Vector2 cursorPosition; Vector2 cursorPosition;
for(UnsignedInt i = 0; i != layouter->glyphCount(); ++i) { for(UnsignedInt i = 0; i != layouter->glyphCount(); ++i) {
/* Position of the texture in the resulting glyph, texture coordinates */ /* Position of the texture in the resulting glyph, texture coordinates */

7
src/Text/TextRenderer.h

@ -197,9 +197,10 @@ renderer.mesh().draw();
@section TextRenderer-extensions Required OpenGL functionality @section TextRenderer-extensions Required OpenGL functionality
Mutable text rendering requires @extension{ARB,map_buffer_range} (also part of Mutable text rendering requires @extension{ARB,map_buffer_range} on desktop
OpenGL ES 3.0 or available as @es_extension{EXT,map_buffer_range} in ES 2.0) OpenGL (also part of OpenGL ES 3.0). If @es_extension{EXT,map_buffer_range} is
for asynchronous buffer updates. 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 @see TextRenderer2D, TextRenderer3D, Font, Shaders::AbstractVectorShader
*/ */

Loading…
Cancel
Save