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) {