mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-10 01:09:10 -04:00
Compare commits
3 Commits
8743e11285
...
c7df641aa2
| Author | SHA1 | Date | |
|---|---|---|---|
| c7df641aa2 | |||
| 63beefd0de | |||
| b3bf537fab |
@ -1153,7 +1153,10 @@ text/text_font_filters: text/text_font_filters.c
|
||||
--preload-file text/resources/KAISG.ttf@resources/KAISG.ttf
|
||||
|
||||
text/text_font_loading: text/text_font_loading.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file text/resources/pixantiqua.fnt@resources/pixantiqua.fnt \
|
||||
--preload-file text/resources/pixantiqua.png@resources/pixantiqua.png \
|
||||
--preload-file text/resources/pixantiqua.ttf@resources/pixantiqua.ttf
|
||||
|
||||
text/text_font_sdf: text/text_font_sdf.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
|
||||
@ -38,12 +38,12 @@ int main(void)
|
||||
|
||||
// Define characters to draw
|
||||
// NOTE: raylib supports UTF-8 encoding, following list is actually codified as UTF8 internally
|
||||
const char msg[256] = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI\nJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmn\nopqrstuvwxyz{|}~¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ\nÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷\nøùúûüýþÿ";
|
||||
const char msg[256] = "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI\nJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmn\nopqrstuvwxyz{|}~¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ\nÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷\nøùúûüýþÿ";
|
||||
|
||||
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
|
||||
|
||||
// BMFont (AngelCode) : Font data and image atlas have been generated using external program
|
||||
Font fontBm = LoadFont("resources/pixantiqua.fnt");
|
||||
Font fontBm = LoadFont("resources/pixantiqua.fnt"); // Requires "resources/pixantiqua.png"
|
||||
|
||||
// TTF font : Font data and atlas are generated directly from TTF
|
||||
// NOTE: We define a font base size of 32 pixels tall and up-to 250 characters
|
||||
|
||||
@ -68,6 +68,7 @@
|
||||
#define REXM_MAX_BUFFER_SIZE (2*1024*1024) // 2MB
|
||||
|
||||
#define REXM_MAX_RESOURCE_PATHS 256
|
||||
#define REXM_MAX_RESOURCE_PATH_LENGTH 256
|
||||
|
||||
// Create local commit with changes on example renaming
|
||||
//#define RENAME_AUTO_COMMIT_CREATION
|
||||
@ -2493,25 +2494,21 @@ static void SortExampleByName(rlExampleInfo *items, int count)
|
||||
qsort(items, count, sizeof(rlExampleInfo), rlExampleInfoCompare);
|
||||
}
|
||||
|
||||
// Scan resource paths in example file
|
||||
// WARNING: Supported resource file extensions is hardcoded by used file types
|
||||
// but new examples could require other file extensions to be added,
|
||||
// maybe it should look for '.xxx")' patterns instead
|
||||
// TODO: WARNING: Some resources could require linked resources: .fnt --> .png, .mtl --> .png, .gltf --> .png, ...
|
||||
static char **LoadExampleResourcePaths(const char *filePath, int *resPathCount)
|
||||
// Scan asset paths from a source code file (raylib)
|
||||
// WARNING: Supported asset file extensions are hardcoded by used file types
|
||||
// but new examples could require other file extensions to be added
|
||||
static char **LoadExampleResourcePaths(const char *srcFilePath, int *resPathCount)
|
||||
{
|
||||
#define REXM_MAX_RESOURCE_PATH_LEN 256
|
||||
|
||||
char **paths = (char **)RL_CALLOC(REXM_MAX_RESOURCE_PATHS, sizeof(char **));
|
||||
for (int i = 0; i < REXM_MAX_RESOURCE_PATHS; i++) paths[i] = (char *)RL_CALLOC(REXM_MAX_RESOURCE_PATH_LEN, sizeof(char));
|
||||
for (int i = 0; i < REXM_MAX_RESOURCE_PATHS; i++) paths[i] = (char *)RL_CALLOC(REXM_MAX_RESOURCE_PATH_LENGTH, sizeof(char));
|
||||
|
||||
int resCounter = 0;
|
||||
char *code = LoadFileText(filePath);
|
||||
char *code = LoadFileText(srcFilePath);
|
||||
|
||||
if (code != NULL)
|
||||
{
|
||||
// Resources extensions to check
|
||||
const char *exts[] = { ".png", ".bmp", ".jpg", ".qoi", ".gif", ".raw", ".hdr", ".ttf", ".fnt", ".wav", ".ogg", ".mp3", ".flac", ".mod", ".qoa", ".obj", ".iqm", ".glb", ".m3d", ".vox", ".vs", ".fs", ".txt" };
|
||||
const char *exts[] = { ".png", ".bmp", ".jpg", ".qoi", ".gif", ".raw", ".hdr", ".ttf", ".fnt", ".wav", ".ogg", ".mp3", ".flac", ".mod", ".xm", ".qoa", ".obj", ".iqm", ".glb", ".m3d", ".vox", ".vs", ".fs", ".txt" };
|
||||
const int extCount = sizeof(exts)/sizeof(char *);
|
||||
|
||||
char *ptr = code;
|
||||
@ -2537,9 +2534,9 @@ static char **LoadExampleResourcePaths(const char *filePath, int *resPathCount)
|
||||
!((functionIndex05 != -1) && (functionIndex05 < 40))) // Not found SaveFileText() before ""
|
||||
{
|
||||
int len = (int)(end - start);
|
||||
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LEN))
|
||||
if ((len > 0) && (len < REXM_MAX_RESOURCE_PATH_LENGTH))
|
||||
{
|
||||
char buffer[REXM_MAX_RESOURCE_PATH_LEN] = { 0 };
|
||||
char buffer[REXM_MAX_RESOURCE_PATH_LENGTH] = { 0 };
|
||||
strncpy(buffer, start, len);
|
||||
buffer[len] = '\0';
|
||||
|
||||
@ -2575,6 +2572,29 @@ static char **LoadExampleResourcePaths(const char *filePath, int *resPathCount)
|
||||
UnloadFileText(code);
|
||||
}
|
||||
|
||||
/*
|
||||
// Some resources could require linked resources: .fnt --> .png, .mtl --> .png, .gltf --> .png
|
||||
// So doing a recursive pass to scan possible files with second resources
|
||||
int currentAssetCounter = resCounter;
|
||||
for (int i = 0; i < currentAssetCounter; i++)
|
||||
{
|
||||
if (IsFileExtension(paths[i], ".fnt;.gltf"))
|
||||
{
|
||||
int assetCount2 = 0;
|
||||
// ERROR: srcFilePath changes on rcursive call and TextFormat() static arrays are oveerride
|
||||
char **assetPaths2 = LoadExampleResourcePaths(TextFormat("%s/%s", GetDirectoryPath(srcFilePath), paths[i]), &assetCount2);
|
||||
|
||||
for (int j = 0; j < assetCount2; j++)
|
||||
{
|
||||
strcpy(paths[resCounter], TextFormat("%s/%s", GetDirectoryPath(paths[i]) + 2, assetPaths2[j]));
|
||||
resCounter++;
|
||||
}
|
||||
|
||||
UnloadExampleResourcePaths(assetPaths2);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
*resPathCount = resCounter;
|
||||
return paths;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user