From 4c7eb2f63da370b6ea894ed50d5a4bf519d4f3f2 Mon Sep 17 00:00:00 2001 From: My Name Date: Tue, 15 Sep 2020 11:41:34 +0900 Subject: [PATCH 1/2] Added a preprocessor definition to disable the use of stb_image + Added CMakeLists --- CMakeLists.txt | 19 +++++++++++++++++++ src/nanovg.c | 5 +++++ 2 files changed, 24 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7e43222 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.8) + +add_definitions(-DFONS_USE_FREETYPE) +add_definitions(-DNVG_NO_STB) + +add_library ( + nanovg + src/nanovg.c +) + +include_directories(../freetype/include) + +target_link_libraries( + nanovg + PUBLIC + freetype +) + +target_include_directories (nanovg PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) diff --git a/src/nanovg.c b/src/nanovg.c index aa86354..f42426a 100644 --- a/src/nanovg.c +++ b/src/nanovg.c @@ -24,8 +24,11 @@ #include "nanovg.h" #define FONTSTASH_IMPLEMENTATION #include "fontstash.h" + +#ifndef NVG_NO_STB #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" +#endif #ifdef _MSC_VER #pragma warning(disable: 4100) // unreferenced formal parameter @@ -788,6 +791,7 @@ void nvgFillPaint(NVGcontext* ctx, NVGpaint paint) nvgTransformMultiply(state->fill.xform, state->xform); } +#ifndef NVG_NO_STB int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags) { int w, h, n, image; @@ -816,6 +820,7 @@ int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int stbi_image_free(img); return image; } +#endif int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data) { From 0fa06d96f168d0774ea5dccdccce888c1fc98bad Mon Sep 17 00:00:00 2001 From: My Name Date: Wed, 16 Sep 2020 11:11:26 +0900 Subject: [PATCH 2/2] Removed CMakeLists.txt --- CMakeLists.txt | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 7e43222..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 3.8) - -add_definitions(-DFONS_USE_FREETYPE) -add_definitions(-DNVG_NO_STB) - -add_library ( - nanovg - src/nanovg.c -) - -include_directories(../freetype/include) - -target_link_libraries( - nanovg - PUBLIC - freetype -) - -target_include_directories (nanovg PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)