From d241ee85166e720cc0d3bc777ea940e25e1f1d3c Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 29 Nov 2022 10:58:27 +0100 Subject: [PATCH] ADDED: Optional support for PNM images (.ppm, .pgm) --- CMakeOptions.txt | 1 + cmake/CompileDefinitions.cmake | 1 + src/config.h | 1 + src/rtextures.c | 11 ++++++++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeOptions.txt b/CMakeOptions.txt index d7698339..326ed44e 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -57,6 +57,7 @@ cmake_dependent_option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editin cmake_dependent_option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON CUSTOMIZE_BUILD ON) +cmake_dependent_option(SUPPORT_FILEFORMAT_PNM "Support loading PNM as textures" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" ${OFF} CUSTOMIZE_BUILD OFF) diff --git a/cmake/CompileDefinitions.cmake b/cmake/CompileDefinitions.cmake index 7193f5ff..74922245 100644 --- a/cmake/CompileDefinitions.cmake +++ b/cmake/CompileDefinitions.cmake @@ -35,6 +35,7 @@ if (${CUSTOMIZE_BUILD}) define_if("raylib" SUPPORT_FILEFORMAT_PNG) define_if("raylib" SUPPORT_FILEFORMAT_DDS) define_if("raylib" SUPPORT_FILEFORMAT_HDR) + define_if("raylib" SUPPORT_FILEFORMAT_PNM) define_if("raylib" SUPPORT_FILEFORMAT_KTX) define_if("raylib" SUPPORT_FILEFORMAT_ASTC) define_if("raylib" SUPPORT_FILEFORMAT_BMP) diff --git a/src/config.h b/src/config.h index a7ec2523..82224e3a 100644 --- a/src/config.h +++ b/src/config.h @@ -148,6 +148,7 @@ //#define SUPPORT_FILEFORMAT_PSD 1 #define SUPPORT_FILEFORMAT_DDS 1 #define SUPPORT_FILEFORMAT_HDR 1 +//#define SUPPORT_FILEFORMAT_PNM 1 //#define SUPPORT_FILEFORMAT_KTX 1 //#define SUPPORT_FILEFORMAT_ASTC 1 //#define SUPPORT_FILEFORMAT_PKM 1 diff --git a/src/rtextures.c b/src/rtextures.c index 6b8af71d..19dd5f62 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -16,6 +16,7 @@ * #define SUPPORT_FILEFORMAT_PSD * #define SUPPORT_FILEFORMAT_PIC * #define SUPPORT_FILEFORMAT_HDR +* #define SUPPORT_FILEFORMAT_PNM * #define SUPPORT_FILEFORMAT_DDS * #define SUPPORT_FILEFORMAT_PKM * #define SUPPORT_FILEFORMAT_KTX @@ -103,6 +104,9 @@ #if !defined(SUPPORT_FILEFORMAT_HDR) #define STBI_NO_HDR #endif +#if !defined(SUPPORT_FILEFORMAT_PNM) + #define STBI_NO_PNM +#endif #if defined(SUPPORT_FILEFORMAT_DDS) #define RL_GPUTEX_SUPPORT_DDS @@ -135,7 +139,8 @@ defined(SUPPORT_FILEFORMAT_PSD) || \ defined(SUPPORT_FILEFORMAT_GIF) || \ defined(SUPPORT_FILEFORMAT_PIC) || \ - defined(SUPPORT_FILEFORMAT_HDR)) + defined(SUPPORT_FILEFORMAT_HDR) || \ + defined(SUPPORT_FILEFORMAT_PNM)) #define STBI_MALLOC RL_MALLOC #define STBI_FREE RL_FREE @@ -234,6 +239,7 @@ Image LoadImage(const char *fileName) defined(SUPPORT_FILEFORMAT_GIF) || \ defined(SUPPORT_FILEFORMAT_PIC) || \ defined(SUPPORT_FILEFORMAT_HDR) || \ + defined(SUPPORT_FILEFORMAT_PNM) || \ defined(SUPPORT_FILEFORMAT_PSD) #define STBI_REQUIRED @@ -344,6 +350,9 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i #if defined(SUPPORT_FILEFORMAT_PIC) || (strcmp(fileType, ".pic") == 0) #endif +#if defined(SUPPORT_FILEFORMAT_PNM) + || ((strcmp(fileType, ".ppm") == 0) || (strcmp(fileType, ".pgm") == 0)) +#endif #if defined(SUPPORT_FILEFORMAT_PSD) || (strcmp(fileType, ".psd") == 0) #endif