Support external config flags

This commit is contained in:
Ray 2019-03-12 16:00:26 +01:00
parent 76e968f6b7
commit 477ea4d660
4 changed files with 25 additions and 3 deletions

View file

@ -92,6 +92,8 @@
// Check if config flags have been externally provided on compilation line // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS) #if !defined(EXTERNAL_CONFIG_FLAGS)
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#else
#define RAYLIB_VERSION "2.5"
#endif #endif
#if (defined(__linux__) || defined(PLATFORM_WEB)) && _POSIX_C_SOURCE < 199309L #if (defined(__linux__) || defined(PLATFORM_WEB)) && _POSIX_C_SOURCE < 199309L

View file

@ -563,7 +563,10 @@ int GetPixelDataSize(int width, int height, int format);// Get pixel data size i
#define SUPPORT_VR_SIMULATOR #define SUPPORT_VR_SIMULATOR
#define SUPPORT_DISTORTION_SHADER #define SUPPORT_DISTORTION_SHADER
#else #else
#include "config.h" // rlgl module configuration // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS)
#include "config.h" // Defines module configuration flags
#endif
#endif #endif
#include <stdio.h> // Required for: fopen(), fclose(), fread()... [Used only on LoadText()] #include <stdio.h> // Required for: fopen(), fclose(), fread()... [Used only on LoadText()]

View file

@ -182,6 +182,15 @@ Image LoadImage(const char *fileName)
{ {
Image image = { 0 }; Image image = { 0 };
#if defined(SUPPORT_FILEFORMAT_PNG) || \
defined(SUPPORT_FILEFORMAT_BMP) || \
defined(SUPPORT_FILEFORMAT_TGA) || \
defined(SUPPORT_FILEFORMAT_GIF) || \
defined(SUPPORT_FILEFORMAT_PIC) || \
defined(SUPPORT_FILEFORMAT_PSD)
#define STBI_REQUIRED
#endif
#if defined(SUPPORT_FILEFORMAT_PNG) #if defined(SUPPORT_FILEFORMAT_PNG)
if ((IsFileExtension(fileName, ".png")) if ((IsFileExtension(fileName, ".png"))
#else #else
@ -207,6 +216,7 @@ Image LoadImage(const char *fileName)
#endif #endif
) )
{ {
#if defined(STBI_REQUIRED)
int imgWidth = 0; int imgWidth = 0;
int imgHeight = 0; int imgHeight = 0;
int imgBpp = 0; int imgBpp = 0;
@ -229,6 +239,7 @@ Image LoadImage(const char *fileName)
else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8; else if (imgBpp == 3) image.format = UNCOMPRESSED_R8G8B8;
else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8; else if (imgBpp == 4) image.format = UNCOMPRESSED_R8G8B8A8;
} }
#endif
} }
#if defined(SUPPORT_FILEFORMAT_HDR) #if defined(SUPPORT_FILEFORMAT_HDR)
else if (IsFileExtension(fileName, ".hdr")) else if (IsFileExtension(fileName, ".hdr"))
@ -1403,6 +1414,8 @@ void ImageResizeCanvas(Image *image, int newWidth,int newHeight, int offsetX, in
else else
{ {
// TODO: ImageCrop(), define proper cropping rectangle // TODO: ImageCrop(), define proper cropping rectangle
UnloadImage(imTemp);
} }
} }

View file

@ -30,9 +30,13 @@
* *
**********************************************************************************************/ **********************************************************************************************/
#include "config.h"
#include "raylib.h" // WARNING: Required for: LogType enum #include "raylib.h" // WARNING: Required for: LogType enum
// Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS)
#include "config.h" // Defines module configuration flags
#endif
#include "utils.h" #include "utils.h"
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)