From 1ae2981d571c3af6a804edd5d14603f7a202cbca Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Tue, 19 Jun 2018 10:04:35 +0300 Subject: [PATCH] stringSize + STATIC --- CMakeLists.txt | 6 +++++- include/glez/font.hpp | 3 ++- include/glez/glez.hpp | 1 + src/detail/font.cpp | 3 ++- src/font.cpp | 6 ++++++ src/glez.cpp | 6 +++++- 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5690615..ef13232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,11 @@ set(lib_dest "${export_dest}/${CMAKE_BUILD_TYPE}") find_package(PNG REQUIRED) find_package(GLEW REQUIRED) -add_library(${PROJECT_NAME} SHARED "") + +add_library(${PROJECT_NAME} STATIC "") + +target_compile_definitions(glez PRIVATE + _GLIBCXX_USE_CXX11_ABI=0) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32") diff --git a/include/glez/font.hpp b/include/glez/font.hpp index fe42906..ec0e4bc 100644 --- a/include/glez/font.hpp +++ b/include/glez/font.hpp @@ -15,7 +15,7 @@ class font { public: inline font(std::string path, float size) - : path(std::move(path)), size(size) + : path(std::move(path)), size(size), loaded(false) { } ~font(); @@ -32,6 +32,7 @@ public: void load(); void unload(); + void stringSize(const std::string &string, float *width, float *height); const std::string path; const float size; diff --git a/include/glez/glez.hpp b/include/glez/glez.hpp index 3add091..a07b7df 100644 --- a/include/glez/glez.hpp +++ b/include/glez/glez.hpp @@ -8,6 +8,7 @@ namespace glez { +void preInit(); void init(int width, int height); void shutdown(); diff --git a/src/detail/font.cpp b/src/detail/font.cpp index 3c1259d..1c0bfb0 100644 --- a/src/detail/font.cpp +++ b/src/detail/font.cpp @@ -38,7 +38,8 @@ void font::load(const std::string &path, float size) void font::unload() { - assert(init); + if (!init) + return; texture_atlas_delete(atlas); texture_font_delete(font); diff --git a/src/font.cpp b/src/font.cpp index 7567db2..6d7cd36 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -28,4 +28,10 @@ void font::unload() auto &font = detail::font::get(handle); font.unload(); } + +void font::stringSize(const std::string &string, float *width, float *height) +{ + auto &font = detail::font::get(handle); + font.stringSize(string, width, height); +} } \ No newline at end of file diff --git a/src/glez.cpp b/src/glez.cpp index cfe21ce..864e0c6 100644 --- a/src/glez.cpp +++ b/src/glez.cpp @@ -13,7 +13,6 @@ namespace glez void init(int width, int height) { - detail::font::init(); detail::program::init(width, height); detail::texture::init(); } @@ -39,4 +38,9 @@ void end() { detail::render::end(); } + +void preInit() +{ + detail::font::init(); +} } \ No newline at end of file