Skip to content

Commit

Permalink
Allow disabling STB_*_IMPLEMENTATION (#578)
Browse files Browse the repository at this point in the history
When having stb_rect_pack or stb_truetype used elsewhere in your project, Nuklear could cause conflicts. This change adds `NK_NO_STB_RECT_PACK_IMPLEMENTATION` or `NK_NO_STB_TRUETYPE_IMPLEMENTATION` to allow disabling adding `STB_RECT_PACK_IMPLEMENTATION` or `STB_TRUETYPE_IMPLEMENTATION`.
  • Loading branch information
RobLoach authored Oct 17, 2023
1 parent 7478cd7 commit bed81e2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -6103,8 +6103,23 @@ NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_prop

#ifdef NK_INCLUDE_FONT_BAKING

/**
* @def NK_NO_STB_RECT_PACK_IMPLEMENTATION
*
* When defined, will avoid enabling STB_RECT_PACK_IMPLEMENTATION for when stb_rect_pack.h is already implemented elsewhere.
*/
#ifndef NK_NO_STB_RECT_PACK_IMPLEMENTATION
#define STB_RECT_PACK_IMPLEMENTATION
#endif /* NK_NO_STB_RECT_PACK_IMPLEMENTATION */

/**
* @def NK_NO_STB_TRUETYPE_IMPLEMENTATION
*
* When defined, will avoid enabling STB_TRUETYPE_IMPLEMENTATION for when stb_truetype.h is already implemented elsewhere.
*/
#ifndef NK_NO_STB_TRUETYPE_IMPLEMENTATION
#define STB_TRUETYPE_IMPLEMENTATION
#endif /* NK_NO_STB_TRUETYPE_IMPLEMENTATION */

/* Allow consumer to define own STBTT_malloc/STBTT_free, and use the font atlas' allocator otherwise */
#ifndef STBTT_malloc
Expand Down
15 changes: 15 additions & 0 deletions src/nuklear_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,23 @@ NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_prop

#ifdef NK_INCLUDE_FONT_BAKING

/**
* @def NK_NO_STB_RECT_PACK_IMPLEMENTATION
*
* When defined, will avoid enabling STB_RECT_PACK_IMPLEMENTATION for when stb_rect_pack.h is already implemented elsewhere.
*/
#ifndef NK_NO_STB_RECT_PACK_IMPLEMENTATION
#define STB_RECT_PACK_IMPLEMENTATION
#endif /* NK_NO_STB_RECT_PACK_IMPLEMENTATION */

/**
* @def NK_NO_STB_TRUETYPE_IMPLEMENTATION
*
* When defined, will avoid enabling STB_TRUETYPE_IMPLEMENTATION for when stb_truetype.h is already implemented elsewhere.
*/
#ifndef NK_NO_STB_TRUETYPE_IMPLEMENTATION
#define STB_TRUETYPE_IMPLEMENTATION
#endif /* NK_NO_STB_TRUETYPE_IMPLEMENTATION */

/* Allow consumer to define own STBTT_malloc/STBTT_free, and use the font atlas' allocator otherwise */
#ifndef STBTT_malloc
Expand Down

0 comments on commit bed81e2

Please sign in to comment.