Added IsFileExtension()
Replaced old GetExtension() function Make IsFileExtension() public to the API
This commit is contained in:
parent
2f65975c5e
commit
080a79f0b0
9 changed files with 83 additions and 77 deletions
39
src/audio.c
39
src/audio.c
|
@ -24,7 +24,6 @@
|
||||||
* Selected desired fileformats to be supported for loading. Some of those formats are
|
* Selected desired fileformats to be supported for loading. Some of those formats are
|
||||||
* supported by default, to remove support, just comment unrequired #define in this module
|
* supported by default, to remove support, just comment unrequired #define in this module
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* LIMITATIONS:
|
* LIMITATIONS:
|
||||||
* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS)
|
* Only up to two channels supported: MONO and STEREO (for additional channels, use AL_EXT_MCFORMATS)
|
||||||
* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32)
|
* Only the following sample sizes supported: 8bit PCM, 16bit PCM, 32-bit float PCM (using AL_EXT_FLOAT32)
|
||||||
|
@ -65,8 +64,6 @@
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
//#define AUDIO_STANDALONE // NOTE: To use the audio module as standalone lib, just uncomment this line
|
|
||||||
|
|
||||||
// Default configuration flags (supported features)
|
// Default configuration flags (supported features)
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
#define SUPPORT_FILEFORMAT_WAV
|
#define SUPPORT_FILEFORMAT_WAV
|
||||||
|
@ -194,8 +191,8 @@ static Wave LoadFLAC(const char *fileName); // Load FLAC file
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(AUDIO_STANDALONE)
|
#if defined(AUDIO_STANDALONE)
|
||||||
const char *GetExtension(const char *fileName); // Get the extension for a filename
|
bool IsFileExtension(const char *fileName, const char *ext); // Check file extension
|
||||||
void TraceLog(int msgType, const char *text, ...); // Outputs a trace log message (INFO, ERROR, WARNING)
|
void TraceLog(int msgType, const char *text, ...); // Outputs trace log message (INFO, ERROR, WARNING)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -285,15 +282,15 @@ Wave LoadWave(const char *fileName)
|
||||||
{
|
{
|
||||||
Wave wave = { 0 };
|
Wave wave = { 0 };
|
||||||
|
|
||||||
if (strcmp(GetExtension(fileName), "wav") == 0) wave = LoadWAV(fileName);
|
if (IsFileExtension(fileName, ".wav")) wave = LoadWAV(fileName);
|
||||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||||
else if (strcmp(GetExtension(fileName), "ogg") == 0) wave = LoadOGG(fileName);
|
else if (IsFileExtension(fileName, ".ogg")) wave = LoadOGG(fileName);
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||||
else if (strcmp(GetExtension(fileName), "flac") == 0) wave = LoadFLAC(fileName);
|
else if (IsFileExtension(fileName, ".flac")) wave = LoadFLAC(fileName);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(AUDIO_STANDALONE)
|
#if !defined(AUDIO_STANDALONE)
|
||||||
else if (strcmp(GetExtension(fileName),"rres") == 0)
|
else if (IsFileExtension(fileName, ".rres"))
|
||||||
{
|
{
|
||||||
RRES rres = LoadResource(fileName, 0);
|
RRES rres = LoadResource(fileName, 0);
|
||||||
|
|
||||||
|
@ -672,7 +669,7 @@ Music LoadMusicStream(const char *fileName)
|
||||||
{
|
{
|
||||||
Music music = (MusicData *)malloc(sizeof(MusicData));
|
Music music = (MusicData *)malloc(sizeof(MusicData));
|
||||||
|
|
||||||
if (strcmp(GetExtension(fileName), "ogg") == 0)
|
if (IsFileExtension(fileName, ".ogg"))
|
||||||
{
|
{
|
||||||
// Open ogg audio stream
|
// Open ogg audio stream
|
||||||
music->ctxOgg = stb_vorbis_open_filename(fileName, NULL, NULL);
|
music->ctxOgg = stb_vorbis_open_filename(fileName, NULL, NULL);
|
||||||
|
@ -696,7 +693,7 @@ Music LoadMusicStream(const char *fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||||
else if (strcmp(GetExtension(fileName), "flac") == 0)
|
else if (IsFileExtension(fileName, ".flac"))
|
||||||
{
|
{
|
||||||
music->ctxFlac = drflac_open_file(fileName);
|
music->ctxFlac = drflac_open_file(fileName);
|
||||||
|
|
||||||
|
@ -717,7 +714,7 @@ Music LoadMusicStream(const char *fileName)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_XM)
|
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||||
else if (strcmp(GetExtension(fileName), "xm") == 0)
|
else if (IsFileExtension(fileName, ".xm"))
|
||||||
{
|
{
|
||||||
int result = jar_xm_create_context_from_file(&music->ctxXm, 48000, fileName);
|
int result = jar_xm_create_context_from_file(&music->ctxXm, 48000, fileName);
|
||||||
|
|
||||||
|
@ -739,7 +736,7 @@ Music LoadMusicStream(const char *fileName)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||||
else if (strcmp(GetExtension(fileName), "mod") == 0)
|
else if (IsFileExtension(fileName, ".mod"))
|
||||||
{
|
{
|
||||||
jar_mod_init(&music->ctxMod);
|
jar_mod_init(&music->ctxMod);
|
||||||
|
|
||||||
|
@ -1310,12 +1307,18 @@ static Wave LoadFLAC(const char *fileName)
|
||||||
|
|
||||||
// Some required functions for audio standalone module version
|
// Some required functions for audio standalone module version
|
||||||
#if defined(AUDIO_STANDALONE)
|
#if defined(AUDIO_STANDALONE)
|
||||||
// Get the extension for a filename
|
// Check file extension
|
||||||
const char *GetExtension(const char *fileName)
|
bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
{
|
{
|
||||||
const char *dot = strrchr(fileName, '.');
|
bool result = false;
|
||||||
if (!dot || dot == fileName) return "";
|
const char *fileExt;
|
||||||
return (dot + 1);
|
|
||||||
|
if ((fileExt = strrchr(fileName, '.')) != NULL)
|
||||||
|
{
|
||||||
|
if (strcmp(fileExt, ext) == 0) result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outputs a trace log message (INFO, ERROR, WARNING)
|
// Outputs a trace log message (INFO, ERROR, WARNING)
|
||||||
|
|
|
@ -123,7 +123,7 @@ Wave LoadWave(const char *fileName); // Load wave dat
|
||||||
Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
Wave LoadWaveEx(void *data, int sampleCount, int sampleRate, int sampleSize, int channels); // Load wave data from raw array data
|
||||||
Sound LoadSound(const char *fileName); // Load sound from file
|
Sound LoadSound(const char *fileName); // Load sound from file
|
||||||
Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
|
Sound LoadSoundFromWave(Wave wave); // Load sound from wave data
|
||||||
void UpdateSound(Sound sound, const void *data, int samplesCount); // Update sound buffer with new data
|
void UpdateSound(Sound sound, const void *data, int samplesCount);// Update sound buffer with new data
|
||||||
void UnloadWave(Wave wave); // Unload wave data
|
void UnloadWave(Wave wave); // Unload wave data
|
||||||
void UnloadSound(Sound sound); // Unload sound
|
void UnloadSound(Sound sound); // Unload sound
|
||||||
void PlaySound(Sound sound); // Play a sound
|
void PlaySound(Sound sound); // Play a sound
|
||||||
|
@ -151,9 +151,10 @@ void SetMusicLoopCount(Music music, float count); // Set music loo
|
||||||
float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||||
float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||||
|
|
||||||
|
// Raw audio stream functions
|
||||||
AudioStream InitAudioStream(unsigned int sampleRate,
|
AudioStream InitAudioStream(unsigned int sampleRate,
|
||||||
unsigned int sampleSize,
|
unsigned int sampleSize,
|
||||||
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
unsigned int channels); // Init audio stream (to stream raw audio pcm data)
|
||||||
void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
void UpdateAudioStream(AudioStream stream, const void *data, int samplesCount); // Update audio stream buffers with data
|
||||||
void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
void CloseAudioStream(AudioStream stream); // Close audio stream and free memory
|
||||||
bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
|
bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill
|
||||||
|
|
22
src/core.c
22
src/core.c
|
@ -102,7 +102,7 @@
|
||||||
#include <stdint.h> // Required for: typedef unsigned long long int uint64_t, used by hi-res timer
|
#include <stdint.h> // Required for: typedef unsigned long long int uint64_t, used by hi-res timer
|
||||||
#include <time.h> // Required for: time() - Android/RPI hi-res timer (NOTE: Linux only!)
|
#include <time.h> // Required for: time() - Android/RPI hi-res timer (NOTE: Linux only!)
|
||||||
#include <math.h> // Required for: tan() [Used in Begin3dMode() to set perspective]
|
#include <math.h> // Required for: tan() [Used in Begin3dMode() to set perspective]
|
||||||
#include <string.h> // Required for: strcmp()
|
#include <string.h> // Required for: strrchr(), strcmp()
|
||||||
//#include <errno.h> // Macros for reporting and retrieving error conditions through error codes
|
//#include <errno.h> // Macros for reporting and retrieving error conditions through error codes
|
||||||
|
|
||||||
#if defined __linux__ || defined(PLATFORM_WEB)
|
#if defined __linux__ || defined(PLATFORM_WEB)
|
||||||
|
@ -978,6 +978,12 @@ Color Fade(Color color, float alpha)
|
||||||
return (Color){color.r, color.g, color.b, (unsigned char)colorAlpha};
|
return (Color){color.r, color.g, color.b, (unsigned char)colorAlpha};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activates raylib logo at startup
|
||||||
|
void ShowLogo(void)
|
||||||
|
{
|
||||||
|
showLogo = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Enable some window/system configurations
|
// Enable some window/system configurations
|
||||||
void SetConfigFlags(char flags)
|
void SetConfigFlags(char flags)
|
||||||
{
|
{
|
||||||
|
@ -987,10 +993,18 @@ void SetConfigFlags(char flags)
|
||||||
if (configFlags & FLAG_FULLSCREEN_MODE) fullscreen = true;
|
if (configFlags & FLAG_FULLSCREEN_MODE) fullscreen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activates raylib logo at startup
|
// Check file extension
|
||||||
void ShowLogo(void)
|
bool IsFileExtension(const char *fileName, const char *ext)
|
||||||
{
|
{
|
||||||
showLogo = true;
|
bool result = false;
|
||||||
|
const char *fileExt;
|
||||||
|
|
||||||
|
if ((fileExt = strrchr(fileName, '.')) != NULL)
|
||||||
|
{
|
||||||
|
if (strcmp(fileExt, ext) == 0) result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
|
|
@ -593,7 +593,7 @@ Mesh LoadMesh(const char *fileName)
|
||||||
Mesh mesh = { 0 };
|
Mesh mesh = { 0 };
|
||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_OBJ)
|
#if defined(SUPPORT_FILEFORMAT_OBJ)
|
||||||
if (strcmp(GetExtension(fileName), "obj") == 0) mesh = LoadOBJ(fileName);
|
if (IsFileExtension(fileName, ".obj")) mesh = LoadOBJ(fileName);
|
||||||
#else
|
#else
|
||||||
TraceLog(WARNING, "[%s] Mesh fileformat not supported, it can't be loaded", fileName);
|
TraceLog(WARNING, "[%s] Mesh fileformat not supported, it can't be loaded", fileName);
|
||||||
#endif
|
#endif
|
||||||
|
@ -706,7 +706,7 @@ Material LoadMaterial(const char *fileName)
|
||||||
Material material = { 0 };
|
Material material = { 0 };
|
||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_MTL)
|
#if defined(SUPPORT_FILEFORMAT_MTL)
|
||||||
if (strcmp(GetExtension(fileName), "mtl") == 0) material = LoadMTL(fileName);
|
if (IsFileExtension(fileName, ".mtl")) material = LoadMTL(fileName);
|
||||||
#else
|
#else
|
||||||
TraceLog(WARNING, "[%s] Material fileformat not supported, it can't be loaded", fileName);
|
TraceLog(WARNING, "[%s] Material fileformat not supported, it can't be loaded", fileName);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -687,9 +687,10 @@ RLAPI float *MatrixToFloat(Matrix mat); // Converts Ma
|
||||||
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
RLAPI int GetRandomValue(int min, int max); // Returns a random value between min and max (both included)
|
||||||
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f
|
||||||
|
|
||||||
RLAPI void SetConfigFlags(char flags); // Setup some window configuration flags
|
|
||||||
RLAPI void ShowLogo(void); // Activates raylib logo at startup (can be done with flags)
|
RLAPI void ShowLogo(void); // Activates raylib logo at startup (can be done with flags)
|
||||||
//RLAPI void TraceLog(int logType, const char *text, ...); // Trace log messages showing (INFO, WARNING, ERROR, DEBUG)
|
RLAPI void SetConfigFlags(char flags); // Setup some window configuration flags
|
||||||
|
//RLAPI void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG)
|
||||||
|
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension
|
||||||
|
|
||||||
RLAPI bool IsFileDropped(void); // Check if a file have been dropped into window
|
RLAPI bool IsFileDropped(void); // Check if a file have been dropped into window
|
||||||
RLAPI char **GetDroppedFiles(int *count); // Retrieve dropped files into window
|
RLAPI char **GetDroppedFiles(int *count); // Retrieve dropped files into window
|
||||||
|
|
10
src/text.c
10
src/text.c
|
@ -48,7 +48,7 @@
|
||||||
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
|
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
|
||||||
#include <stdio.h> // Required for: FILE, fopen(), fclose(), fscanf(), feof(), rewind(), fgets()
|
#include <stdio.h> // Required for: FILE, fopen(), fclose(), fscanf(), feof(), rewind(), fgets()
|
||||||
|
|
||||||
#include "utils.h" // Required for: GetExtension()
|
#include "utils.h" // Required for: IsFileExtension()
|
||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||||
// Following libs are used on LoadTTF()
|
// Following libs are used on LoadTTF()
|
||||||
|
@ -287,7 +287,7 @@ SpriteFont LoadSpriteFont(const char *fileName)
|
||||||
SpriteFont spriteFont = { 0 };
|
SpriteFont spriteFont = { 0 };
|
||||||
|
|
||||||
// Check file extension
|
// Check file extension
|
||||||
if (strcmp(GetExtension(fileName),"rres") == 0)
|
if (IsFileExtension(fileName, ".rres"))
|
||||||
{
|
{
|
||||||
// TODO: Read multiple resource blocks from file (RRES_FONT_IMAGE, RRES_FONT_CHARDATA)
|
// TODO: Read multiple resource blocks from file (RRES_FONT_IMAGE, RRES_FONT_CHARDATA)
|
||||||
RRES rres = LoadResource(fileName, 0);
|
RRES rres = LoadResource(fileName, 0);
|
||||||
|
@ -314,10 +314,10 @@ SpriteFont LoadSpriteFont(const char *fileName)
|
||||||
//UnloadResource(rres[0]);
|
//UnloadResource(rres[0]);
|
||||||
}
|
}
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||||
else if (strcmp(GetExtension(fileName),"ttf") == 0) spriteFont = LoadSpriteFontTTF(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL);
|
else if (IsFileExtension(fileName, ".ttf")) spriteFont = LoadSpriteFontTTF(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL);
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_FNT)
|
#if defined(SUPPORT_FILEFORMAT_FNT)
|
||||||
else if (strcmp(GetExtension(fileName),"fnt") == 0) spriteFont = LoadBMFont(fileName);
|
else if (IsFileExtension(fileName, ".fnt")) spriteFont = LoadBMFont(fileName);
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -344,7 +344,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount,
|
||||||
SpriteFont spriteFont = { 0 };
|
SpriteFont spriteFont = { 0 };
|
||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||||
if (strcmp(GetExtension(fileName),"ttf") == 0)
|
if (IsFileExtension(fileName, ".ttf"))
|
||||||
{
|
{
|
||||||
if ((fontChars == NULL) || (charsCount == 0))
|
if ((fontChars == NULL) || (charsCount == 0))
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,21 +163,32 @@ Image LoadImage(const char *fileName)
|
||||||
image.mipmaps = 0;
|
image.mipmaps = 0;
|
||||||
image.format = 0;
|
image.format = 0;
|
||||||
|
|
||||||
if ((strcmp(GetExtension(fileName),"png") == 0)
|
if (IsFileExtension(fileName, ".rres"))
|
||||||
|
{
|
||||||
|
RRES rres = LoadResource(fileName, 0);
|
||||||
|
|
||||||
|
// NOTE: Parameters for RRES_TYPE_IMAGE are: width, height, format, mipmaps
|
||||||
|
|
||||||
|
if (rres[0].type == RRES_TYPE_IMAGE) image = LoadImagePro(rres[0].data, rres[0].param1, rres[0].param2, rres[0].param3);
|
||||||
|
else TraceLog(WARNING, "[%s] Resource file does not contain image data", fileName);
|
||||||
|
|
||||||
|
UnloadResource(rres);
|
||||||
|
}
|
||||||
|
else if ((IsFileExtension(fileName, ".png"))
|
||||||
#if defined(SUPPORT_FILEFORMAT_BMP)
|
#if defined(SUPPORT_FILEFORMAT_BMP)
|
||||||
|| (strcmp(GetExtension(fileName),"bmp") == 0)
|
|| (IsFileExtension(fileName, ".bmp"))
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_TGA)
|
#if defined(SUPPORT_FILEFORMAT_TGA)
|
||||||
|| (strcmp(GetExtension(fileName),"tga") == 0)
|
|| (IsFileExtension(fileName, ".tga"))
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_JPG)
|
#if defined(SUPPORT_FILEFORMAT_JPG)
|
||||||
|| (strcmp(GetExtension(fileName),"jpg") == 0)
|
|| (IsFileExtension(fileName, ".jpg"))
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_DDS)
|
#if defined(SUPPORT_FILEFORMAT_DDS)
|
||||||
|| (strcmp(GetExtension(fileName),"gif") == 0)
|
|| (IsFileExtension(fileName, ".gif"))
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_PSD)
|
#if defined(SUPPORT_FILEFORMAT_PSD)
|
||||||
|| (strcmp(GetExtension(fileName),"psd") == 0)
|
|| (IsFileExtension(fileName, ".psd"))
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -198,32 +209,21 @@ Image LoadImage(const char *fileName)
|
||||||
else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8;
|
else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8;
|
||||||
}
|
}
|
||||||
#if defined(SUPPORT_FILEFORMAT_DDS)
|
#if defined(SUPPORT_FILEFORMAT_DDS)
|
||||||
else if (strcmp(GetExtension(fileName),"dds") == 0) image = LoadDDS(fileName);
|
else if (IsFileExtension(fileName, ".dds")) image = LoadDDS(fileName);
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_PKM)
|
#if defined(SUPPORT_FILEFORMAT_PKM)
|
||||||
else if (strcmp(GetExtension(fileName),"pkm") == 0) image = LoadPKM(fileName);
|
else if (IsFileExtension(fileName, ".pkm")) image = LoadPKM(fileName);
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_KTX)
|
#if defined(SUPPORT_FILEFORMAT_KTX)
|
||||||
else if (strcmp(GetExtension(fileName),"ktx") == 0) image = LoadKTX(fileName);
|
else if (IsFileExtension(fileName, ".ktx")) image = LoadKTX(fileName);
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_PVR)
|
#if defined(SUPPORT_FILEFORMAT_PVR)
|
||||||
else if (strcmp(GetExtension(fileName),"pvr") == 0) image = LoadPVR(fileName);
|
else if (IsFileExtension(fileName, ".pvr")) image = LoadPVR(fileName);
|
||||||
#endif
|
#endif
|
||||||
#if defined(SUPPORT_FILEFORMAT_ASTC)
|
#if defined(SUPPORT_FILEFORMAT_ASTC)
|
||||||
else if (strcmp(GetExtension(fileName),"astc") == 0) image = LoadASTC(fileName);
|
else if (IsFileExtension(fileName, ".astc")) image = LoadASTC(fileName);
|
||||||
#endif
|
#endif
|
||||||
else if (strcmp(GetExtension(fileName),"rres") == 0)
|
else TraceLog(WARNING, "[%s] Image fileformat not supported", fileName);
|
||||||
{
|
|
||||||
RRES rres = LoadResource(fileName, 0);
|
|
||||||
|
|
||||||
// NOTE: Parameters for RRES_TYPE_IMAGE are: width, height, format, mipmaps
|
|
||||||
|
|
||||||
if (rres[0].type == RRES_TYPE_IMAGE) image = LoadImagePro(rres[0].data, rres[0].param1, rres[0].param2, rres[0].param3);
|
|
||||||
else TraceLog(WARNING, "[%s] Resource file does not contain image data", fileName);
|
|
||||||
|
|
||||||
UnloadResource(rres);
|
|
||||||
}
|
|
||||||
else TraceLog("[%s] Image fileformat not supported", fileName);
|
|
||||||
|
|
||||||
if (image.data != NULL) TraceLog(INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height);
|
if (image.data != NULL) TraceLog(INFO, "[%s] Image loaded successfully (%ix%i)", fileName, image.width, image.height);
|
||||||
else TraceLog(WARNING, "[%s] Image could not be loaded", fileName);
|
else TraceLog(WARNING, "[%s] Image could not be loaded", fileName);
|
||||||
|
|
22
src/utils.c
22
src/utils.c
|
@ -88,14 +88,15 @@ static int android_close(void *cookie);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Definition - Utilities
|
// Module Functions Definition - Utilities
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Outputs a trace log message
|
|
||||||
|
// Output trace log messages
|
||||||
void TraceLog(int msgType, const char *text, ...)
|
void TraceLog(int msgType, const char *text, ...)
|
||||||
{
|
{
|
||||||
#if !defined(NO_TRACELOG)
|
#if defined(SUPPORT_TRACELOG)
|
||||||
static char buffer[128];
|
static char buffer[128];
|
||||||
int traceDebugMsgs = 1;
|
int traceDebugMsgs = 1;
|
||||||
|
|
||||||
#ifdef DO_NOT_TRACE_DEBUG_MSGS
|
#if defined(SUPPORT_TRACELOG_DEBUG)
|
||||||
traceDebugMsgs = 0;
|
traceDebugMsgs = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ void TraceLog(int msgType, const char *text, ...)
|
||||||
|
|
||||||
if (msgType == ERROR) exit(1); // If ERROR message, exit program
|
if (msgType == ERROR) exit(1); // If ERROR message, exit program
|
||||||
|
|
||||||
#endif // NO_TRACELOG
|
#endif // SUPPORT_TRACELOG
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
||||||
|
@ -163,19 +164,6 @@ void RecordMalloc(int mallocType, int mallocSize, const char *msg)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool IsFileExtension(const char *fileName, const char *ext)
|
|
||||||
{
|
|
||||||
return (strcmp(GetExtension(fileName), ext) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the extension for a filename
|
|
||||||
const char *GetExtension(const char *fileName)
|
|
||||||
{
|
|
||||||
const char *dot = strrchr(fileName, '.');
|
|
||||||
if (!dot || dot == fileName) return "";
|
|
||||||
return (dot + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
// Initialize asset manager from android app
|
// Initialize asset manager from android app
|
||||||
void InitAssetManager(AAssetManager *manager)
|
void InitAssetManager(AAssetManager *manager)
|
||||||
|
|
|
@ -60,8 +60,7 @@ extern "C" { // Prevents name mangling of functions
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Declaration
|
// Module Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
void TraceLog(int msgType, const char *text, ...); // Outputs a trace log message
|
void TraceLog(int msgType, const char *text, ...); // Outputs a trace log message
|
||||||
const char *GetExtension(const char *fileName); // Returns extension of a filename
|
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI)
|
||||||
#if defined(SUPPORT_SAVE_BMP)
|
#if defined(SUPPORT_SAVE_BMP)
|
||||||
|
@ -74,7 +73,7 @@ void SavePNG(const char *fileName, unsigned char *imgData, int width, int height
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
void InitAssetManager(AAssetManager *manager); // Initialize asset manager from android app
|
void InitAssetManager(AAssetManager *manager); // Initialize asset manager from android app
|
||||||
FILE *android_fopen(const char *fileName, const char *mode); // Replacement for fopen()
|
FILE *android_fopen(const char *fileName, const char *mode); // Replacement for fopen()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue