Added a preprocessor definition to disable the use of stb_image + Added CMakeLists

master
My Name 2020-09-15 11:41:34 +09:00
parent 2bead03bea
commit 4c7eb2f63d
2 changed files with 24 additions and 0 deletions

19
CMakeLists.txt Normal file
View File

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

View File

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