memononen / nanovg

Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.
zlib License
5.06k stars 767 forks source link

Added a preprocessor definition to disable the use of stb_image #587

Closed christophe-f8 closed 3 years ago

christophe-f8 commented 3 years ago

I'm working on a large project with many libraries and applications and I use stb_image and/or nanovg in several of them. Since stb_image is linked using a preprocessor definition (STB_IMAGE_IMPLEMENTATION) linked errors occurred when using both nanovg and some of my libraries using stb_image (attempt to link twice).

I made a small fix by disabling the use of stb_image in NanoVG by using a single preprocessor definition (NVG_NO_STB), which is undefined by default (i.e. STB is used by default), so this should have no effect at all for everyone, unless you manually add that definition.

Also, I've added a CMakeLists for building purposes.

memononen commented 3 years ago

Hi! The changes to the nanovg.c looks good, but I cant accept the cmake file as I cannot maintain it. Would you mind updating the PR to remove the cmakelist.txt?

On Tue, Sep 15, 2020 at 5:52 AM christophe-f8 notifications@github.com wrote:

I'm working on a large project with many libraries and applications and I use stb_image and/or nanovg in several of them. Since stb_image is linked using a preprocessor definition (STB_IMAGE_IMPLEMENTATION) linked errors occurred when using both nanovg and some of my libraries using stb_image (attempt to link twice).

I made a small fix by disabling the use of stb_image in NanoVG by using a single preprocessor definition (NVG_NO_STB), which is undefined by default (i.e. STB is used by default), so this should have no effect at all for everyone, unless you manually add that definition.

Also, I've added a CMakeLists for building purposes.

You can view, comment on, or merge this pull request online at:

https://github.com/memononen/nanovg/pull/587 Commit Summary

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

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/memononen/nanovg/pull/587, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIBXSHD5JMZZNPUZLPMN73SF3JIJANCNFSM4RMM7FJQ .

christophe-f8 commented 3 years ago

Sure, I removed CMakeLists.txt. It's pretty easy to write anyway should one need to.

I've updated my fork and I assume that it updates the PR as well, but let me know if I need to do something else (I'm really new to committing/pushing on GitHub)

memononen commented 3 years ago

Merged, thanks for improvement!