From f25c35648c9a1fb7a4c9a7afe9b432134a9cbd9a Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Fri, 29 Nov 2024 12:07:43 -0800 Subject: [PATCH 1/2] Make all the defines in config.h be override-able by the build system --- examples/shapes/shapes_rectangle_advanced.c | 2 +- src/config.h | 400 +++++++++++++++++--- src/platforms/rcore_android.c | 10 +- src/platforms/rcore_desktop_glfw.c | 12 +- src/platforms/rcore_desktop_rgfw.c | 8 +- src/platforms/rcore_desktop_sdl.c | 8 +- src/platforms/rcore_drm.c | 14 +- src/platforms/rcore_template.c | 2 +- src/platforms/rcore_web.c | 8 +- src/raudio.c | 112 +++--- src/rcore.c | 116 +++--- src/rmodels.c | 60 +-- src/rshapes.c | 22 +- src/rtext.c | 44 +-- src/rtextures.c | 148 ++++---- src/utils.c | 10 +- src/utils.h | 4 +- 17 files changed, 638 insertions(+), 342 deletions(-) diff --git a/examples/shapes/shapes_rectangle_advanced.c b/examples/shapes/shapes_rectangle_advanced.c index e885a10ee05a..c0003fb46bea 100644 --- a/examples/shapes/shapes_rectangle_advanced.c +++ b/examples/shapes/shapes_rectangle_advanced.c @@ -61,7 +61,7 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou const Vector2 centers[4] = { point[8], point[9], point[10], point[11] }; const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f }; -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); diff --git a/src/config.h b/src/config.h index d8f7112eb0f9..4cc3b7206ad7 100644 --- a/src/config.h +++ b/src/config.h @@ -32,52 +32,107 @@ // Module selection - Some modules could be avoided // Mandatory modules: rcore, rlgl, utils //------------------------------------------------------------------------------------ +#ifndef SUPPORT_MODULE_RSHAPES #define SUPPORT_MODULE_RSHAPES 1 +#endif + +#ifndef SUPPORT_MODULE_RTEXTURES #define SUPPORT_MODULE_RTEXTURES 1 +#endif + +#ifndef SUPPORT_MODULE_RTEXT #define SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures +#endif + +#ifndef SUPPORT_MODULE_RMODELS #define SUPPORT_MODULE_RMODELS 1 +#endif + +#ifndef SUPPORT_MODULE_RAUDIO #define SUPPORT_MODULE_RAUDIO 1 +#endif //------------------------------------------------------------------------------------ // Module: rcore - Configuration Flags //------------------------------------------------------------------------------------ // Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital +#ifndef SUPPORT_CAMERA_SYSTEM #define SUPPORT_CAMERA_SYSTEM 1 +#endif + // Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag +#ifndef SUPPORT_GESTURES_SYSTEM #define SUPPORT_GESTURES_SYSTEM 1 +#endif + // Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64 +#ifndef SUPPORT_RPRAND_GENERATOR #define SUPPORT_RPRAND_GENERATOR 1 +#endif + // Mouse gestures are directly mapped like touches and processed by gestures system +#ifndef SUPPORT_MOUSE_GESTURES #define SUPPORT_MOUSE_GESTURES 1 +#endif + // Reconfigure standard input to receive key inputs, works with SSH connection. +#ifndef SUPPORT_SSH_KEYBOARD_RPI #define SUPPORT_SSH_KEYBOARD_RPI 1 +#endif + // Setting a higher resolution can improve the accuracy of time-out intervals in wait functions. // However, it can also reduce overall system performance, because the thread scheduler switches tasks more often. +#ifndef SUPPORT_WINMM_HIGHRES_TIMER #define SUPPORT_WINMM_HIGHRES_TIMER 1 -// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used -//#define SUPPORT_BUSY_WAIT_LOOP 1 +#endif + +// Use busy wait loop for timing sync, if 0, a high-resolution timer is set up and used (Default off) +#ifndef SUPPORT_BUSY_WAIT_LOOP +#define SUPPORT_BUSY_WAIT_LOOP 0 +#endif + // Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy +#ifndef SUPPORT_PARTIALBUSY_WAIT_LOOP #define SUPPORT_PARTIALBUSY_WAIT_LOOP 1 +#endif + // Allow automatic screen capture of current screen pressing F12, defined in KeyCallback() +#ifndef SUPPORT_SCREEN_CAPTURE #define SUPPORT_SCREEN_CAPTURE 1 +#endif + // Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback() +#ifndef SUPPORT_GIF_RECORDING #define SUPPORT_GIF_RECORDING 1 +#endif + // Support CompressData() and DecompressData() functions +#ifndef SUPPORT_COMPRESSION_API #define SUPPORT_COMPRESSION_API 1 +#endif + // Support automatic generated events, loading and recording of those events when required +#ifndef SUPPORT_AUTOMATION_EVENTS #define SUPPORT_AUTOMATION_EVENTS 1 -// Support custom frame control, only for advanced users +#endif + +// Support custom frame control, only for advanced users (Default off) // By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents() // Enabling this flag allows manual control of the frame processes, use at your own risk -//#define SUPPORT_CUSTOM_FRAME_CONTROL 1 +#ifndef SUPPORT_CUSTOM_FRAME_CONTROL +#define SUPPORT_CUSTOM_FRAME_CONTROL 0 +#endif // Support for clipboard image loading // NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows) +#ifndef SUPPORT_CLIPBOARD_IMAGE #define SUPPORT_CLIPBOARD_IMAGE 1 +#endif // NOTE: Clipboard image loading requires support for some image file formats // TODO: Those defines should probably be removed from here, I prefer to let the user manage them -#if defined(SUPPORT_CLIPBOARD_IMAGE) + +#if SUPPORT_CLIPBOARD_IMAGE #ifndef SUPPORT_MODULE_RTEXTURES #define SUPPORT_MODULE_RTEXTURES 1 #endif @@ -95,25 +150,59 @@ #endif #endif - // rcore: Configuration values //------------------------------------------------------------------------------------ +#ifndef MAX_FILEPATH_CAPACITY #define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity +#endif + +#ifndef MAX_FILEPATH_LENGTH #define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value) +#endif +#ifndef MAX_KEYBOARD_KEYS #define MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported +#endif + +#ifndef MAX_MOUSE_BUTTONS #define MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported +#endif + +#ifndef MAX_GAMEPADS #define MAX_GAMEPADS 4 // Maximum number of gamepads supported +#endif + +#ifndef MAX_GAMEPAD_AXIS #define MAX_GAMEPAD_AXIS 8 // Maximum number of axis supported (per gamepad) +#endif + +#ifndef MAX_GAMEPAD_BUTTONS #define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad) +#endif + +#ifndef MAX_GAMEPAD_VIBRATION_TIME #define MAX_GAMEPAD_VIBRATION_TIME 2.0f // Maximum vibration time in seconds +#endif + +#ifndef MAX_TOUCH_POINTS #define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported +#endif + +#ifndef MAX_KEY_PRESSED_QUEUE #define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue +#endif + +#ifndef MAX_CHAR_PRESSED_QUEUE #define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue +#endif +#ifndef MAX_DECOMPRESSION_SIZE #define MAX_DECOMPRESSION_SIZE 64 // Max size allocated for decompression in MB +#endif +#ifndef MAX_AUTOMATION_EVENTS #define MAX_AUTOMATION_EVENTS 16384 // Maximum number of automation events to record +#endif //------------------------------------------------------------------------------------ // Module: rlgl - Configuration values @@ -125,31 +214,75 @@ // Show OpenGL extensions and capabilities detailed logs on init //#define RLGL_SHOW_GL_DETAILS_INFO 1 +#ifndef RL_SUPPORT_MESH_GPU_SKINNING #define RL_SUPPORT_MESH_GPU_SKINNING 1 // GPU skinning, comment if your GPU does not support more than 8 VBOs +#endif -//#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits +#ifndef RL_DEFAULT_BATCH_BUFFERS #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) +#endif + +#ifndef RL_DEFAULT_BATCH_DRAWCALLS #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) +#endif + +#ifndef RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture()) +#endif +#ifndef RL_MAX_MATRIX_STACK_SIZE #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack +#endif +#ifndef RL_MAX_SHADER_LOCATIONS #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported +#endif +#ifndef RL_CULL_DISTANCE_NEAR #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance +#endif + +#ifndef RL_CULL_DISTANCE_FAR #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance +#endif // Default shader vertex attribute locations +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0 +#endif + +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1 +#endif + +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2 +#endif + +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR 3 +#endif + +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT 4 +#endif + +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5 +#endif + +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6 -#if defined(RL_SUPPORT_MESH_GPU_SKINNING) - #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7 - #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8 +#endif + +#if RL_SUPPORT_MESH_GPU_SKINNING +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS +#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7 +#endif + +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS +#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8 +#endif #endif // Default shader vertex attribute names to set location points @@ -161,140 +294,303 @@ #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 +#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MVP #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix +#endif + +#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix +#endif + +#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix +#endif + +#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix +#endif + +#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)) +#endif + +#ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) +#endif + +#ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) +#endif + +#ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) -#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) +#endif +#ifndef RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 +#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) +#endif //------------------------------------------------------------------------------------ // Module: rshapes - Configuration Flags //------------------------------------------------------------------------------------ // Use QUADS instead of TRIANGLES for drawing when possible // Some lines-based shapes could still use lines +#ifndef SUPPORT_QUADS_DRAW_MODE #define SUPPORT_QUADS_DRAW_MODE 1 +#endif // rshapes: Configuration values //------------------------------------------------------------------------------------ +#ifndef SPLINE_SEGMENT_DIVISIONS #define SPLINE_SEGMENT_DIVISIONS 24 // Spline segments subdivisions - +#endif //------------------------------------------------------------------------------------ // Module: rtextures - Configuration Flags //------------------------------------------------------------------------------------ -// Selecte desired fileformats to be supported for image data loading +// Select desired fileformats to be supported for image data loading +#ifndef SUPPORT_FILEFORMAT_PNG #define SUPPORT_FILEFORMAT_PNG 1 -//#define SUPPORT_FILEFORMAT_BMP 1 -//#define SUPPORT_FILEFORMAT_TGA 1 -//#define SUPPORT_FILEFORMAT_JPG 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_BMP +#define SUPPORT_FILEFORMAT_BMP 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_TGA +#define SUPPORT_FILEFORMAT_TGA 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_JPG +#define SUPPORT_FILEFORMAT_JPG 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_GIF #define SUPPORT_FILEFORMAT_GIF 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_QOI #define SUPPORT_FILEFORMAT_QOI 1 -//#define SUPPORT_FILEFORMAT_PSD 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_PSD +#define SUPPORT_FILEFORMAT_PSD 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_DDS #define SUPPORT_FILEFORMAT_DDS 1 -//#define SUPPORT_FILEFORMAT_HDR 1 -//#define SUPPORT_FILEFORMAT_PIC 1 -//#define SUPPORT_FILEFORMAT_KTX 1 -//#define SUPPORT_FILEFORMAT_ASTC 1 -//#define SUPPORT_FILEFORMAT_PKM 1 -//#define SUPPORT_FILEFORMAT_PVR 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_HDR +#define SUPPORT_FILEFORMAT_HDR 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_PIC +#define SUPPORT_FILEFORMAT_PIC 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_KTX +#define SUPPORT_FILEFORMAT_KTX 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_ASTC +#define SUPPORT_FILEFORMAT_ASTC 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_PNM +#define SUPPORT_FILEFORMAT_PNM 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_PVR +#define SUPPORT_FILEFORMAT_PVR 0 +#endif // Support image export functionality (.png, .bmp, .tga, .jpg, .qoi) +#ifndef SUPPORT_IMAGE_EXPORT #define SUPPORT_IMAGE_EXPORT 1 +#endif + // Support procedural image generation functionality (gradient, spot, perlin-noise, cellular) +#ifndef SUPPORT_IMAGE_GENERATION #define SUPPORT_IMAGE_GENERATION 1 +#endif + // Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... // If not defined, still some functions are supported: ImageFormat(), ImageCrop(), ImageToPOT() +#ifndef SUPPORT_IMAGE_MANIPULATION #define SUPPORT_IMAGE_MANIPULATION 1 - +#endif //------------------------------------------------------------------------------------ // Module: rtext - Configuration Flags //------------------------------------------------------------------------------------ // Default font is loaded on window initialization to be available for the user to render simple text // NOTE: If enabled, uses external module functions to load default raylib font +#ifndef SUPPORT_DEFAULT_FONT #define SUPPORT_DEFAULT_FONT 1 +#endif + // Selected desired font fileformats to be supported for loading +#ifndef SUPPORT_FILEFORMAT_TTF #define SUPPORT_FILEFORMAT_TTF 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_FNT #define SUPPORT_FILEFORMAT_FNT 1 -//#define SUPPORT_FILEFORMAT_BDF 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_BDF +#define SUPPORT_FILEFORMAT_BDF 0 +#endif // Support text management functions // If not defined, still some functions are supported: TextLength(), TextFormat() +#ifndef SUPPORT_TEXT_MANIPULATION #define SUPPORT_TEXT_MANIPULATION 1 +#endif // On font atlas image generation [GenImageFontAtlas()], add a 3x3 pixels white rectangle // at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow // drawing text and shapes with a single draw call [SetShapesTexture()]. +#ifndef SUPPORT_FONT_ATLAS_WHITE_REC #define SUPPORT_FONT_ATLAS_WHITE_REC 1 +#endif // rtext: Configuration values //------------------------------------------------------------------------------------ -#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions: - // TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit() -#define MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit() +// Size of internal static buffers used on some functions: +// TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit() +#ifndef MAX_TEXT_BUFFER_LENGTH +#define MAX_TEXT_BUFFER_LENGTH 1024 +#endif +// Maximum number of substrings to split: TextSplit() +#ifndef MAX_TEXTSPLIT_COUNT +#define MAX_TEXTSPLIT_COUNT 128 +#endif //------------------------------------------------------------------------------------ // Module: rmodels - Configuration Flags //------------------------------------------------------------------------------------ // Selected desired model fileformats to be supported for loading -#define SUPPORT_FILEFORMAT_OBJ 1 -#define SUPPORT_FILEFORMAT_MTL 1 -#define SUPPORT_FILEFORMAT_IQM 1 -#define SUPPORT_FILEFORMAT_GLTF 1 -#define SUPPORT_FILEFORMAT_VOX 1 -#define SUPPORT_FILEFORMAT_M3D 1 +#ifndef SUPPORT_FILEFORMAT_OBJ +#define SUPPORT_FILEFORMAT_OBJ 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_MTL +#define SUPPORT_FILEFORMAT_MTL 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_IQM +#define SUPPORT_FILEFORMAT_IQM 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_GLTF +#define SUPPORT_FILEFORMAT_GLTF 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_VOX +#define SUPPORT_FILEFORMAT_VOX 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_M3D +#define SUPPORT_FILEFORMAT_M3D 1 +#endif + // Support procedural mesh generation functions, uses external par_shapes.h library // NOTE: Some generated meshes DO NOT include generated texture coordinates -#define SUPPORT_MESH_GENERATION 1 +#ifndef SUPPORT_MESH_GENERATION +#define SUPPORT_MESH_GENERATION 1 +#endif // rmodels: Configuration values //------------------------------------------------------------------------------------ -#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported +#ifndef MAX_MATERIAL_MAPS +#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported +#endif -#ifdef RL_SUPPORT_MESH_GPU_SKINNING +#ifndef MAX_MESH_VERTEX_BUFFERS +#if RL_SUPPORT_MESH_GPU_SKINNING #define MAX_MESH_VERTEX_BUFFERS 9 // Maximum vertex buffers (VBO) per mesh #else #define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh #endif +#endif //------------------------------------------------------------------------------------ // Module: raudio - Configuration Flags //------------------------------------------------------------------------------------ // Desired audio fileformats to be supported for loading -#define SUPPORT_FILEFORMAT_WAV 1 -#define SUPPORT_FILEFORMAT_OGG 1 -#define SUPPORT_FILEFORMAT_MP3 1 -#define SUPPORT_FILEFORMAT_QOA 1 -//#define SUPPORT_FILEFORMAT_FLAC 1 -#define SUPPORT_FILEFORMAT_XM 1 -#define SUPPORT_FILEFORMAT_MOD 1 +#ifndef SUPPORT_FILEFORMAT_WAV +#define SUPPORT_FILEFORMAT_WAV 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_OGG +#define SUPPORT_FILEFORMAT_OGG 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_MP3 +#define SUPPORT_FILEFORMAT_MP3 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_QOA +#define SUPPORT_FILEFORMAT_QOA 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_FLAC +#define SUPPORT_FILEFORMAT_FLAC 0 +#endif + +#ifndef SUPPORT_FILEFORMAT_XM +#define SUPPORT_FILEFORMAT_XM 1 +#endif + +#ifndef SUPPORT_FILEFORMAT_MOD +#define SUPPORT_FILEFORMAT_MOD 1 +#endif // raudio: Configuration values //------------------------------------------------------------------------------------ -#define AUDIO_DEVICE_FORMAT ma_format_f32 // Device output format (miniaudio: float-32bit) -#define AUDIO_DEVICE_CHANNELS 2 // Device output channels: stereo -#define AUDIO_DEVICE_SAMPLE_RATE 0 // Device sample rate (device default) +#ifndef AUDIO_DEVICE_FORMAT +#define AUDIO_DEVICE_FORMAT ma_format_f32 // Device output format (miniaudio: float-32bit) +#endif -#define MAX_AUDIO_BUFFER_POOL_CHANNELS 16 // Maximum number of audio pool channels +#ifndef AUDIO_DEVICE_CHANNELS +#define AUDIO_DEVICE_CHANNELS 2 // Device output channels: stereo +#endif + +#ifndef AUDIO_DEVICE_SAMPLE_RATE +#define AUDIO_DEVICE_SAMPLE_RATE 0 // Device sample rate (device default) +#endif + +#ifndef MAX_AUDIO_BUFFER_POOL_CHANNELS +#define MAX_AUDIO_BUFFER_POOL_CHANNELS 16 // Maximum number of audio pool channels +#endif //------------------------------------------------------------------------------------ // Module: utils - Configuration Flags //------------------------------------------------------------------------------------ // Standard file io library (stdio.h) included -#define SUPPORT_STANDARD_FILEIO 1 +#ifndef SUPPORT_STANDARD_FILEIO +#define SUPPORT_STANDARD_FILEIO 1 +#endif + // Show TRACELOG() output messages // NOTE: By default LOG_DEBUG traces not shown -#define SUPPORT_TRACELOG 1 -//#define SUPPORT_TRACELOG_DEBUG 1 +#ifndef SUPPORT_TRACELOG +#define SUPPORT_TRACELOG 1 +#endif + +#ifndef SUPPORT_TRACELOG_DEBUG +#define SUPPORT_TRACELOG_DEBUG 0 +#endif + // utils: Configuration values //------------------------------------------------------------------------------------ -#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message +#ifndef MAX_TRACELOG_MSG_LENGTH +#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message +#endif + #endif // CONFIG_H diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 47dc5cabc9ef..041805dff012 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -653,7 +653,7 @@ const char *GetKeyName(int key) // Register all input events void PollInputEvents(void) { -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM // NOTE: Gestures update must be called every frame to reset gestures correctly // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); @@ -1007,11 +1007,11 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd) // Initialize hi-res timer InitTimer(); - #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) + #if SUPPORT_MODULE_RTEXT && SUPPORT_DEFAULT_FONT // Load default font // WARNING: External function: Module required: rtext LoadFontDefault(); - #if defined(SUPPORT_MODULE_RSHAPES) + #if SUPPORT_MODULE_RSHAPES // Set font white rectangle for shapes drawing, so shapes and text can be batched together // WARNING: rshapes module is required, if not available, default internal white rectangle is used Rectangle rec = GetFontDefault().recs[95]; @@ -1027,7 +1027,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd) } #endif #else - #if defined(SUPPORT_MODULE_RSHAPES) + #if SUPPORT_MODULE_RSHAPES // Set default texture and rectangle to be used for shapes drawing // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8 Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; @@ -1286,7 +1286,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) int32_t action = AMotionEvent_getAction(event); unsigned int flags = action & AMOTION_EVENT_ACTION_MASK; -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM GestureEvent gestureEvent = { 0 }; gestureEvent.pointCount = CORE.Input.Touch.pointCount; diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 5caf17ead231..01c0d255ff2e 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -64,7 +64,7 @@ #define GLFW_NATIVE_INCLUDE_NONE // To avoid some symbols re-definition in windows.h #include "GLFW/glfw3native.h" - #if defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) + #if SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP // NOTE: Those functions require linking with winmm library //#pragma warning(disable: 4273) __declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod); @@ -972,7 +972,7 @@ Image GetClipboardImage(void) { Image image = { 0 }; -#if defined(SUPPORT_CLIPBOARD_IMAGE) +#if SUPPORT_CLIPBOARD_IMAGE #if defined(_WIN32) unsigned long long int dataSize = 0; void *fileData = NULL; @@ -1122,7 +1122,7 @@ const char *GetKeyName(int key) // Register all input events void PollInputEvents(void) { -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM // NOTE: Gestures update must be called every frame to reset gestures correctly // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); @@ -1693,7 +1693,7 @@ void ClosePlatform(void) glfwDestroyWindow(platform.handle); glfwTerminate(); -#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) +#if defined(_WIN32) && SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP timeEndPeriod(1); // Restore time period #endif } @@ -1838,7 +1838,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int CORE.Input.Mouse.currentButtonState[button] = action; CORE.Input.Touch.currentTouchState[button] = action; -#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) +#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES // Process mouse events as touches to be able to use mouse-gestures GestureEvent gestureEvent = { 0 }; @@ -1873,7 +1873,7 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) CORE.Input.Mouse.currentPosition.y = (float)y; CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; -#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) +#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES // Process mouse events as touches to be able to use mouse-gestures GestureEvent gestureEvent = { 0 }; diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 913223511be2..61ee777e025b 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -664,7 +664,7 @@ const char *GetClipboardText(void) return RGFW_readClipboard(NULL); } -#if defined(SUPPORT_CLIPBOARD_IMAGE) +#if SUPPORT_CLIPBOARD_IMAGE #if defined(_WIN32) #define WIN32_CLIPBOARD_IMPLEMENTATION #define WINUSER_ALREADY_INCLUDED @@ -679,7 +679,7 @@ Image GetClipboardImage(void) { Image image = { 0 }; -#if defined(SUPPORT_CLIPBOARD_IMAGE) +#if SUPPORT_CLIPBOARD_IMAGE #if defined(_WIN32) unsigned long long int dataSize = 0; void *fileData = NULL; @@ -858,7 +858,7 @@ char RSGL_keystrToChar(const char *str) // Register all input events void PollInputEvents(void) { -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM // NOTE: Gestures update must be called every frame to reset gestures correctly // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); @@ -1203,7 +1203,7 @@ void PollInputEvents(void) default: break; } -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM if (touchAction > -1) { // Process mouse events as touches to be able to use mouse-gestures diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 99de9af223a7..5ea0d16e4d83 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -1107,7 +1107,7 @@ Image GetClipboardImage(void) { Image image = { 0 }; -#if defined(SUPPORT_CLIPBOARD_IMAGE) +#if SUPPORT_CLIPBOARD_IMAGE // Let's hope compiler put these arrays in static memory const char *imageFormats[] = { "image/bmp", @@ -1311,7 +1311,7 @@ static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event) // Register all input events void PollInputEvents(void) { -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM // NOTE: Gestures update must be called every frame to reset gestures correctly // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); @@ -1737,7 +1737,7 @@ void PollInputEvents(void) default: break; } -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM if (touchAction > -1) { // Process mouse events as touches to be able to use mouse-gestures @@ -1939,7 +1939,7 @@ int InitPlatform(void) // NOTE: No need to call InitTimer(), let SDL manage it internally CORE.Time.previous = GetTime(); // Get time as double - #if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) + #if defined(_WIN32) && SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "1"); // SDL equivalent of timeBeginPeriod() and timeEndPeriod() #endif //---------------------------------------------------------------------------- diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index e9a2368680a7..e19475ead407 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -220,7 +220,7 @@ static const short linuxToRaylibMap[KEYMAP_SIZE] = { int InitPlatform(void); // Initialize platform (graphics, inputs and more) void ClosePlatform(void); // Close platform -#if defined(SUPPORT_SSH_KEYBOARD_RPI) +#if SUPPORT_SSH_KEYBOARD_RPI static void InitKeyboard(void); // Initialize raw keyboard system static void RestoreKeyboard(void); // Restore keyboard system static void ProcessKeyboard(void); // Process keyboard events @@ -648,7 +648,7 @@ const char *GetKeyName(int key) // Register all input events void PollInputEvents(void) { -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM // NOTE: Gestures update must be called every frame to reset gestures correctly // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); @@ -671,7 +671,7 @@ void PollInputEvents(void) PollKeyboardEvents(); -#if defined(SUPPORT_SSH_KEYBOARD_RPI) +#if SUPPORT_SSH_KEYBOARD_RPI // NOTE: Keyboard reading could be done using input_event(s) or just read from stdin, both methods are used here. // stdin reading is still used for legacy purposes, it allows keyboard input trough SSH console if (!platform.eventKeyboardMode) ProcessKeyboard(); @@ -1070,7 +1070,7 @@ int InitPlatform(void) //---------------------------------------------------------------------------- InitEvdevInput(); // Evdev inputs initialization -#if defined(SUPPORT_SSH_KEYBOARD_RPI) +#if SUPPORT_SSH_KEYBOARD_RPI InitKeyboard(); // Keyboard init (stdin) #endif //---------------------------------------------------------------------------- @@ -1174,7 +1174,7 @@ void ClosePlatform(void) } } -#if defined(SUPPORT_SSH_KEYBOARD_RPI) +#if SUPPORT_SSH_KEYBOARD_RPI // Initialize Keyboard system (using standard input) static void InitKeyboard(void) { @@ -1593,7 +1593,7 @@ static void PollKeyboardEvents(void) // Check if the event is a key event if (event.type != EV_KEY) continue; -#if defined(SUPPORT_SSH_KEYBOARD_RPI) +#if SUPPORT_SSH_KEYBOARD_RPI // If the event was a key, we know a working keyboard is connected, so disable the SSH keyboard platform.eventKeyboardMode = true; #endif @@ -1836,7 +1836,7 @@ static void PollMouseEvents(void) if (CORE.Input.Touch.position[i].x >= 0) CORE.Input.Touch.pointCount++; } -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM if (touchAction > -1) { GestureEvent gestureEvent = { 0 }; diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 891c4ab3417e..a1931ea425c6 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -404,7 +404,7 @@ const char *GetKeyName(int key) // Register all input events void PollInputEvents(void) { -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM // NOTE: Gestures update must be called every frame to reset gestures correctly // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index d0be025146cd..014b9285aaf8 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -968,7 +968,7 @@ const char *GetKeyName(int key) // Register all input events void PollInputEvents(void) { -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM // NOTE: Gestures update must be called every frame to reset gestures correctly // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); @@ -1534,7 +1534,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int CORE.Input.Mouse.currentButtonState[button] = action; CORE.Input.Touch.currentTouchState[button] = action; -#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) +#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES // Process mouse events as touches to be able to use mouse-gestures GestureEvent gestureEvent = { 0 }; @@ -1575,7 +1575,7 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; } -#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) +#if SUPPORT_GESTURES_SYSTEM && SUPPORT_MOUSE_GESTURES // Process mouse events as touches to be able to use mouse-gestures GestureEvent gestureEvent = { 0 }; @@ -1768,7 +1768,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.position[0].y; } -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM GestureEvent gestureEvent = {0}; gestureEvent.pointCount = CORE.Input.Touch.pointCount; diff --git a/src/raudio.c b/src/raudio.c index 7de360fc01aa..198ac40435e6 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -81,7 +81,7 @@ #include "utils.h" // Required for: fopen() Android mapping #endif -#if defined(SUPPORT_MODULE_RAUDIO) +#if SUPPORT_MODULE_RAUDIO #if defined(_WIN32) // To avoid conflicting windows.h symbols with raylib, some flags are defined @@ -204,7 +204,7 @@ typedef struct tagBITMAPINFOHEADER { #endif #endif -#if defined(SUPPORT_FILEFORMAT_WAV) +#if SUPPORT_FILEFORMAT_WAV #define DRWAV_MALLOC RL_MALLOC #define DRWAV_REALLOC RL_REALLOC #define DRWAV_FREE RL_FREE @@ -213,12 +213,12 @@ typedef struct tagBITMAPINFOHEADER { #include "external/dr_wav.h" // WAV loading functions #endif -#if defined(SUPPORT_FILEFORMAT_OGG) +#if SUPPORT_FILEFORMAT_OGG // TODO: Remap stb_vorbis malloc()/free() calls to RL_MALLOC/RL_FREE #include "external/stb_vorbis.c" // OGG loading functions #endif -#if defined(SUPPORT_FILEFORMAT_MP3) +#if SUPPORT_FILEFORMAT_MP3 #define DRMP3_MALLOC RL_MALLOC #define DRMP3_REALLOC RL_REALLOC #define DRMP3_FREE RL_FREE @@ -227,7 +227,7 @@ typedef struct tagBITMAPINFOHEADER { #include "external/dr_mp3.h" // MP3 loading functions #endif -#if defined(SUPPORT_FILEFORMAT_QOA) +#if SUPPORT_FILEFORMAT_QOA #define QOA_MALLOC RL_MALLOC #define QOA_FREE RL_FREE @@ -247,7 +247,7 @@ typedef struct tagBITMAPINFOHEADER { #endif #endif -#if defined(SUPPORT_FILEFORMAT_FLAC) +#if SUPPORT_FILEFORMAT_FLAC #define DRFLAC_MALLOC RL_MALLOC #define DRFLAC_REALLOC RL_REALLOC #define DRFLAC_FREE RL_FREE @@ -257,7 +257,7 @@ typedef struct tagBITMAPINFOHEADER { #include "external/dr_flac.h" // FLAC loading functions #endif -#if defined(SUPPORT_FILEFORMAT_XM) +#if SUPPORT_FILEFORMAT_XM #define JARXM_MALLOC RL_MALLOC #define JARXM_FREE RL_FREE @@ -274,7 +274,7 @@ typedef struct tagBITMAPINFOHEADER { #endif #endif -#if defined(SUPPORT_FILEFORMAT_MOD) +#if SUPPORT_FILEFORMAT_MOD #define JARMOD_MALLOC RL_MALLOC #define JARMOD_FREE RL_FREE @@ -789,7 +789,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int Wave wave = { 0 }; if (false) { } -#if defined(SUPPORT_FILEFORMAT_WAV) +#if SUPPORT_FILEFORMAT_WAV else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0)) { drwav wav = { 0 }; @@ -811,7 +811,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int drwav_uninit(&wav); } #endif -#if defined(SUPPORT_FILEFORMAT_OGG) +#if SUPPORT_FILEFORMAT_OGG else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0)) { stb_vorbis *oggData = stb_vorbis_open_memory((unsigned char *)fileData, dataSize, NULL, NULL); @@ -833,7 +833,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int else TRACELOG(LOG_WARNING, "WAVE: Failed to load OGG data"); } #endif -#if defined(SUPPORT_FILEFORMAT_MP3) +#if SUPPORT_FILEFORMAT_MP3 else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0)) { drmp3_config config = { 0 }; @@ -853,7 +853,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int } #endif -#if defined(SUPPORT_FILEFORMAT_QOA) +#if SUPPORT_FILEFORMAT_QOA else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0)) { qoa_desc qoa = { 0 }; @@ -872,7 +872,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int } #endif -#if defined(SUPPORT_FILEFORMAT_FLAC) +#if SUPPORT_FILEFORMAT_FLAC else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0)) { unsigned long long int totalFrameCount = 0; @@ -1049,7 +1049,7 @@ bool ExportWave(Wave wave, const char *fileName) bool success = false; if (false) { } -#if defined(SUPPORT_FILEFORMAT_WAV) +#if SUPPORT_FILEFORMAT_WAV else if (IsFileExtension(fileName, ".wav")) { drwav wav = { 0 }; @@ -1072,7 +1072,7 @@ bool ExportWave(Wave wave, const char *fileName) drwav_free(fileData, NULL); } #endif -#if defined(SUPPORT_FILEFORMAT_QOA) +#if SUPPORT_FILEFORMAT_QOA else if (IsFileExtension(fileName, ".qoa")) { if (wave.sampleSize == 16) @@ -1329,7 +1329,7 @@ Music LoadMusicStream(const char *fileName) bool musicLoaded = false; if (false) { } -#if defined(SUPPORT_FILEFORMAT_WAV) +#if SUPPORT_FILEFORMAT_WAV else if (IsFileExtension(fileName, ".wav")) { drwav *ctxWav = RL_CALLOC(1, sizeof(drwav)); @@ -1353,7 +1353,7 @@ Music LoadMusicStream(const char *fileName) } } #endif -#if defined(SUPPORT_FILEFORMAT_OGG) +#if SUPPORT_FILEFORMAT_OGG else if (IsFileExtension(fileName, ".ogg")) { // Open ogg audio stream @@ -1379,7 +1379,7 @@ Music LoadMusicStream(const char *fileName) } } #endif -#if defined(SUPPORT_FILEFORMAT_MP3) +#if SUPPORT_FILEFORMAT_MP3 else if (IsFileExtension(fileName, ".mp3")) { drmp3 *ctxMp3 = RL_CALLOC(1, sizeof(drmp3)); @@ -1400,7 +1400,7 @@ Music LoadMusicStream(const char *fileName) } } #endif -#if defined(SUPPORT_FILEFORMAT_QOA) +#if SUPPORT_FILEFORMAT_QOA else if (IsFileExtension(fileName, ".qoa")) { qoaplay_desc *ctxQoa = qoaplay_open(fileName); @@ -1419,7 +1419,7 @@ Music LoadMusicStream(const char *fileName) else{} //No uninit required } #endif -#if defined(SUPPORT_FILEFORMAT_FLAC) +#if SUPPORT_FILEFORMAT_FLAC else if (IsFileExtension(fileName, ".flac")) { drflac *ctxFlac = drflac_open_file(fileName, NULL); @@ -1441,7 +1441,7 @@ Music LoadMusicStream(const char *fileName) } } #endif -#if defined(SUPPORT_FILEFORMAT_XM) +#if SUPPORT_FILEFORMAT_XM else if (IsFileExtension(fileName, ".xm")) { jar_xm_context_t *ctxXm = NULL; @@ -1470,7 +1470,7 @@ Music LoadMusicStream(const char *fileName) } } #endif -#if defined(SUPPORT_FILEFORMAT_MOD) +#if SUPPORT_FILEFORMAT_MOD else if (IsFileExtension(fileName, ".mod")) { jar_mod_context_t *ctxMod = RL_CALLOC(1, sizeof(jar_mod_context_t)); @@ -1521,7 +1521,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, bool musicLoaded = false; if (false) { } -#if defined(SUPPORT_FILEFORMAT_WAV) +#if SUPPORT_FILEFORMAT_WAV else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0)) { drwav *ctxWav = RL_CALLOC(1, sizeof(drwav)); @@ -1546,7 +1546,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, } } #endif -#if defined(SUPPORT_FILEFORMAT_OGG) +#if SUPPORT_FILEFORMAT_OGG else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0)) { // Open ogg audio stream @@ -1572,7 +1572,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, } } #endif -#if defined(SUPPORT_FILEFORMAT_MP3) +#if SUPPORT_FILEFORMAT_MP3 else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0)) { drmp3 *ctxMp3 = RL_CALLOC(1, sizeof(drmp3)); @@ -1594,7 +1594,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, } } #endif -#if defined(SUPPORT_FILEFORMAT_QOA) +#if SUPPORT_FILEFORMAT_QOA else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0)) { qoaplay_desc *ctxQoa = NULL; @@ -1617,7 +1617,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, else{} //No uninit required } #endif -#if defined(SUPPORT_FILEFORMAT_FLAC) +#if SUPPORT_FILEFORMAT_FLAC else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0)) { drflac *ctxFlac = drflac_open_memory((const void*)data, dataSize, NULL); @@ -1639,7 +1639,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, } } #endif -#if defined(SUPPORT_FILEFORMAT_XM) +#if SUPPORT_FILEFORMAT_XM else if ((strcmp(fileType, ".xm") == 0) || (strcmp(fileType, ".XM") == 0)) { jar_xm_context_t *ctxXm = NULL; @@ -1668,7 +1668,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, } } #endif -#if defined(SUPPORT_FILEFORMAT_MOD) +#if SUPPORT_FILEFORMAT_MOD else if ((strcmp(fileType, ".mod") == 0) || (strcmp(fileType, ".MOD") == 0)) { jar_mod_context_t *ctxMod = (jar_mod_context_t *)RL_MALLOC(sizeof(jar_mod_context_t)); @@ -1744,25 +1744,25 @@ void UnloadMusicStream(Music music) if (music.ctxData != NULL) { if (false) { } -#if defined(SUPPORT_FILEFORMAT_WAV) +#if SUPPORT_FILEFORMAT_WAV else if (music.ctxType == MUSIC_AUDIO_WAV) drwav_uninit((drwav *)music.ctxData); #endif -#if defined(SUPPORT_FILEFORMAT_OGG) +#if SUPPORT_FILEFORMAT_OGG else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData); #endif -#if defined(SUPPORT_FILEFORMAT_MP3) +#if SUPPORT_FILEFORMAT_MP3 else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); } #endif -#if defined(SUPPORT_FILEFORMAT_QOA) +#if SUPPORT_FILEFORMAT_QOA else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData); #endif -#if defined(SUPPORT_FILEFORMAT_FLAC) +#if SUPPORT_FILEFORMAT_FLAC else if (music.ctxType == MUSIC_AUDIO_FLAC) drflac_free((drflac *)music.ctxData, NULL); #endif -#if defined(SUPPORT_FILEFORMAT_XM) +#if SUPPORT_FILEFORMAT_XM else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData); #endif -#if defined(SUPPORT_FILEFORMAT_MOD) +#if SUPPORT_FILEFORMAT_MOD else if (music.ctxType == MUSIC_MODULE_MOD) { jar_mod_unload((jar_mod_context_t *)music.ctxData); RL_FREE(music.ctxData); } #endif } @@ -1793,25 +1793,25 @@ void StopMusicStream(Music music) switch (music.ctxType) { -#if defined(SUPPORT_FILEFORMAT_WAV) +#if SUPPORT_FILEFORMAT_WAV case MUSIC_AUDIO_WAV: drwav_seek_to_first_pcm_frame((drwav *)music.ctxData); break; #endif -#if defined(SUPPORT_FILEFORMAT_OGG) +#if SUPPORT_FILEFORMAT_OGG case MUSIC_AUDIO_OGG: stb_vorbis_seek_start((stb_vorbis *)music.ctxData); break; #endif -#if defined(SUPPORT_FILEFORMAT_MP3) +#if SUPPORT_FILEFORMAT_MP3 case MUSIC_AUDIO_MP3: drmp3_seek_to_start_of_stream((drmp3 *)music.ctxData); break; #endif -#if defined(SUPPORT_FILEFORMAT_QOA) +#if SUPPORT_FILEFORMAT_QOA case MUSIC_AUDIO_QOA: qoaplay_rewind((qoaplay_desc *)music.ctxData); break; #endif -#if defined(SUPPORT_FILEFORMAT_FLAC) +#if SUPPORT_FILEFORMAT_FLAC case MUSIC_AUDIO_FLAC: drflac__seek_to_first_frame((drflac *)music.ctxData); break; #endif -#if defined(SUPPORT_FILEFORMAT_XM) +#if SUPPORT_FILEFORMAT_XM case MUSIC_MODULE_XM: jar_xm_reset((jar_xm_context_t *)music.ctxData); break; #endif -#if defined(SUPPORT_FILEFORMAT_MOD) +#if SUPPORT_FILEFORMAT_MOD case MUSIC_MODULE_MOD: jar_mod_seek_start((jar_mod_context_t *)music.ctxData); break; #endif default: break; @@ -1828,16 +1828,16 @@ void SeekMusicStream(Music music, float position) switch (music.ctxType) { -#if defined(SUPPORT_FILEFORMAT_WAV) +#if SUPPORT_FILEFORMAT_WAV case MUSIC_AUDIO_WAV: drwav_seek_to_pcm_frame((drwav *)music.ctxData, positionInFrames); break; #endif -#if defined(SUPPORT_FILEFORMAT_OGG) +#if SUPPORT_FILEFORMAT_OGG case MUSIC_AUDIO_OGG: stb_vorbis_seek_frame((stb_vorbis *)music.ctxData, positionInFrames); break; #endif -#if defined(SUPPORT_FILEFORMAT_MP3) +#if SUPPORT_FILEFORMAT_MP3 case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break; #endif -#if defined(SUPPORT_FILEFORMAT_QOA) +#if SUPPORT_FILEFORMAT_QOA case MUSIC_AUDIO_QOA: { int qoaFrame = positionInFrames/QOA_FRAME_LEN; @@ -1847,7 +1847,7 @@ void SeekMusicStream(Music music, float position) positionInFrames = ((qoaplay_desc *)music.ctxData)->sample_position; } break; #endif -#if defined(SUPPORT_FILEFORMAT_FLAC) +#if SUPPORT_FILEFORMAT_FLAC case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break; #endif default: break; @@ -1896,7 +1896,7 @@ void UpdateMusicStream(Music music) switch (music.ctxType) { - #if defined(SUPPORT_FILEFORMAT_WAV) + #if SUPPORT_FILEFORMAT_WAV case MUSIC_AUDIO_WAV: { if (music.stream.sampleSize == 16) @@ -1923,7 +1923,7 @@ void UpdateMusicStream(Music music) } } break; #endif - #if defined(SUPPORT_FILEFORMAT_OGG) + #if SUPPORT_FILEFORMAT_OGG case MUSIC_AUDIO_OGG: { while (true) @@ -1936,7 +1936,7 @@ void UpdateMusicStream(Music music) } } break; #endif - #if defined(SUPPORT_FILEFORMAT_MP3) + #if SUPPORT_FILEFORMAT_MP3 case MUSIC_AUDIO_MP3: { while (true) @@ -1949,7 +1949,7 @@ void UpdateMusicStream(Music music) } } break; #endif - #if defined(SUPPORT_FILEFORMAT_QOA) + #if SUPPORT_FILEFORMAT_QOA case MUSIC_AUDIO_QOA: { unsigned int frameCountRead = qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)AUDIO.System.pcmBuffer, framesToStream); @@ -1966,7 +1966,7 @@ void UpdateMusicStream(Music music) */ } break; #endif - #if defined(SUPPORT_FILEFORMAT_FLAC) + #if SUPPORT_FILEFORMAT_FLAC case MUSIC_AUDIO_FLAC: { while (true) @@ -1979,7 +1979,7 @@ void UpdateMusicStream(Music music) } } break; #endif - #if defined(SUPPORT_FILEFORMAT_XM) + #if SUPPORT_FILEFORMAT_XM case MUSIC_MODULE_XM: { // NOTE: Internally we consider 2 channels generation, so sampleCount/2 @@ -1990,7 +1990,7 @@ void UpdateMusicStream(Music music) } break; #endif - #if defined(SUPPORT_FILEFORMAT_MOD) + #if SUPPORT_FILEFORMAT_MOD case MUSIC_MODULE_MOD: { // NOTE: 3rd parameter (nbsample) specify the number of stereo 16bits samples you want, so sampleCount/2 @@ -2061,7 +2061,7 @@ float GetMusicTimePlayed(Music music) float secondsPlayed = 0.0f; if (music.stream.buffer != NULL) { -#if defined(SUPPORT_FILEFORMAT_XM) +#if SUPPORT_FILEFORMAT_XM if (music.ctxType == MUSIC_MODULE_XM) { uint64_t framesPlayed = 0; diff --git a/src/rcore.c b/src/rcore.c index ba23df776266..57e537e5fbc9 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -116,17 +116,17 @@ #define RAYMATH_IMPLEMENTATION #include "raymath.h" // Vector2, Vector3, Quaternion and Matrix functionality -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM #define RGESTURES_IMPLEMENTATION #include "rgestures.h" // Gestures detection functionality #endif -#if defined(SUPPORT_CAMERA_SYSTEM) +#if SUPPORT_CAMERA_SYSTEM #define RCAMERA_IMPLEMENTATION #include "rcamera.h" // Camera system functionality #endif -#if defined(SUPPORT_GIF_RECORDING) +#if SUPPORT_GIF_RECORDING #define MSF_GIF_MALLOC(contextPointer, newSize) RL_MALLOC(newSize) #define MSF_GIF_REALLOC(contextPointer, oldMemory, oldSize, newSize) RL_REALLOC(oldMemory, newSize) #define MSF_GIF_FREE(contextPointer, oldMemory, oldSize) RL_FREE(oldMemory) @@ -135,7 +135,7 @@ #include "external/msf_gif.h" // GIF recording functionality #endif -#if defined(SUPPORT_COMPRESSION_API) +#if SUPPORT_COMPRESSION_API #define SINFL_IMPLEMENTATION #define SINFL_NO_SIMD #include "external/sinfl.h" // Deflate (RFC 1951) decompressor @@ -144,7 +144,7 @@ #include "external/sdefl.h" // Deflate (RFC 1951) compressor #endif -#if defined(SUPPORT_RPRAND_GENERATOR) +#if SUPPORT_RPRAND_GENERATOR #define RPRAND_IMPLEMENTATION #include "external/rprand.h" #endif @@ -377,17 +377,17 @@ CoreData CORE = { 0 }; // Global CORE state context // NOTE: Useful to allow Texture, RenderTexture, Font.texture, Mesh.vaoId/vboId, Shader loading bool isGpuReady = false; -#if defined(SUPPORT_SCREEN_CAPTURE) +#if SUPPORT_SCREEN_CAPTURE static int screenshotCounter = 0; // Screenshots counter #endif -#if defined(SUPPORT_GIF_RECORDING) +#if SUPPORT_GIF_RECORDING static unsigned int gifFrameCounter = 0; // GIF frames counter static bool gifRecording = false; // GIF recording state static MsfGifState gifState = { 0 }; // MSGIF context state #endif -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS // Automation events type typedef enum AutomationEventType { EVENT_NONE = 0, @@ -480,7 +480,7 @@ static bool automationEventRecording = false; // Recording automat // NOTE: Those functions are common for all platforms! //---------------------------------------------------------------------------------- -#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) +#if SUPPORT_MODULE_RTEXT && SUPPORT_DEFAULT_FONT extern void LoadFontDefault(void); // [Module: text] Loads default font on InitWindow() extern void UnloadFontDefault(void); // [Module: text] Unloads default font from GPU memory #endif @@ -495,7 +495,7 @@ static void SetupViewport(int width, int height); // Set viewport for static void ScanDirectoryFiles(const char *basePath, FilePathList *list, const char *filter); // Scan all files and directories in a base path static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *list, const char *filter); // Scan all files and directories recursively from a base path -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS static void RecordAutomationEvent(void); // Record frame events (to internal events array) #endif @@ -504,7 +504,7 @@ static void RecordAutomationEvent(void); // Record frame events (to internal eve void __stdcall Sleep(unsigned long msTimeout); // Required for: WaitTime() #endif -#if !defined(SUPPORT_MODULE_RTEXT) +#if !SUPPORT_MODULE_RTEXT const char *TextFormat(const char *text, ...); // Formatting of text with variables to 'embed' #endif // !SUPPORT_MODULE_RTEXT @@ -513,18 +513,18 @@ const char *TextFormat(const char *text, ...); // Formatting of tex #endif // We're using `#pragma message` because `#warning` is not adopted by MSVC. -#if defined(SUPPORT_CLIPBOARD_IMAGE) - #if !defined(SUPPORT_MODULE_RTEXTURES) +#if SUPPORT_CLIPBOARD_IMAGE + #if !SUPPORT_MODULE_RTEXTURES #pragma message ("Warning: Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly") #endif // It's nice to have support Bitmap on Linux as well, but not as necessary as Windows - #if !defined(SUPPORT_FILEFORMAT_BMP) && defined(_WIN32) + #if !SUPPORT_FILEFORMAT_BMP && defined(_WIN32) #pragma message ("Warning: Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_FILEFORMAT_BMP, specially on Windows") #endif // From what I've tested applications on Wayland saves images on clipboard as PNG. - #if (!defined(SUPPORT_FILEFORMAT_PNG) || !defined(SUPPORT_FILEFORMAT_JPG)) && !defined(_WIN32) + #if (!SUPPORT_FILEFORMAT_PNG || !SUPPORT_FILEFORMAT_JPG) && !defined(_WIN32) #pragma message ("Warning: Getting image from the clipboard might not work without SUPPORT_FILEFORMAT_PNG or SUPPORT_FILEFORMAT_JPG") #endif @@ -626,27 +626,27 @@ void InitWindow(int width, int height, const char *title) TRACELOG(LOG_INFO, "Supported raylib modules:"); TRACELOG(LOG_INFO, " > rcore:..... loaded (mandatory)"); TRACELOG(LOG_INFO, " > rlgl:...... loaded (mandatory)"); -#if defined(SUPPORT_MODULE_RSHAPES) +#if SUPPORT_MODULE_RSHAPES TRACELOG(LOG_INFO, " > rshapes:... loaded (optional)"); #else TRACELOG(LOG_INFO, " > rshapes:... not loaded (optional)"); #endif -#if defined(SUPPORT_MODULE_RTEXTURES) +#if SUPPORT_MODULE_RTEXTURES TRACELOG(LOG_INFO, " > rtextures:. loaded (optional)"); #else TRACELOG(LOG_INFO, " > rtextures:. not loaded (optional)"); #endif -#if defined(SUPPORT_MODULE_RTEXT) +#if SUPPORT_MODULE_RTEXT TRACELOG(LOG_INFO, " > rtext:..... loaded (optional)"); #else TRACELOG(LOG_INFO, " > rtext:..... not loaded (optional)"); #endif -#if defined(SUPPORT_MODULE_RMODELS) +#if SUPPORT_MODULE_RMODELS TRACELOG(LOG_INFO, " > rmodels:... loaded (optional)"); #else TRACELOG(LOG_INFO, " > rmodels:... not loaded (optional)"); #endif -#if defined(SUPPORT_MODULE_RAUDIO) +#if SUPPORT_MODULE_RAUDIO TRACELOG(LOG_INFO, " > raudio:.... loaded (optional)"); #else TRACELOG(LOG_INFO, " > raudio:.... not loaded (optional)"); @@ -679,12 +679,12 @@ void InitWindow(int width, int height, const char *title) // Setup default viewport SetupViewport(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height); -#if defined(SUPPORT_MODULE_RTEXT) - #if defined(SUPPORT_DEFAULT_FONT) +#if SUPPORT_MODULE_RTEXT + #if SUPPORT_DEFAULT_FONT // Load default font // WARNING: External function: Module required: rtext LoadFontDefault(); - #if defined(SUPPORT_MODULE_RSHAPES) + #if SUPPORT_MODULE_RSHAPES // Set font white rectangle for shapes drawing, so shapes and text can be batched together // WARNING: rshapes module is required, if not available, default internal white rectangle is used Rectangle rec = GetFontDefault().recs[95]; @@ -701,7 +701,7 @@ void InitWindow(int width, int height, const char *title) #endif #endif #else - #if defined(SUPPORT_MODULE_RSHAPES) + #if SUPPORT_MODULE_RSHAPES // Set default texture and rectangle to be used for shapes drawing // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8 Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; @@ -721,7 +721,7 @@ void InitWindow(int width, int height, const char *title) // Close window and unload OpenGL context void CloseWindow(void) { -#if defined(SUPPORT_GIF_RECORDING) +#if SUPPORT_GIF_RECORDING if (gifRecording) { MsfGifResult result = msf_gif_end(&gifState); @@ -730,7 +730,7 @@ void CloseWindow(void) } #endif -#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) +#if SUPPORT_MODULE_RTEXT && SUPPORT_DEFAULT_FONT UnloadFontDefault(); // WARNING: Module required: rtext #endif @@ -888,7 +888,7 @@ void EndDrawing(void) { rlDrawRenderBatchActive(); // Update and draw internal render batch -#if defined(SUPPORT_GIF_RECORDING) +#if SUPPORT_GIF_RECORDING // Draw record indicator if (gifRecording) { @@ -916,7 +916,7 @@ void EndDrawing(void) RL_FREE(screenData); // Free image data } - #if defined(SUPPORT_MODULE_RSHAPES) && defined(SUPPORT_MODULE_RTEXT) + #if SUPPORT_MODULE_RSHAPES && SUPPORT_MODULE_RTEXT // Display the recording indicator every half-second if ((int)(GetTime()/0.5)%2 == 1) { @@ -929,11 +929,11 @@ void EndDrawing(void) } #endif -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS if (automationEventRecording) RecordAutomationEvent(); // Event recording #endif -#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL) +#if !SUPPORT_CUSTOM_FRAME_CONTROL SwapScreenBuffer(); // Copy back buffer to front buffer (screen) // Frame time control system @@ -958,10 +958,10 @@ void EndDrawing(void) PollInputEvents(); // Poll user events (before next frame update) #endif -#if defined(SUPPORT_SCREEN_CAPTURE) +#if SUPPORT_SCREEN_CAPTURE if (IsKeyPressed(KEY_F12)) { -#if defined(SUPPORT_GIF_RECORDING) +#if SUPPORT_GIF_RECORDING if (IsKeyDown(KEY_LEFT_CONTROL)) { if (gifRecording) @@ -1656,7 +1656,7 @@ int GetFPS(void) { int fps = 0; -#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL) +#if !SUPPORT_CUSTOM_FRAME_CONTROL #define FPS_CAPTURE_FRAMES_COUNT 30 // 30 captures #define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 milliseconds #define FPS_STEP (FPS_AVERAGE_TIME_SECONDS/FPS_CAPTURE_FRAMES_COUNT) @@ -1716,14 +1716,14 @@ void WaitTime(double seconds) { if (seconds < 0) return; // Security check -#if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) +#if SUPPORT_BUSY_WAIT_LOOP || SUPPORT_PARTIALBUSY_WAIT_LOOP double destinationTime = GetTime() + seconds; #endif -#if defined(SUPPORT_BUSY_WAIT_LOOP) +#if SUPPORT_BUSY_WAIT_LOOP while (GetTime() < destinationTime) { } #else - #if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) + #if SUPPORT_PARTIALBUSY_WAIT_LOOP double sleepSeconds = seconds - seconds*0.05; // NOTE: We reserve a percentage of the time for busy waiting #else double sleepSeconds = seconds; @@ -1747,7 +1747,7 @@ void WaitTime(double seconds) usleep(sleepSeconds*1000000.0); #endif - #if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) + #if SUPPORT_PARTIALBUSY_WAIT_LOOP while (GetTime() < destinationTime) { } #endif #endif @@ -1763,7 +1763,7 @@ void WaitTime(double seconds) // Set the seed for the random number generator void SetRandomSeed(unsigned int seed) { -#if defined(SUPPORT_RPRAND_GENERATOR) +#if SUPPORT_RPRAND_GENERATOR rprand_set_seed(seed); #else srand(seed); @@ -1782,7 +1782,7 @@ int GetRandomValue(int min, int max) min = tmp; } -#if defined(SUPPORT_RPRAND_GENERATOR) +#if SUPPORT_RPRAND_GENERATOR value = rprand_get_value(min, max); #else // WARNING: Ranges higher than RAND_MAX will return invalid results @@ -1804,7 +1804,7 @@ int *LoadRandomSequence(unsigned int count, int min, int max) { int *values = NULL; -#if defined(SUPPORT_RPRAND_GENERATOR) +#if SUPPORT_RPRAND_GENERATOR values = rprand_load_sequence(count, min, max); #else if (count > ((unsigned int)abs(max - min) + 1)) return values; // Security check @@ -1841,7 +1841,7 @@ int *LoadRandomSequence(unsigned int count, int min, int max) // Unload random values sequence void UnloadRandomSequence(int *sequence) { -#if defined(SUPPORT_RPRAND_GENERATOR) +#if SUPPORT_RPRAND_GENERATOR rprand_unload_sequence(sequence); #else RL_FREE(sequence); @@ -1852,7 +1852,7 @@ void UnloadRandomSequence(int *sequence) // NOTE: Provided fileName should not contain paths, saving to working directory void TakeScreenshot(const char *fileName) { -#if defined(SUPPORT_MODULE_RTEXTURES) +#if SUPPORT_MODULE_RTEXTURES // Security check to (partially) avoid malicious code if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; } @@ -1918,7 +1918,7 @@ bool IsFileExtension(const char *fileName, const char *ext) if (fileExt != NULL) { -#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_TEXT_MANIPULATION) +#if SUPPORT_MODULE_RTEXT && SUPPORT_TEXT_MANIPULATION int extCount = 0; const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext @@ -2466,7 +2466,7 @@ unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDa unsigned char *compData = NULL; -#if defined(SUPPORT_COMPRESSION_API) +#if SUPPORT_COMPRESSION_API // Compress data and generate a valid DEFLATE stream struct sdefl *sdefl = RL_CALLOC(1, sizeof(struct sdefl)); // WARNING: Possible stack overflow, struct sdefl is almost 1MB int bounds = sdefl_bound(dataSize); @@ -2486,7 +2486,7 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i { unsigned char *data = NULL; -#if defined(SUPPORT_COMPRESSION_API) +#if SUPPORT_COMPRESSION_API // Decompress data from a valid DEFLATE stream data = (unsigned char *)RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1); int length = sinflate(data, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize); @@ -2872,7 +2872,7 @@ AutomationEventList LoadAutomationEventList(const char *fileName) list.events = (AutomationEvent *)RL_CALLOC(MAX_AUTOMATION_EVENTS, sizeof(AutomationEvent)); list.capacity = MAX_AUTOMATION_EVENTS; -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS if (fileName == NULL) TRACELOG(LOG_INFO, "AUTOMATION: New empty events list loaded successfully"); else { @@ -2946,7 +2946,7 @@ AutomationEventList LoadAutomationEventList(const char *fileName) // Unload automation events list from file void UnloadAutomationEventList(AutomationEventList list) { -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS RL_FREE(list.events); #endif } @@ -2956,7 +2956,7 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName) { bool success = false; -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS // Export events as binary file // TODO: Save to memory buffer and SaveFileData() /* @@ -3005,7 +3005,7 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName) // Setup automation event list to record to void SetAutomationEventList(AutomationEventList *list) { -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS currentEventList = list; #endif } @@ -3019,7 +3019,7 @@ void SetAutomationEventBaseFrame(int frame) // Start recording automation events (AutomationEventList must be set) void StartAutomationEventRecording(void) { -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS automationEventRecording = true; #endif } @@ -3027,7 +3027,7 @@ void StartAutomationEventRecording(void) // Stop recording automation events void StopAutomationEventRecording(void) { -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS automationEventRecording = false; #endif } @@ -3035,7 +3035,7 @@ void StopAutomationEventRecording(void) // Play a recorded automation event void PlayAutomationEvent(AutomationEvent event) { -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS // WARNING: When should event be played? After/before/replace PollInputEvents()? -> Up to the user! if (!automationEventRecording) // TODO: Allow recording events while playing? @@ -3084,7 +3084,7 @@ void PlayAutomationEvent(AutomationEvent event) { CORE.Input.Gamepad.axisState[event.params[0]][event.params[1]] = ((float)event.params[2]/32768.0f); } break; - #if defined(SUPPORT_GESTURES_SYSTEM) + #if SUPPORT_GESTURES_SYSTEM case INPUT_GESTURE: GESTURES.current = event.params[0]; break; // param[0]: gesture (enum Gesture) -> rgestures.h: GESTURES.current #endif // Window event @@ -3094,7 +3094,7 @@ void PlayAutomationEvent(AutomationEvent event) case WINDOW_RESIZE: SetWindowSize(event.params[0], event.params[1]); break; // Custom event - #if defined(SUPPORT_SCREEN_CAPTURE) + #if SUPPORT_SCREEN_CAPTURE case ACTION_TAKE_SCREENSHOT: { TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter)); @@ -3516,7 +3516,7 @@ void InitTimer(void) // However, it can also reduce overall system performance, because the thread scheduler switches tasks more often // High resolutions can also prevent the CPU power management system from entering power-saving modes // Setting a higher resolution does not improve the accuracy of the high-resolution performance counter -#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_DESKTOP_SDL) +#if defined(_WIN32) && SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP && !defined(PLATFORM_DESKTOP_SDL) timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms) #endif @@ -3762,7 +3762,7 @@ static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *fi else TRACELOG(LOG_WARNING, "FILEIO: Directory cannot be opened (%s)", basePath); } -#if defined(SUPPORT_AUTOMATION_EVENTS) +#if SUPPORT_AUTOMATION_EVENTS // Automation event recording // NOTE: Recording is by default done at EndDrawing(), before PollInputEvents() static void RecordAutomationEvent(void) @@ -4007,7 +4007,7 @@ static void RecordAutomationEvent(void) } //------------------------------------------------------------------------------------- -#if defined(SUPPORT_GESTURES_SYSTEM) +#if SUPPORT_GESTURES_SYSTEM // Gestures input currentEventList->events recording //------------------------------------------------------------------------------------- if (GESTURES.current != GESTURE_NONE) @@ -4029,7 +4029,7 @@ static void RecordAutomationEvent(void) } #endif -#if !defined(SUPPORT_MODULE_RTEXT) +#if !SUPPORT_MODULE_RTEXT // Formatting of text with variables to 'embed' // WARNING: String returned will expire after this function is called MAX_TEXTFORMAT_BUFFERS times const char *TextFormat(const char *text, ...) diff --git a/src/rmodels.c b/src/rmodels.c index 05ad8083c73c..c745d792a0ec 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -47,7 +47,7 @@ #include "config.h" // Defines module configuration flags #endif -#if defined(SUPPORT_MODULE_RMODELS) +#if SUPPORT_MODULE_RMODELS #include "utils.h" // Required for: TRACELOG(), LoadFileData(), LoadFileText(), SaveFileText() #include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 @@ -58,7 +58,7 @@ #include // Required for: memcmp(), strlen(), strncpy() #include // Required for: sinf(), cosf(), sqrtf(), fabsf() -#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL) +#if SUPPORT_FILEFORMAT_OBJ || SUPPORT_FILEFORMAT_MTL #define TINYOBJ_MALLOC RL_MALLOC #define TINYOBJ_CALLOC RL_CALLOC #define TINYOBJ_REALLOC RL_REALLOC @@ -68,7 +68,7 @@ #include "external/tinyobj_loader_c.h" // OBJ/MTL file formats loading #endif -#if defined(SUPPORT_FILEFORMAT_GLTF) +#if SUPPORT_FILEFORMAT_GLTF #define CGLTF_MALLOC RL_MALLOC #define CGLTF_FREE RL_FREE @@ -76,7 +76,7 @@ #include "external/cgltf.h" // glTF file format loading #endif -#if defined(SUPPORT_FILEFORMAT_VOX) +#if SUPPORT_FILEFORMAT_VOX #define VOX_MALLOC RL_MALLOC #define VOX_CALLOC RL_CALLOC #define VOX_REALLOC RL_REALLOC @@ -86,8 +86,8 @@ #include "external/vox_loader.h" // VOX file format loading (MagikaVoxel) #endif -#if defined(SUPPORT_FILEFORMAT_M3D) - #define M3D_MALLOC RL_MALLOC +#if SUPPORT_FILEFORMAT_M3D +#define M3D_MALLOC RL_MALLOC #define M3D_REALLOC RL_REALLOC #define M3D_FREE RL_FREE @@ -95,7 +95,7 @@ #include "external/m3d.h" // Model3D file format loading #endif -#if defined(SUPPORT_MESH_GENERATION) +#if SUPPORT_MESH_GENERATION #define PAR_MALLOC(T, N) ((T*)RL_MALLOC(N*sizeof(T))) #define PAR_CALLOC(T, N) ((T*)RL_CALLOC(N*sizeof(T), 1)) #define PAR_REALLOC(T, BUF, N) ((T*)RL_REALLOC(BUF, sizeof(T)*(N))) @@ -146,25 +146,25 @@ //---------------------------------------------------------------------------------- // Module specific Functions Declaration //---------------------------------------------------------------------------------- -#if defined(SUPPORT_FILEFORMAT_OBJ) +#if SUPPORT_FILEFORMAT_OBJ static Model LoadOBJ(const char *fileName); // Load OBJ mesh data #endif -#if defined(SUPPORT_FILEFORMAT_IQM) +#if SUPPORT_FILEFORMAT_IQM static Model LoadIQM(const char *fileName); // Load IQM mesh data static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCount); // Load IQM animation data #endif -#if defined(SUPPORT_FILEFORMAT_GLTF) +#if SUPPORT_FILEFORMAT_GLTF static Model LoadGLTF(const char *fileName); // Load GLTF mesh data static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCount); // Load GLTF animation data #endif -#if defined(SUPPORT_FILEFORMAT_VOX) +#if SUPPORT_FILEFORMAT_VOX static Model LoadVOX(const char *filename); // Load VOX mesh data #endif -#if defined(SUPPORT_FILEFORMAT_M3D) +#if SUPPORT_FILEFORMAT_M3D static Model LoadM3D(const char *filename); // Load M3D mesh data static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCount); // Load M3D animation data #endif -#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL) +#if SUPPORT_FILEFORMAT_OBJ || SUPPORT_FILEFORMAT_MTL static void ProcessMaterialsOBJ(Material *rayMaterials, tinyobj_material_t *materials, int materialCount); // Process obj materials #endif @@ -1091,19 +1091,19 @@ Model LoadModel(const char *fileName) { Model model = { 0 }; -#if defined(SUPPORT_FILEFORMAT_OBJ) +#if SUPPORT_FILEFORMAT_OBJ if (IsFileExtension(fileName, ".obj")) model = LoadOBJ(fileName); #endif -#if defined(SUPPORT_FILEFORMAT_IQM) +#if SUPPORT_FILEFORMAT_IQM if (IsFileExtension(fileName, ".iqm")) model = LoadIQM(fileName); #endif -#if defined(SUPPORT_FILEFORMAT_GLTF) +#if SUPPORT_FILEFORMAT_GLTF if (IsFileExtension(fileName, ".gltf") || IsFileExtension(fileName, ".glb")) model = LoadGLTF(fileName); #endif -#if defined(SUPPORT_FILEFORMAT_VOX) +#if SUPPORT_FILEFORMAT_VOX if (IsFileExtension(fileName, ".vox")) model = LoadVOX(fileName); #endif -#if defined(SUPPORT_FILEFORMAT_M3D) +#if SUPPORT_FILEFORMAT_M3D if (IsFileExtension(fileName, ".m3d")) model = LoadM3D(fileName); #endif @@ -2111,7 +2111,7 @@ bool ExportMeshAsCode(Mesh mesh, const char *fileName) return success; } -#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL) +#if SUPPORT_FILEFORMAT_OBJ || SUPPORT_FILEFORMAT_MTL // Process obj materials static void ProcessMaterialsOBJ(Material *materials, tinyobj_material_t *mats, int materialCount) { @@ -2155,7 +2155,7 @@ Material *LoadMaterials(const char *fileName, int *materialCount) // TODO: Support IQM and GLTF for materials parsing -#if defined(SUPPORT_FILEFORMAT_MTL) +#if SUPPORT_FILEFORMAT_MTL if (IsFileExtension(fileName, ".mtl")) { tinyobj_material_t *mats = NULL; @@ -2248,13 +2248,13 @@ ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount) { ModelAnimation *animations = NULL; -#if defined(SUPPORT_FILEFORMAT_IQM) +#if SUPPORT_FILEFORMAT_IQM if (IsFileExtension(fileName, ".iqm")) animations = LoadModelAnimationsIQM(fileName, animCount); #endif -#if defined(SUPPORT_FILEFORMAT_M3D) +#if SUPPORT_FILEFORMAT_M3D if (IsFileExtension(fileName, ".m3d")) animations = LoadModelAnimationsM3D(fileName, animCount); #endif -#if defined(SUPPORT_FILEFORMAT_GLTF) +#if SUPPORT_FILEFORMAT_GLTF if (IsFileExtension(fileName, ".gltf;.glb")) animations = LoadModelAnimationsGLTF(fileName, animCount); #endif @@ -2402,7 +2402,7 @@ bool IsModelAnimationValid(Model model, ModelAnimation anim) return result; } -#if defined(SUPPORT_MESH_GENERATION) +#if SUPPORT_MESH_GENERATION // Generate polygonal mesh Mesh GenMeshPoly(int sides, float radius) { @@ -4157,7 +4157,7 @@ RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Ve //---------------------------------------------------------------------------------- // Module specific Functions Definition //---------------------------------------------------------------------------------- -#if defined(SUPPORT_FILEFORMAT_IQM) || defined(SUPPORT_FILEFORMAT_GLTF) +#if SUPPORT_FILEFORMAT_IQM || SUPPORT_FILEFORMAT_GLTF // Build pose from parent joints // NOTE: Required for animations loading (required by IQM and GLTF) static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform *transforms) @@ -4180,7 +4180,7 @@ static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform } #endif -#if defined(SUPPORT_FILEFORMAT_OBJ) +#if SUPPORT_FILEFORMAT_OBJ // Load OBJ mesh data // // Keep the following information in mind when reading this @@ -4425,7 +4425,7 @@ static Model LoadOBJ(const char *fileName) } #endif -#if defined(SUPPORT_FILEFORMAT_IQM) +#if SUPPORT_FILEFORMAT_IQM // Load IQM mesh data static Model LoadIQM(const char *fileName) { @@ -5043,7 +5043,7 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCou #endif -#if defined(SUPPORT_FILEFORMAT_GLTF) +#if SUPPORT_FILEFORMAT_GLTF // Load file data callback for cgltf static cgltf_result LoadFileGLTFCallback(const struct cgltf_memory_options *memoryOptions, const struct cgltf_file_options *fileOptions, const char *path, cgltf_size *size, void **data) { @@ -6219,7 +6219,7 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo } #endif -#if defined(SUPPORT_FILEFORMAT_VOX) +#if SUPPORT_FILEFORMAT_VOX // Load VOX (MagicaVoxel) mesh data static Model LoadVOX(const char *fileName) { @@ -6329,7 +6329,7 @@ static Model LoadVOX(const char *fileName) } #endif -#if defined(SUPPORT_FILEFORMAT_M3D) +#if SUPPORT_FILEFORMAT_M3D // Hook LoadFileData()/UnloadFileData() calls to M3D loaders unsigned char *m3d_loaderhook(char *fn, unsigned int *len) { return LoadFileData((const char *)fn, (int *)len); } void m3d_freehook(void *data) { UnloadFileData((unsigned char *)data); } diff --git a/src/rshapes.c b/src/rshapes.c index ece5513b36f0..fb62b8ca8e16 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -51,7 +51,7 @@ #include "config.h" // Defines module configuration flags #endif -#if defined(SUPPORT_MODULE_RSHAPES) +#if SUPPORT_MODULE_RSHAPES #include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 @@ -132,7 +132,7 @@ void DrawPixel(int posX, int posY, Color color) // Draw a pixel (Vector version) void DrawPixelV(Vector2 position, Color color) { -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); @@ -310,7 +310,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA float stepLength = (endAngle - startAngle)/(float)segments; float angle = startAngle; -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); @@ -538,7 +538,7 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA float stepLength = (endAngle - startAngle)/(float)segments; float angle = startAngle; -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); @@ -718,7 +718,7 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color bottomRight.y = y + (dx + rec.width)*sinRotation + (dy + rec.height)*cosRotation; } -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); @@ -825,7 +825,7 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color) rlEnd(); /* // Previous implementation, it has issues... but it does not require view matrix... -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE DrawRectangle(posX, posY, width, 1, color); DrawRectangle(posX + width - 1, posY + 1, 1, height - 2, color); DrawRectangle(posX, posY + height - 1, width, 1, color); @@ -935,7 +935,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co const Vector2 centers[4] = { point[8], point[9], point[10], point[11] }; const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f }; -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); @@ -1178,7 +1178,7 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f if (lineThick > 1) { -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); @@ -1354,7 +1354,7 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f // NOTE: Vertex must be provided in counter-clockwise order void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) { -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); @@ -1469,7 +1469,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col float centralAngle = rotation*DEG2RAD; float angleStep = 360.0f/(float)sides*DEG2RAD; -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); @@ -1538,7 +1538,7 @@ void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, fl float exteriorAngle = 360.0f/(float)sides*DEG2RAD; float innerRadius = radius - (lineThick*cosf(DEG2RAD*exteriorAngle/2.0f)); -#if defined(SUPPORT_QUADS_DRAW_MODE) +#if SUPPORT_QUADS_DRAW_MODE rlSetTexture(GetShapesTexture().id); Rectangle shapeRect = GetShapesTextureRectangle(); diff --git a/src/rtext.c b/src/rtext.c index 999557d38f01..ad9986537ca5 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -60,7 +60,7 @@ #include "config.h" // Defines module configuration flags #endif -#if defined(SUPPORT_MODULE_RTEXT) +#if SUPPORT_MODULE_RTEXT #include "utils.h" // Required for: LoadFile*() #include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 -> Only DrawTextPro() @@ -71,7 +71,7 @@ #include // Required for: va_list, va_start(), vsprintf(), va_end() [Used in TextFormat()] #include // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()] -#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF) +#if SUPPORT_FILEFORMAT_TTF || SUPPORT_FILEFORMAT_BDF #if defined(__GNUC__) // GCC and Clang #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" @@ -87,7 +87,7 @@ #endif #endif -#if defined(SUPPORT_FILEFORMAT_TTF) +#if SUPPORT_FILEFORMAT_TTF #if defined(__GNUC__) // GCC and Clang #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" @@ -125,7 +125,7 @@ // Global variables //---------------------------------------------------------------------------------- extern bool isGpuReady; -#if defined(SUPPORT_DEFAULT_FONT) +#if SUPPORT_DEFAULT_FONT // Default font provided by raylib // NOTE: Default font is loaded on InitWindow() and disposed on CloseWindow() [module: core] static Font defaultFont = { 0 }; @@ -139,15 +139,15 @@ static Font defaultFont = { 0 }; //---------------------------------------------------------------------------------- // Module specific Functions Declaration //---------------------------------------------------------------------------------- -#if defined(SUPPORT_FILEFORMAT_FNT) +#if SUPPORT_FILEFORMAT_FNT static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file) #endif -#if defined(SUPPORT_FILEFORMAT_BDF) +#if SUPPORT_FILEFORMAT_BDF static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, int *codepoints, int codepointCount, int *outFontSize); #endif static int textLineSpacing = 2; // Text vertical line spacing in pixels (between lines) -#if defined(SUPPORT_DEFAULT_FONT) +#if SUPPORT_DEFAULT_FONT extern void LoadFontDefault(void); extern void UnloadFontDefault(void); #endif @@ -155,7 +155,7 @@ extern void UnloadFontDefault(void); //---------------------------------------------------------------------------------- // Module Functions Definition //---------------------------------------------------------------------------------- -#if defined(SUPPORT_DEFAULT_FONT) +#if SUPPORT_DEFAULT_FONT // Load raylib default font extern void LoadFontDefault(void) { @@ -318,7 +318,7 @@ extern void UnloadFontDefault(void) // Get the default font, useful to be used with extended parameters Font GetFontDefault() { -#if defined(SUPPORT_DEFAULT_FONT) +#if SUPPORT_DEFAULT_FONT return defaultFont; #else Font font = { 0 }; @@ -345,15 +345,15 @@ Font LoadFont(const char *fileName) Font font = { 0 }; -#if defined(SUPPORT_FILEFORMAT_TTF) +#if SUPPORT_FILEFORMAT_TTF if (IsFileExtension(fileName, ".ttf") || IsFileExtension(fileName, ".otf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS); else #endif -#if defined(SUPPORT_FILEFORMAT_FNT) +#if SUPPORT_FILEFORMAT_FNT if (IsFileExtension(fileName, ".fnt")) font = LoadBMFont(fileName); else #endif -#if defined(SUPPORT_FILEFORMAT_BDF) +#if SUPPORT_FILEFORMAT_BDF if (IsFileExtension(fileName, ".bdf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS); else #endif @@ -535,7 +535,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int font.glyphCount = (codepointCount > 0)? codepointCount : 95; font.glyphPadding = 0; -#if defined(SUPPORT_FILEFORMAT_TTF) +#if SUPPORT_FILEFORMAT_TTF if (TextIsEqual(fileExtLower, ".ttf") || TextIsEqual(fileExtLower, ".otf")) { @@ -543,7 +543,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int } else #endif -#if defined(SUPPORT_FILEFORMAT_BDF) +#if SUPPORT_FILEFORMAT_BDF if (TextIsEqual(fileExtLower, ".bdf")) { font.glyphs = LoadFontDataBDF(fileData, dataSize, codepoints, font.glyphCount, &font.baseSize); @@ -554,7 +554,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int font.glyphs = NULL; } -#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF) +#if SUPPORT_FILEFORMAT_TTF || SUPPORT_FILEFORMAT_BDF if (font.glyphs != NULL) { font.glyphPadding = FONT_TTF_DEFAULT_CHARS_PADDING; @@ -614,7 +614,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz GlyphInfo *chars = NULL; -#if defined(SUPPORT_FILEFORMAT_TTF) +#if SUPPORT_FILEFORMAT_TTF // Load font data (including pixel data) from TTF memory file // NOTE: Loaded information should be enough to generate font image atlas, using any packaging method if (fileData != NULL) @@ -734,7 +734,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz // Generate image font atlas using chars info // NOTE: Packing method: 0-Default, 1-Skyline -#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF) +#if SUPPORT_FILEFORMAT_TTF || SUPPORT_FILEFORMAT_BDF Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod) { Image atlas = { 0 }; @@ -901,7 +901,7 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp RL_FREE(context); } -#if defined(SUPPORT_FONT_ATLAS_WHITE_REC) +#if 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 // shapes and text can be backed into a single draw call: SetShapesTexture() @@ -1487,7 +1487,7 @@ float TextToFloat(const char *text) return value*sign; } -#if defined(SUPPORT_TEXT_MANIPULATION) +#if SUPPORT_TEXT_MANIPULATION // Copy one string to another, returns bytes copied int TextCopy(char *dst, const char *src) { @@ -2136,7 +2136,7 @@ int GetCodepointPrevious(const char *text, int *codepointSize) //---------------------------------------------------------------------------------- // Module specific Functions Definition //---------------------------------------------------------------------------------- -#if defined(SUPPORT_FILEFORMAT_FNT) || defined(SUPPORT_FILEFORMAT_BDF) +#if SUPPORT_FILEFORMAT_FNT || SUPPORT_FILEFORMAT_BDF // Read a line from memory // REQUIRES: memcpy() // NOTE: Returns the number of bytes read @@ -2150,7 +2150,7 @@ static int GetLine(const char *origin, char *buffer, int maxLength) } #endif -#if defined(SUPPORT_FILEFORMAT_FNT) +#if SUPPORT_FILEFORMAT_FNT // Load a BMFont file (AngelCode font file) // REQUIRES: strstr(), sscanf(), strrchr(), memcpy() static Font LoadBMFont(const char *fileName) @@ -2320,7 +2320,7 @@ static Font LoadBMFont(const char *fileName) #endif -#if defined(SUPPORT_FILEFORMAT_BDF) +#if SUPPORT_FILEFORMAT_BDF // Convert hexadecimal to decimal (single digit) static unsigned char HexToInt(char hex) diff --git a/src/rtextures.c b/src/rtextures.c index 2d269d7f379d..91b09a10d41b 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -68,7 +68,7 @@ #include "config.h" // Defines module configuration flags #endif -#if defined(SUPPORT_MODULE_RTEXTURES) +#if SUPPORT_MODULE_RTEXTURES #include "utils.h" // Required for: TRACELOG() #include "rlgl.h" // OpenGL abstraction layer to multiple versions @@ -79,47 +79,47 @@ #include // Required for: sprintf() [Used in ExportImageAsCode()] // Support only desired texture formats on stb_image -#if !defined(SUPPORT_FILEFORMAT_BMP) +#if !SUPPORT_FILEFORMAT_BMP #define STBI_NO_BMP #endif -#if !defined(SUPPORT_FILEFORMAT_PNG) +#if !SUPPORT_FILEFORMAT_PNG #define STBI_NO_PNG #endif -#if !defined(SUPPORT_FILEFORMAT_TGA) +#if !SUPPORT_FILEFORMAT_TGA #define STBI_NO_TGA #endif -#if !defined(SUPPORT_FILEFORMAT_JPG) +#if !SUPPORT_FILEFORMAT_JPG #define STBI_NO_JPEG // Image format .jpg and .jpeg #endif -#if !defined(SUPPORT_FILEFORMAT_PSD) +#if !SUPPORT_FILEFORMAT_PSD #define STBI_NO_PSD #endif -#if !defined(SUPPORT_FILEFORMAT_GIF) +#if !SUPPORT_FILEFORMAT_GIF #define STBI_NO_GIF #endif -#if !defined(SUPPORT_FILEFORMAT_PIC) +#if !SUPPORT_FILEFORMAT_PIC #define STBI_NO_PIC #endif -#if !defined(SUPPORT_FILEFORMAT_HDR) +#if !SUPPORT_FILEFORMAT_HDR #define STBI_NO_HDR #endif -#if !defined(SUPPORT_FILEFORMAT_PNM) +#if !SUPPORT_FILEFORMAT_PNM #define STBI_NO_PNM #endif -#if defined(SUPPORT_FILEFORMAT_DDS) +#if SUPPORT_FILEFORMAT_DDS #define RL_GPUTEX_SUPPORT_DDS #endif -#if defined(SUPPORT_FILEFORMAT_PKM) +#if SUPPORT_FILEFORMAT_PNM #define RL_GPUTEX_SUPPORT_PKM #endif -#if defined(SUPPORT_FILEFORMAT_KTX) +#if SUPPORT_FILEFORMAT_KTX #define RL_GPUTEX_SUPPORT_KTX #endif -#if defined(SUPPORT_FILEFORMAT_PVR) +#if SUPPORT_FILEFORMAT_PVR #define RL_GPUTEX_SUPPORT_PVR #endif -#if defined(SUPPORT_FILEFORMAT_ASTC) +#if SUPPORT_FILEFORMAT_ASTC #define RL_GPUTEX_SUPPORT_ASTC #endif @@ -128,15 +128,15 @@ #define STBI_NO_SIMD #endif -#if (defined(SUPPORT_FILEFORMAT_BMP) || \ - defined(SUPPORT_FILEFORMAT_PNG) || \ - defined(SUPPORT_FILEFORMAT_TGA) || \ - defined(SUPPORT_FILEFORMAT_JPG) || \ - defined(SUPPORT_FILEFORMAT_PSD) || \ - defined(SUPPORT_FILEFORMAT_GIF) || \ - defined(SUPPORT_FILEFORMAT_HDR) || \ - defined(SUPPORT_FILEFORMAT_PIC) || \ - defined(SUPPORT_FILEFORMAT_PNM)) +#if (SUPPORT_FILEFORMAT_BMP || \ + SUPPORT_FILEFORMAT_PNG || \ + SUPPORT_FILEFORMAT_TGA || \ + SUPPORT_FILEFORMAT_JPG || \ + SUPPORT_FILEFORMAT_PSD || \ + SUPPORT_FILEFORMAT_GIF || \ + SUPPORT_FILEFORMAT_HDR || \ + SUPPORT_FILEFORMAT_PIC || \ + SUPPORT_FILEFORMAT_PNM) #if defined(__GNUC__) // GCC and Clang #pragma GCC diagnostic push @@ -158,11 +158,11 @@ #endif #endif -#if (defined(SUPPORT_FILEFORMAT_DDS) || \ - defined(SUPPORT_FILEFORMAT_PKM) || \ - defined(SUPPORT_FILEFORMAT_KTX) || \ - defined(SUPPORT_FILEFORMAT_PVR) || \ - defined(SUPPORT_FILEFORMAT_ASTC)) +#if (SUPPORT_FILEFORMAT_DDS || \ + SUPPORT_FILEFORMAT_PNM || \ + SUPPORT_FILEFORMAT_KTX || \ + SUPPORT_FILEFORMAT_PVR || \ + SUPPORT_FILEFORMAT_ASTC) #if defined(__GNUC__) // GCC and Clang #pragma GCC diagnostic push @@ -178,7 +178,7 @@ #endif #endif -#if defined(SUPPORT_FILEFORMAT_QOI) +#if SUPPORT_FILEFORMAT_QOI #define QOI_MALLOC RL_MALLOC #define QOI_FREE RL_FREE @@ -196,7 +196,7 @@ #endif -#if defined(SUPPORT_IMAGE_EXPORT) +#if SUPPORT_IMAGE_EXPORT #define STBIW_MALLOC RL_MALLOC #define STBIW_FREE RL_FREE #define STBIW_REALLOC RL_REALLOC @@ -205,7 +205,7 @@ #include "external/stb_image_write.h" // Required for: stbi_write_*() #endif -#if defined(SUPPORT_IMAGE_GENERATION) +#if SUPPORT_IMAGE_GENERATION #define STB_PERLIN_IMPLEMENTATION #include "external/stb_perlin.h" // Required for: stb_perlin_fbm_noise3 #endif @@ -267,15 +267,15 @@ Image LoadImage(const char *fileName) { Image image = { 0 }; -#if defined(SUPPORT_FILEFORMAT_PNG) || \ - defined(SUPPORT_FILEFORMAT_BMP) || \ - defined(SUPPORT_FILEFORMAT_TGA) || \ - defined(SUPPORT_FILEFORMAT_JPG) || \ - defined(SUPPORT_FILEFORMAT_GIF) || \ - defined(SUPPORT_FILEFORMAT_PIC) || \ - defined(SUPPORT_FILEFORMAT_HDR) || \ - defined(SUPPORT_FILEFORMAT_PNM) || \ - defined(SUPPORT_FILEFORMAT_PSD) +#if SUPPORT_FILEFORMAT_PNG || \ + SUPPORT_FILEFORMAT_BMP || \ + SUPPORT_FILEFORMAT_TGA || \ + SUPPORT_FILEFORMAT_JPG || \ + SUPPORT_FILEFORMAT_GIF || \ + SUPPORT_FILEFORMAT_PIC || \ + SUPPORT_FILEFORMAT_HDR || \ + SUPPORT_FILEFORMAT_PNM || \ + SUPPORT_FILEFORMAT_PSD #define STBI_REQUIRED #endif @@ -337,7 +337,7 @@ Image LoadImageAnim(const char *fileName, int *frames) Image image = { 0 }; int frameCount = 0; -#if defined(SUPPORT_FILEFORMAT_GIF) +#if SUPPORT_FILEFORMAT_GIF if (IsFileExtension(fileName, ".gif")) { int dataSize = 0; @@ -382,7 +382,7 @@ Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileDat // Security check for input data if ((fileType == NULL) || (fileData == NULL) || (dataSize == 0)) return image; -#if defined(SUPPORT_FILEFORMAT_GIF) +#if SUPPORT_FILEFORMAT_GIF if ((strcmp(fileType, ".gif") == 0) || (strcmp(fileType, ".GIF") == 0)) { if (fileData != NULL) @@ -429,30 +429,30 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i } if ((false) -#if defined(SUPPORT_FILEFORMAT_PNG) +#if SUPPORT_FILEFORMAT_PNG || (strcmp(fileType, ".png") == 0) || (strcmp(fileType, ".PNG") == 0) #endif -#if defined(SUPPORT_FILEFORMAT_BMP) +#if SUPPORT_FILEFORMAT_BMP || (strcmp(fileType, ".bmp") == 0) || (strcmp(fileType, ".BMP") == 0) #endif -#if defined(SUPPORT_FILEFORMAT_TGA) +#if SUPPORT_FILEFORMAT_TGA || (strcmp(fileType, ".tga") == 0) || (strcmp(fileType, ".TGA") == 0) #endif -#if defined(SUPPORT_FILEFORMAT_JPG) +#if SUPPORT_FILEFORMAT_JPG || (strcmp(fileType, ".jpg") == 0) || (strcmp(fileType, ".jpeg") == 0) || (strcmp(fileType, ".JPG") == 0) || (strcmp(fileType, ".JPEG") == 0) #endif -#if defined(SUPPORT_FILEFORMAT_GIF) +#if SUPPORT_FILEFORMAT_GIF || (strcmp(fileType, ".gif") == 0) || (strcmp(fileType, ".GIF") == 0) #endif -#if defined(SUPPORT_FILEFORMAT_PIC) +#if SUPPORT_FILEFORMAT_PIC || (strcmp(fileType, ".pic") == 0) || (strcmp(fileType, ".PIC") == 0) #endif -#if defined(SUPPORT_FILEFORMAT_PNM) +#if SUPPORT_FILEFORMAT_PNM || (strcmp(fileType, ".ppm") == 0) || (strcmp(fileType, ".pgm") == 0) || (strcmp(fileType, ".PPM") == 0) || (strcmp(fileType, ".PGM") == 0) #endif -#if defined(SUPPORT_FILEFORMAT_PSD) +#if SUPPORT_FILEFORMAT_PSD || (strcmp(fileType, ".psd") == 0) || (strcmp(fileType, ".PSD") == 0) #endif ) @@ -477,7 +477,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i } #endif } -#if defined(SUPPORT_FILEFORMAT_HDR) +#if SUPPORT_FILEFORMAT_HDR else if ((strcmp(fileType, ".hdr") == 0) || (strcmp(fileType, ".HDR") == 0)) { #if defined(STBI_REQUIRED) @@ -500,7 +500,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i #endif } #endif -#if defined(SUPPORT_FILEFORMAT_QOI) +#if SUPPORT_FILEFORMAT_QOI else if ((strcmp(fileType, ".qoi") == 0) || (strcmp(fileType, ".QOI") == 0)) { if (fileData != NULL) @@ -514,31 +514,31 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i } } #endif -#if defined(SUPPORT_FILEFORMAT_DDS) +#if SUPPORT_FILEFORMAT_DDS else if ((strcmp(fileType, ".dds") == 0) || (strcmp(fileType, ".DDS") == 0)) { image.data = rl_load_dds_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps); } #endif -#if defined(SUPPORT_FILEFORMAT_PKM) +#if SUPPORT_FILEFORMAT_PKM else if ((strcmp(fileType, ".pkm") == 0) || (strcmp(fileType, ".PKM") == 0)) { image.data = rl_load_pkm_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps); } #endif -#if defined(SUPPORT_FILEFORMAT_KTX) +#if SUPPORT_FILEFORMAT_KTX else if ((strcmp(fileType, ".ktx") == 0) || (strcmp(fileType, ".KTX") == 0)) { image.data = rl_load_ktx_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps); } #endif -#if defined(SUPPORT_FILEFORMAT_PVR) +#if SUPPORT_FILEFORMAT_PVR else if ((strcmp(fileType, ".pvr") == 0) || (strcmp(fileType, ".PVR") == 0)) { image.data = rl_load_pvr_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps); } #endif -#if defined(SUPPORT_FILEFORMAT_ASTC) +#if SUPPORT_FILEFORMAT_ASTC else if ((strcmp(fileType, ".astc") == 0) || (strcmp(fileType, ".ASTC") == 0)) { image.data = rl_load_astc_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps); @@ -628,7 +628,7 @@ bool ExportImage(Image image, const char *fileName) // Security check for input data if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return result; -#if defined(SUPPORT_IMAGE_EXPORT) +#if SUPPORT_IMAGE_EXPORT int channels = 4; bool allocatedData = false; unsigned char *imgData = (unsigned char *)image.data; @@ -644,7 +644,7 @@ bool ExportImage(Image image, const char *fileName) allocatedData = true; } -#if defined(SUPPORT_FILEFORMAT_PNG) +#if SUPPORT_FILEFORMAT_PNG if (IsFileExtension(fileName, ".png")) { int dataSize = 0; @@ -655,17 +655,17 @@ bool ExportImage(Image image, const char *fileName) #else if (false) { } #endif -#if defined(SUPPORT_FILEFORMAT_BMP) +#if SUPPORT_FILEFORMAT_BMP else if (IsFileExtension(fileName, ".bmp")) result = stbi_write_bmp(fileName, image.width, image.height, channels, imgData); #endif -#if defined(SUPPORT_FILEFORMAT_TGA) +#if SUPPORT_FILEFORMAT_TGA else if (IsFileExtension(fileName, ".tga")) result = stbi_write_tga(fileName, image.width, image.height, channels, imgData); #endif -#if defined(SUPPORT_FILEFORMAT_JPG) +#if SUPPORT_FILEFORMAT_JPG else if (IsFileExtension(fileName, ".jpg") || IsFileExtension(fileName, ".jpeg")) result = stbi_write_jpg(fileName, image.width, image.height, channels, imgData, 90); // JPG quality: between 1 and 100 #endif -#if defined(SUPPORT_FILEFORMAT_QOI) +#if SUPPORT_FILEFORMAT_QOI else if (IsFileExtension(fileName, ".qoi")) { channels = 0; @@ -685,7 +685,7 @@ bool ExportImage(Image image, const char *fileName) } } #endif -#if defined(SUPPORT_FILEFORMAT_KTX) +#if SUPPORT_FILEFORMAT_KTX else if (IsFileExtension(fileName, ".ktx")) { result = rl_save_ktx(fileName, image.data, image.width, image.height, image.format, image.mipmaps); @@ -716,7 +716,7 @@ unsigned char *ExportImageToMemory(Image image, const char *fileType, int *dataS // Security check for input data if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return NULL; -#if defined(SUPPORT_IMAGE_EXPORT) +#if SUPPORT_IMAGE_EXPORT int channels = 4; if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) channels = 1; @@ -724,7 +724,7 @@ unsigned char *ExportImageToMemory(Image image, const char *fileType, int *dataS else if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8) channels = 3; else if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8) channels = 4; -#if defined(SUPPORT_FILEFORMAT_PNG) +#if SUPPORT_FILEFORMAT_PNG if ((strcmp(fileType, ".png") == 0) || (strcmp(fileType, ".PNG") == 0)) { fileData = stbi_write_png_to_mem((const unsigned char *)image.data, image.width*channels, image.width, image.height, channels, dataSize); @@ -741,7 +741,7 @@ bool ExportImageAsCode(Image image, const char *fileName) { bool success = false; -#if defined(SUPPORT_IMAGE_EXPORT) +#if SUPPORT_IMAGE_EXPORT #ifndef TEXT_BYTES_PER_LINE #define TEXT_BYTES_PER_LINE 20 @@ -814,7 +814,7 @@ Image GenImageColor(int width, int height, Color color) return image; } -#if defined(SUPPORT_IMAGE_GENERATION) +#if SUPPORT_IMAGE_GENERATION // Generate image: linear gradient // The direction value specifies the direction of the gradient (in degrees) // with 0 being vertical (from top to bottom), 90 being horizontal (from left to right) @@ -1449,7 +1449,7 @@ void ImageFormat(Image *image, int newFormat) if (image->mipmaps > 1) { image->mipmaps = 1; - #if defined(SUPPORT_IMAGE_MANIPULATION) + #if SUPPORT_IMAGE_MANIPULATION if (image->data != NULL) ImageMipmaps(image); #endif } @@ -1462,7 +1462,7 @@ void ImageFormat(Image *image, int newFormat) Image ImageText(const char *text, int fontSize, Color color) { Image imText = { 0 }; -#if defined(SUPPORT_MODULE_RTEXT) +#if SUPPORT_MODULE_RTEXT int defaultFontSize = 10; // Default Font chars height in pixel if (fontSize < defaultFontSize) fontSize = defaultFontSize; int spacing = fontSize/defaultFontSize; @@ -1479,7 +1479,7 @@ Image ImageText(const char *text, int fontSize, Color color) Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint) { Image imText = { 0 }; -#if defined(SUPPORT_MODULE_RTEXT) +#if SUPPORT_MODULE_RTEXT int size = (int)strlen(text); // Get size in bytes of text int textOffsetX = 0; // Image drawing position X @@ -1869,7 +1869,7 @@ void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, i } } -#if defined(SUPPORT_IMAGE_MANIPULATION) +#if SUPPORT_IMAGE_MANIPULATION // Convert image to POT (power-of-two) // NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5) void ImageToPOT(Image *image, Color fill) @@ -4068,7 +4068,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color // Draw text (default font) within an image (destination) void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color) { -#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) +#if SUPPORT_MODULE_RTEXT && SUPPORT_DEFAULT_FONT // Make sure default font is loaded to be used on image text drawing if (GetFontDefault().texture.id == 0) LoadFontDefault(); diff --git a/src/utils.c b/src/utils.c index c5d9748d483c..4feb7960c74f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -104,7 +104,7 @@ void SetTraceLogLevel(int logType) { logTypeLevel = logType; } // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG) void TraceLog(int logType, const char *text, ...) { -#if defined(SUPPORT_TRACELOG) +#if SUPPORT_TRACELOG // Message has level below current threshold, don't emit if (logType < logTypeLevel) return; @@ -191,7 +191,7 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize) data = loadFileData(fileName, dataSize); return data; } -#if defined(SUPPORT_STANDARD_FILEIO) +#if SUPPORT_STANDARD_FILEIO FILE *file = fopen(fileName, "rb"); if (file != NULL) @@ -261,7 +261,7 @@ bool SaveFileData(const char *fileName, void *data, int dataSize) { return saveFileData(fileName, data, dataSize); } -#if defined(SUPPORT_STANDARD_FILEIO) +#if SUPPORT_STANDARD_FILEIO FILE *file = fopen(fileName, "wb"); if (file != NULL) @@ -353,7 +353,7 @@ char *LoadFileText(const char *fileName) text = loadFileText(fileName); return text; } -#if defined(SUPPORT_STANDARD_FILEIO) +#if SUPPORT_STANDARD_FILEIO FILE *file = fopen(fileName, "rt"); if (file != NULL) @@ -415,7 +415,7 @@ bool SaveFileText(const char *fileName, char *text) { return saveFileText(fileName, text); } -#if defined(SUPPORT_STANDARD_FILEIO) +#if SUPPORT_STANDARD_FILEIO FILE *file = fopen(fileName, "wt"); if (file != NULL) diff --git a/src/utils.h b/src/utils.h index 23eca8ee9f98..07bcd785ffef 100644 --- a/src/utils.h +++ b/src/utils.h @@ -32,10 +32,10 @@ #include // Required for: AAssetManager #endif -#if defined(SUPPORT_TRACELOG) +#if SUPPORT_TRACELOG #define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__) - #if defined(SUPPORT_TRACELOG_DEBUG) + #if SUPPORT_TRACELOG_DEBUG #define TRACELOGD(...) TraceLog(LOG_DEBUG, __VA_ARGS__) #else #define TRACELOGD(...) (void)0 From dc67268dfa766b5f12038f6474891b37e1fa3a45 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Tue, 24 Dec 2024 10:39:47 -0800 Subject: [PATCH 2/2] Convert to new config define format --- src/rtextures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtextures.c b/src/rtextures.c index 40fc4c1ec782..f080be424dc7 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -4204,7 +4204,7 @@ TextureCubemap LoadTextureCubemap(Image image, int layout) ImageFormat(&faces, image.format); Image mipmapped = ImageCopy(image); - #if defined(SUPPORT_IMAGE_MANIPULATION) + #if SUPPORT_IMAGE_MANIPULATION ImageMipmaps(&mipmapped); ImageMipmaps(&faces); #endif