Alternative fix for unused functions warnings on stb_truetype.h (and stb_image.h)

This commit is contained in:
ubkp 2023-08-09 21:12:02 -03:00
parent 0959f6ebf6
commit 1615c42ea6
4 changed files with 53 additions and 37 deletions

View File

@ -7758,6 +7758,14 @@ STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user
return stbi__is_16_main(&s);
}
// Workaround to hide the following unused functions warnings while compiling raylib
void unused_stb_image(void)
{
(void)&stbi__addints_valid;
(void)&stbi__mul2shorts_valid;
return;
}
#endif // STB_IMAGE_IMPLEMENTATION
/*

View File

@ -4964,6 +4964,41 @@ STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const
return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2);
}
// Workaround to hide the following unused functions warnings while compiling raylib
void unused_stb_truetype(void)
{
(void)&stbtt_CompareUTF8toUTF16_bigendian;
(void)&stbtt_FindMatchingFont;
(void)&stbtt_GetNumberOfFonts;
(void)&stbtt_BakeFontBitmap;
(void)&stbtt_GetFontNameString;
(void)&stbtt_FreeSDF;
(void)&stbtt_GetPackedQuad;
(void)&stbtt_GetScaledFontVMetrics;
(void)&stbtt_PackFontRange;
(void)&stbtt_PackSetSkipMissingCodepoints;
(void)&stbtt_PackSetOversampling;
(void)&stbtt_PackEnd;
(void)&stbtt_PackBegin;
(void)&stbtt_GetBakedQuad;
(void)&stbtt_MakeCodepointBitmap;
(void)&stbtt_MakeCodepointBitmapSubpixelPrefilter;
(void)&stbtt_GetGlyphBitmap;
(void)&stbtt_FreeBitmap;
(void)&stbtt_GetCodepointBitmapBox;
(void)&stbtt_GetCodepointSVG;
(void)&stbtt_FreeShape;
(void)&stbtt_GetFontBoundingBox;
(void)&stbtt_GetFontVMetricsOS2;
(void)&stbtt_GetCodepointKernAdvance;
(void)&stbtt_GetKerningTable;
(void)&stbtt_GetKerningTableLength;
(void)&stbtt_IsGlyphEmpty;
(void)&stbtt_GetCodepointBox;
(void)&stbtt_GetCodepointShape;
return;
}
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif

View File

@ -71,21 +71,12 @@
#include <ctype.h> // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()]
#if defined(SUPPORT_FILEFORMAT_TTF)
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#define STB_RECT_PACK_IMPLEMENTATION
#include "external/stb_rect_pack.h" // Required for: ttf font rectangles packaging
#define STBTT_STATIC
#define STB_TRUETYPE_IMPLEMENTATION
#include "external/stb_truetype.h" // Required for: ttf font data reading
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic pop
#endif
#endif
//----------------------------------------------------------------------------------
@ -852,7 +843,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
RL_FREE(nodes);
RL_FREE(context);
}
#if defined(SUPPORT_FONT_ATLAS_WHITE_REC)
// Add a 3x3 white rectangle at the bottom-right corner of the generated atlas,
// useful to use as the white texture to draw shapes with raylib, using this rectangle
@ -865,7 +856,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
k -= atlas.width;
}
#endif
// Convert image data from GRAYSCALE to GRAY_ALPHA
unsigned char *dataGrayAlpha = (unsigned char *)RL_MALLOC(atlas.width*atlas.height*sizeof(unsigned char)*2); // Two channels

View File

@ -138,11 +138,6 @@
defined(SUPPORT_FILEFORMAT_PIC) || \
defined(SUPPORT_FILEFORMAT_PNM))
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#define STBI_MALLOC RL_MALLOC
#define STBI_FREE RL_FREE
#define STBI_REALLOC RL_REALLOC
@ -150,10 +145,6 @@
#define STB_IMAGE_IMPLEMENTATION
#include "external/stb_image.h" // Required for: stbi_load_from_file()
// NOTE: Used to read image data (multiple formats support)
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic pop
#endif
#endif
#if (defined(SUPPORT_FILEFORMAT_DDS) || \
@ -162,18 +153,9 @@
defined(SUPPORT_FILEFORMAT_PVR) || \
defined(SUPPORT_FILEFORMAT_ASTC))
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#define RL_GPUTEX_IMPLEMENTATION
#include "external/rl_gputex.h" // Required for: rl_load_xxx_from_memory()
// NOTE: Used to read compressed textures data (multiple formats support)
#if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic pop
#endif
#endif
#if defined(SUPPORT_FILEFORMAT_QOI)
@ -184,7 +166,7 @@
#pragma warning(push)
#pragma warning(disable : 4267)
#endif
#define QOI_IMPLEMENTATION
#include "external/qoi.h"
@ -3300,13 +3282,13 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
{
memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel);
}
// Repeat the first row data for all other rows
int bytesPerRow = bytesPerPixel * (int)rec.width;
for (int y = 1; y < (int)rec.height; y++)
{
memcpy(pSrcPixel + (y*dst->width)*bytesPerPixel, pSrcPixel, bytesPerRow);
}
// Repeat the first row data for all other rows
int bytesPerRow = bytesPerPixel * (int)rec.width;
for (int y = 1; y < (int)rec.height; y++)
{
memcpy(pSrcPixel + (y*dst->width)*bytesPerPixel, pSrcPixel, bytesPerRow);
}
}
// Draw rectangle lines within an image