WARNING: BREAKING: REDESIGNED: raylib build features config system #4411 #4554

Redesigned to support disabling features on compilation with `-DSUPPORT_FEATURE=0`
REMOVED: `SUPPORT_DEFAULT_FONT`, always supported
REMOVED: `SUPPORT_IMAGE_MANIPULATION `, always supported
REMOVED: `SUPPORT_TEXT_MANIPULATION`, always supported
REDESIGNED: `SUPPORT_FONT_ATLAS_WHITE_REC` to `FONT_ATLAS_CORNER_REC_SIZE`
REVIEWED: Config values (other than 0-1) are already defined on respective modules
Other config tweaks here and there
This commit is contained in:
Ray
2026-02-26 08:19:28 +01:00
parent 304e489edd
commit 5361265a7d
17 changed files with 646 additions and 646 deletions

View File

@ -2,7 +2,9 @@
* *
* raylib configuration flags * raylib configuration flags
* *
* This file defines all the configuration flags for the different raylib modules * This file defines the configuration flags for different raylib features per-module
*
* NOTE: Additional values are configured per-module and can be set on compile time
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
@ -28,288 +30,342 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
#if !defined(EXTERNAL_CONFIG_FLAGS)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module selection - Some modules could be avoided // Module selection - Some modules could be avoided
// Mandatory modules: rcore, rlgl // Mandatory modules: rcore, rlgl
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if !defined(EXTERNAL_CONFIG_FLAGS) #ifndef SUPPORT_MODULE_RSHAPES
#define SUPPORT_MODULE_RSHAPES 1 #define SUPPORT_MODULE_RSHAPES 1
#define SUPPORT_MODULE_RTEXTURES 1 #endif
#define SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures #ifndef SUPPORT_MODULE_RTEXTURES
#define SUPPORT_MODULE_RMODELS 1 #define SUPPORT_MODULE_RTEXTURES 1
#define SUPPORT_MODULE_RAUDIO 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 #endif
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: rcore - Configuration Flags // Module: rcore - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if !defined(EXTERNAL_CONFIG_FLAGS) #ifndef SUPPORT_TRACELOG
// Standard file io library (stdio.h) included // Show TRACELOG() output messages
#define SUPPORT_STANDARD_FILEIO 1 #define SUPPORT_TRACELOG 1
// Show TRACELOG() output messages #endif
#define SUPPORT_TRACELOG 1 #ifndef SUPPORT_CAMERA_SYSTEM
// Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital // Camera module is included (rcamera.h) and multiple predefined
#define SUPPORT_CAMERA_SYSTEM 1 // cameras are available: free, 1st/3rd person, orbital
// Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag #define SUPPORT_CAMERA_SYSTEM 1
#define SUPPORT_GESTURES_SYSTEM 1 #endif
// Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64 #ifndef SUPPORT_GESTURES_SYSTEM
#define SUPPORT_RPRAND_GENERATOR 1 // Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
// Mouse gestures are directly mapped like touches and processed by gestures system #define SUPPORT_GESTURES_SYSTEM 1
#define SUPPORT_MOUSE_GESTURES 1 #endif
// Reconfigure standard input to receive key inputs, works with SSH connection #ifndef SUPPORT_RPRAND_GENERATOR
#define SUPPORT_SSH_KEYBOARD_RPI 1 // Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions #define SUPPORT_RPRAND_GENERATOR 1
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often #endif
#define SUPPORT_WINMM_HIGHRES_TIMER 1 #ifndef SUPPORT_MOUSE_GESTURES
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used // Mouse gestures are directly mapped like touches and processed by gestures system
//#define SUPPORT_BUSY_WAIT_LOOP 1 #define SUPPORT_MOUSE_GESTURES 1
// 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 #endif
#define SUPPORT_PARTIALBUSY_WAIT_LOOP 1 #ifndef SUPPORT_SSH_KEYBOARD_RPI
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback() // Reconfigure standard input to receive key inputs, works with SSH connection
// WARNING: It also requires SUPPORT_IMAGE_EXPORT and SUPPORT_FILEFORMAT_PNG flags #define SUPPORT_SSH_KEYBOARD_RPI 1
#define SUPPORT_SCREEN_CAPTURE 1 #endif
// Support CompressData() and DecompressData() functions #ifndef SUPPORT_WINMM_HIGHRES_TIMER
#define SUPPORT_COMPRESSION_API 1 // Setting a higher resolution can improve the accuracy of time-out intervals in wait functions
// Support automatic generated events, loading and recording of those events when required // However, it can also reduce overall system performance, because the thread scheduler switches tasks more often
#define SUPPORT_AUTOMATION_EVENTS 1 #define SUPPORT_WINMM_HIGHRES_TIMER 1
// Support custom frame control, only for advanced users #endif
// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents() #if !defined(SUPPORT_BUSY_WAIT_LOOP) && !SUPPORT_PARTIALBUSY_WAIT_LOOP
// Enabling this flag allows manual control of the frame processes, use at your own risk // Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1 #define SUPPORT_BUSY_WAIT_LOOP 0 // Disabled by default
// Support for clipboard image loading #endif
// NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows) #if !defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) && !SUPPORT_BUSY_WAIT_LOOP
#define SUPPORT_CLIPBOARD_IMAGE 1 // 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
#define SUPPORT_PARTIALBUSY_WAIT_LOOP 1
#endif
#ifndef SUPPORT_SCREEN_CAPTURE
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
// WARNING: It requires SUPPORT_FILEFORMAT_PNG flag
#define SUPPORT_SCREEN_CAPTURE 1
#endif
#ifndef SUPPORT_COMPRESSION_API
// Support CompressData() and DecompressData() functions
#define SUPPORT_COMPRESSION_API 1
#endif
#ifndef SUPPORT_AUTOMATION_EVENTS
// Support automatic generated events, loading and recording of those events when required
#define SUPPORT_AUTOMATION_EVENTS 1
#endif
#ifndef SUPPORT_CUSTOM_FRAME_CONTROL
// Support custom frame control, only for advanced users
// 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 0 // Disabled by default
#endif
#ifndef SUPPORT_CLIPBOARD_IMAGE
// Support for clipboard image loading
// NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows)
// WARNING: It requires support for some additional flags:
// - SUPPORT_MODULE_RTEXTURES
// - SUPPORT_FILEFORMAT_BMP (Windows clipboard)
// - SUPPORT_FILEFORMAT_PNG (Wayland clipboard)
// - SUPPORT_FILEFORMAT_JPG
#define SUPPORT_CLIPBOARD_IMAGE 1
#endif #endif
// NOTE: Clipboard image loading requires support for some image file formats #if SUPPORT_TRACELOG
// TODO: Those defines should probably be removed from here, letting the user manage them
#if defined(SUPPORT_CLIPBOARD_IMAGE)
#ifndef SUPPORT_MODULE_RTEXTURES
#define SUPPORT_MODULE_RTEXTURES 1
#endif
#ifndef STBI_REQUIRED
#define STBI_REQUIRED
#endif
#ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows
#define SUPPORT_FILEFORMAT_BMP 1
#endif
#ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu
#define SUPPORT_FILEFORMAT_PNG 1
#endif
#ifndef SUPPORT_FILEFORMAT_JPG
#define SUPPORT_FILEFORMAT_JPG 1
#endif
#endif
#if defined(SUPPORT_TRACELOG)
#define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__) #define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__)
#else #else
#define TRACELOG(level, ...) (void)0 #define TRACELOG(level, ...) (void)0
#endif #endif
// rcore: Configuration values // rcore: Configuration values
// NOTE: Below values are alread defined inside [rcore.c] so there is no need to be
// redefined here, in case it must be done, just uncomment the required line and update
// the value; it can also be done on compilation with -DVALUE_TO_REDEFINE=128
//------------------------------------------------------------------------------------
//#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
//#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity
//#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value)
//#define MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported
//#define MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported
//#define MAX_GAMEPADS 4 // Maximum number of gamepads supported
//#define MAX_GAMEPAD_AXES 8 // Maximum number of axes supported (per gamepad)
//#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
//#define MAX_GAMEPAD_VIBRATION_TIME 2.0f // Maximum vibration time in seconds
//#define MAX_TOUCH_POINTS 10 // Maximum number of touch points supported
//#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
//#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
//#define MAX_DECOMPRESSION_SIZE 64 // Max size allocated for decompression in MB
//#define MAX_AUTOMATION_EVENTS 16384 // Maximum number of automation events to record
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity
#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value)
#define MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported
#define MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported
#define MAX_GAMEPADS 4 // Maximum number of gamepads supported
#define MAX_GAMEPAD_AXES 8 // Maximum number of axes supported (per gamepad)
#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
#define MAX_GAMEPAD_VIBRATION_TIME 2.0f // Maximum vibration time in seconds
#define MAX_TOUCH_POINTS 10 // Maximum number of touch points supported
#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
#define MAX_DECOMPRESSION_SIZE 64 // Max size allocated for decompression in MB
#define MAX_AUTOMATION_EVENTS 16384 // Maximum number of automation events to record
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: rlgl - Configuration values // Module: rlgl - Configuration values
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if !defined(EXTERNAL_CONFIG_FLAGS) #ifndef RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
//#define SUPPORT_GPU_SKINNING 1 // GPU skinning, comment if your GPU does not support more than 8 VBOs // Request OpenGL debug context (only available on OpenGL 4.3)
#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT 0
// Enable OpenGL Debug Context (only available on OpenGL 4.3) #endif
//#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT 1 // OpenGL debug context requested #ifndef RLGL_SHOW_GL_DETAILS_INFO
// Show OpenGL detailed info on initialization,
// Show OpenGL extensions and capabilities detailed logs on init // supported GL extensions and GL capabilities
//#define RLGL_SHOW_GL_DETAILS_INFO 1 // Show OpenGL detailed info on initialization (limits and extensions) #define RLGL_SHOW_GL_DETAILS_INFO 0
#endif #endif
//#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits // rlgl: Configuration values
#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) // NOTE: Below values are alread defined inside [rlgl.h] so there is no need to be
#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) // redefined here, in case it must be done, just uncomment the required line and update
#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture()) // the value; it can also be done on compilation with -DVALUE_TO_REDEFINE=128
//------------------------------------------------------------------------------------
#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack //#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits
//#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported //#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
//#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
#define RL_CULL_DISTANCE_NEAR 0.05 // Default projection matrix near cull distance //#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
#define RL_CULL_DISTANCE_FAR 4000.0 // Default projection matrix far cull distance //#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
//#define RL_CULL_DISTANCE_NEAR 0.05 // Default projection matrix near cull distance
//#define RL_CULL_DISTANCE_FAR 4000.0 // Default projection matrix far cull distance
// Default shader vertex attribute locations // Default shader vertex attribute locations
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR 3 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR 3
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT 4 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT 4
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
#if defined(SUPPORT_GPU_SKINNING) //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES 7
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES 7 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8 //#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM 9
#endif
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORMS 9
// Default shader vertex attribute/uniform names to set location points // Default shader vertex attribute/uniform names to set location points
// NOTE: When a new shader is loaded, locations are tried to be set for convenience, // NOTE: When a new shader is loaded, locations are tried to be set for convenience, looking for the names defined here
// if the following names are found in the shader, if not, it's up to the user to set locations // In case custom shader names are used, it's up to the user to set locations with GetShaderLocation*() functions
#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION //#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION
#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD //#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD
#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL //#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL
#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR //#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR
#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_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 //#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2
#define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES "vertexBoneIndices" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES //#define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEINDICES "vertexBoneIndices" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES
#define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS "vertexBoneWeights" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS //#define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS "vertexBoneWeights" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS
//#define RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCETRANSFORM "instanceTransform" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM
#define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix //#define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
#define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix //#define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
#define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix //#define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix
#define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix //#define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix
#define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)) //#define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView))
#define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (tint color, multiplied by texture color) //#define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (tint color, multiplied by texture color)
#define RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES "boneMatrices" // bone matrices //#define RL_DEFAULT_SHADER_UNIFORM_NAME_BONEMATRICES "boneMatrices" // bone matrices
#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) //#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0)
#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) //#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) //#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: rshapes - Configuration Flags // Module: rshapes - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if !defined(EXTERNAL_CONFIG_FLAGS) #ifndef SUPPORT_QUADS_DRAW_MODE
// Use QUADS instead of TRIANGLES for drawing when possible // Use QUADS instead of TRIANGLES for drawing when possible
// Some lines-based shapes could still use lines // Some lines-based shapes could still use lines
#define SUPPORT_QUADS_DRAW_MODE 1 #define SUPPORT_QUADS_DRAW_MODE 1
#endif #endif
// rshapes: Configuration values
//------------------------------------------------------------------------------------
#define SPLINE_SEGMENT_DIVISIONS 24 // Spline segments subdivisions
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: rtextures - Configuration Flags // Module: rtextures - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if !defined(EXTERNAL_CONFIG_FLAGS)
// Selected desired fileformats to be supported for image data loading // Selected desired fileformats to be supported for image data loading
#define SUPPORT_FILEFORMAT_PNG 1 #ifndef SUPPORT_FILEFORMAT_PNG
//#define SUPPORT_FILEFORMAT_BMP 1 #define SUPPORT_FILEFORMAT_PNG 1
//#define SUPPORT_FILEFORMAT_TGA 1 #endif
//#define SUPPORT_FILEFORMAT_JPG 1 #ifndef SUPPORT_FILEFORMAT_BMP
#define SUPPORT_FILEFORMAT_GIF 1 // NOTE: BMP support required for clipboard images on Windows
#define SUPPORT_FILEFORMAT_QOI 1 #define SUPPORT_FILEFORMAT_BMP 1
//#define SUPPORT_FILEFORMAT_PSD 1 #endif
#define SUPPORT_FILEFORMAT_DDS 1 #ifndef SUPPORT_FILEFORMAT_TGA
//#define SUPPORT_FILEFORMAT_HDR 1 #define SUPPORT_FILEFORMAT_TGA 0 // Disabled by default
//#define SUPPORT_FILEFORMAT_PIC 1 #endif
//#define SUPPORT_FILEFORMAT_KTX 1 #ifndef SUPPORT_FILEFORMAT_JPG
//#define SUPPORT_FILEFORMAT_ASTC 1 #define SUPPORT_FILEFORMAT_JPG 0 // Disabled by default
//#define SUPPORT_FILEFORMAT_PKM 1 #endif
//#define SUPPORT_FILEFORMAT_PVR 1 #ifndef SUPPORT_FILEFORMAT_GIF
#define SUPPORT_FILEFORMAT_GIF 1
#endif
#ifndef SUPPORT_FILEFORMAT_QOI
#define SUPPORT_FILEFORMAT_QOI 1
#endif
#ifndef SUPPORT_FILEFORMAT_PSD
#define SUPPORT_FILEFORMAT_PSD 0 // Disabled by default
#endif
#ifndef SUPPORT_FILEFORMAT_DDS
#define SUPPORT_FILEFORMAT_DDS 1
#endif
#ifndef SUPPORT_FILEFORMAT_HDR
#define SUPPORT_FILEFORMAT_HDR 0 // Disabled by default
#endif
#ifndef SUPPORT_FILEFORMAT_PIC
#define SUPPORT_FILEFORMAT_PIC 0 // Disabled by default
#endif
#ifndef SUPPORT_FILEFORMAT_KTX
#define SUPPORT_FILEFORMAT_KTX 0 // Disabled by default
#endif
#ifndef SUPPORT_FILEFORMAT_ASTC
#define SUPPORT_FILEFORMAT_ASTC 0 // Disabled by default
#endif
#ifndef SUPPORT_FILEFORMAT_PKM
#define SUPPORT_FILEFORMAT_PKM 0 // Disabled by default
#endif
#ifndef SUPPORT_FILEFORMAT_PVR
#define SUPPORT_FILEFORMAT_PVR 0 // Disabled by default
#endif
// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi) #ifndef SUPPORT_IMAGE_EXPORT
#define SUPPORT_IMAGE_EXPORT 1 // Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
// Support procedural image generation functionality (gradient, spot, perlin-noise, cellular) // NOTE: Image export requires stb_image_write.h library
#define SUPPORT_IMAGE_GENERATION 1 #define SUPPORT_IMAGE_EXPORT 1
// Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... #endif
// If not defined, still some functions are supported: ImageFormat(), ImageCrop(), ImageToPOT() #ifndef SUPPORT_IMAGE_GENERATION
#define SUPPORT_IMAGE_MANIPULATION 1 // Support procedural image generation functionality: gradient, spot, perlin-noise, cellular...
// NOTE: Perlin noise requires stb_perlin.h library
#define SUPPORT_IMAGE_GENERATION 1
#endif #endif
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: rtext - Configuration Flags // Module: rtext - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if !defined(EXTERNAL_CONFIG_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
#define SUPPORT_DEFAULT_FONT 1
// Selected desired font fileformats to be supported for loading // Selected desired font fileformats to be supported for loading
#define SUPPORT_FILEFORMAT_TTF 1 #ifndef SUPPORT_FILEFORMAT_TTF
#define SUPPORT_FILEFORMAT_FNT 1 #define SUPPORT_FILEFORMAT_TTF 1
//#define SUPPORT_FILEFORMAT_BDF 1 #endif
#ifndef SUPPORT_FILEFORMAT_FNT
// Support text management functions #define SUPPORT_FILEFORMAT_FNT 1
// If not defined, still some functions are supported: TextLength(), TextFormat() #endif
#define SUPPORT_TEXT_MANIPULATION 1 #ifndef SUPPORT_FILEFORMAT_BDF
#define SUPPORT_FILEFORMAT_BDF 0 // Disabled by default
// 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()]
#define SUPPORT_FONT_ATLAS_WHITE_REC 1
// Support conservative font atlas size estimation
//#define SUPPORT_FONT_ATLAS_SIZE_CONSERVATIVE 1
#endif #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()
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: rmodels - Configuration Flags // Module: rmodels - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if !defined(EXTERNAL_CONFIG_FLAGS)
// Selected desired model fileformats to be supported for loading // Selected desired model fileformats to be supported for loading
#define SUPPORT_FILEFORMAT_OBJ 1 #ifndef SUPPORT_FILEFORMAT_OBJ
#define SUPPORT_FILEFORMAT_MTL 1 #define SUPPORT_FILEFORMAT_OBJ 1
#define SUPPORT_FILEFORMAT_IQM 1
#define SUPPORT_FILEFORMAT_GLTF 1
#define SUPPORT_FILEFORMAT_VOX 1
#define SUPPORT_FILEFORMAT_M3D 1
// 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
#endif #endif
#ifndef SUPPORT_FILEFORMAT_MTL
// rmodels: Configuration values #define SUPPORT_FILEFORMAT_MTL 1
//------------------------------------------------------------------------------------ #endif
#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported #ifndef SUPPORT_FILEFORMAT_IQM
#define SUPPORT_FILEFORMAT_IQM 1
#ifdef SUPPORT_GPU_SKINNING #endif
// NOTE: Two additional vertex buffers required to store bone indices and bone weights #ifndef SUPPORT_FILEFORMAT_GLTF
#define MAX_MESH_VERTEX_BUFFERS 9 // Maximum vertex buffers (VBO) per mesh #define SUPPORT_FILEFORMAT_GLTF 1
#else #endif
#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh #ifndef SUPPORT_FILEFORMAT_VOX
#define SUPPORT_FILEFORMAT_VOX 1
#endif
#ifndef SUPPORT_FILEFORMAT_M3D
#define SUPPORT_FILEFORMAT_M3D 1
#endif
#ifndef SUPPORT_MESH_GENERATION
// 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
#endif
#ifndef SUPPORT_GPU_SKINNING
// GPU skinning disabled by default, some GPUs do not support more than 8 VBOs
#define SUPPORT_GPU_SKINNING 0
#endif #endif
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: raudio - Configuration Flags // Module: raudio - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#if !defined(EXTERNAL_CONFIG_FLAGS)
// Desired audio fileformats to be supported for loading // Desired audio fileformats to be supported for loading
#define SUPPORT_FILEFORMAT_WAV 1 #ifndef SUPPORT_FILEFORMAT_WAV
#define SUPPORT_FILEFORMAT_OGG 1 #define SUPPORT_FILEFORMAT_WAV 1
#define SUPPORT_FILEFORMAT_MP3 1 #endif
#define SUPPORT_FILEFORMAT_QOA 1 #ifndef SUPPORT_FILEFORMAT_OGG
//#define SUPPORT_FILEFORMAT_FLAC 1 #define SUPPORT_FILEFORMAT_OGG 1
#define SUPPORT_FILEFORMAT_XM 1 #endif
#define SUPPORT_FILEFORMAT_MOD 1 #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 // Disabled by default
#endif
#ifndef SUPPORT_FILEFORMAT_XM
#define SUPPORT_FILEFORMAT_XM 1
#endif
#ifndef SUPPORT_FILEFORMAT_MOD
#define SUPPORT_FILEFORMAT_MOD 1
#endif #endif
// raudio: Configuration values // raudio: Configuration values
// NOTE: Below values are alread defined inside [rlgl.h] so there is no need to be
// redefined here, in case it must be done, just uncomment the required line and update
// the value; it can also be done on compilation with -DVALUE_TO_REDEFINE=128
//------------------------------------------------------------------------------------
//#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)
//#define AUDIO_DEVICE_PERIOD_SIZE_IN_FRAMES 0 // Device period size (controls latency, 0 defaults to 10ms)
//#define MAX_AUDIO_BUFFER_POOL_CHANNELS 16 // Maximum number of audio pool channels
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
#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)
#define AUDIO_DEVICE_PERIOD_SIZE_IN_FRAMES 0 // Device period size (controls latency, 0 defaults to 10ms)
#define MAX_AUDIO_BUFFER_POOL_CHANNELS 16 // Maximum number of audio pool channels #endif // !EXTERNAL_CONFIG_FLAGS
#endif // CONFIG_H #endif // CONFIG_H

4
src/external/rlsw.h vendored
View File

@ -644,7 +644,7 @@ SWAPI void swBindTexture(uint32_t id);
#define SW_ARCH_RISCV #define SW_ARCH_RISCV
#endif #endif
#if defined(RLSW_USE_SIMD_INTRINSICS) #if RLSW_USE_SIMD_INTRINSICS
// Check for SIMD vector instructions // Check for SIMD vector instructions
// NOTE: Compiler is responsible to enable required flags for host device, // NOTE: Compiler is responsible to enable required flags for host device,
// supported features are detected at compiler init but varies depending on compiler // supported features are detected at compiler init but varies depending on compiler
@ -695,7 +695,7 @@ SWAPI void swBindTexture(uint32_t id);
#define SW_HAS_RVV #define SW_HAS_RVV
#include <riscv_vector.h> #include <riscv_vector.h>
#endif #endif
#endif // RLSW_USE_SIMD_INTRINSICS #endif
#ifdef __cplusplus #ifdef __cplusplus
#define SW_CURLY_INIT(name) name #define SW_CURLY_INIT(name) name

View File

@ -713,7 +713,7 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly // NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();
@ -1065,11 +1065,11 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
// Initialize hi-res timer // Initialize hi-res timer
InitTimer(); InitTimer();
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) #if SUPPORT_MODULE_RTEXT
// Load default font // Load default font
// WARNING: External function: Module required: rtext // WARNING: External function: Module required: rtext
LoadFontDefault(); 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 // 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 // WARNING: rshapes module is required, if not available, default internal white rectangle is used
Rectangle rec = GetFontDefault().recs[95]; Rectangle rec = GetFontDefault().recs[95];
@ -1085,7 +1085,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
} }
#endif #endif
#else #else
#if defined(SUPPORT_MODULE_RSHAPES) #if SUPPORT_MODULE_RSHAPES
// Set default texture and rectangle to be used for shapes drawing // Set default texture and rectangle to be used for shapes drawing
// NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8 // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
@ -1347,7 +1347,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
} }
} }
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
gestureEvent.pointCount = 0; gestureEvent.pointCount = 0;

View File

@ -65,7 +65,7 @@
#define GLFW_NATIVE_INCLUDE_NONE // To avoid some symbols re-definition in windows.h #define GLFW_NATIVE_INCLUDE_NONE // To avoid some symbols re-definition in windows.h
#include "GLFW/glfw3native.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 // NOTE: Those functions require linking with winmm library
//#pragma warning(disable: 4273) //#pragma warning(disable: 4273)
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod); __declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
@ -1048,7 +1048,7 @@ Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
#if defined(SUPPORT_CLIPBOARD_IMAGE) #if SUPPORT_CLIPBOARD_IMAGE
#if defined(_WIN32) #if defined(_WIN32)
unsigned long long int dataSize = 0; unsigned long long int dataSize = 0;
void *bmpData = NULL; void *bmpData = NULL;
@ -1062,7 +1062,7 @@ Image GetClipboardImage(void)
#else #else
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
#endif #endif
#endif // SUPPORT_CLIPBOARD_IMAGE #endif
return image; return image;
} }
@ -1202,7 +1202,7 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly // NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();
@ -1514,7 +1514,7 @@ int InitPlatform(void)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE);
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) #if RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context
#endif #endif
} }
@ -1819,7 +1819,7 @@ void ClosePlatform(void)
glfwDestroyWindow(platform.handle); glfwDestroyWindow(platform.handle);
glfwTerminate(); 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 timeEndPeriod(1); // Restore time period
#endif #endif
} }
@ -2049,7 +2049,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
CORE.Input.Mouse.currentButtonState[button] = action; CORE.Input.Mouse.currentButtonState[button] = action;
CORE.Input.Touch.currentTouchState[button] = action; CORE.Input.Touch.currentTouchState[button] = action;
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) #if SUPPORT_GESTURES_SYSTEM && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
@ -2084,7 +2084,7 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
CORE.Input.Mouse.currentPosition.y = (float)y; CORE.Input.Mouse.currentPosition.y = (float)y;
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) #if SUPPORT_GESTURES_SYSTEM && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };

View File

@ -423,7 +423,6 @@ void *SDL_GetClipboardData(const char *mime_type, size_t *size)
// We could possibly implement it ourselves in this case for some easier platforms // We could possibly implement it ourselves in this case for some easier platforms
return NULL; return NULL;
} }
#endif // USING_VERSION_SDL3 #endif // USING_VERSION_SDL3
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -1163,7 +1162,7 @@ Image GetClipboardImage(void)
{ {
Image image = { 0 }; Image image = { 0 };
#if defined(SUPPORT_CLIPBOARD_IMAGE) #if SUPPORT_CLIPBOARD_IMAGE
// Let's hope compiler put these arrays in static memory // Let's hope compiler put these arrays in static memory
const char *imageFormats[] = { const char *imageFormats[] = {
"image/bmp", "image/bmp",
@ -1350,7 +1349,7 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly // NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();
@ -1892,7 +1891,7 @@ void PollInputEvents(void)
default: break; default: break;
} }
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
if (touchAction > -1) if (touchAction > -1)
{ {
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
@ -1989,7 +1988,7 @@ int InitPlatform(void)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) #if RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); // Enable OpenGL Debug Context SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); // Enable OpenGL Debug Context
#endif #endif
} }
@ -2113,7 +2112,7 @@ int InitPlatform(void)
// NOTE: No need to call InitTimer(), let SDL manage it internally // NOTE: No need to call InitTimer(), let SDL manage it internally
CORE.Time.previous = GetTime(); // Get time as double 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() SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "1"); // SDL equivalent of timeBeginPeriod() and timeEndPeriod()
#endif #endif
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -80,7 +80,7 @@
#include <errno.h> // Required for: EBUSY, EAGAIN #include <errno.h> // Required for: EBUSY, EAGAIN
#define MAX_DRM_CACHED_BUFFERS 3 #define MAX_DRM_CACHED_BUFFERS 3
#endif // SUPPORT_DRM_CACHE #endif
#ifndef EGL_OPENGL_ES3_BIT #ifndef EGL_OPENGL_ES3_BIT
#define EGL_OPENGL_ES3_BIT 0x40 #define EGL_OPENGL_ES3_BIT 0x40
@ -160,7 +160,7 @@ static FramebufferCache fbCache[MAX_DRM_CACHED_BUFFERS] = { 0 };
static volatile int fbCacheCount = 0; static volatile int fbCacheCount = 0;
static volatile bool pendingFlip = false; static volatile bool pendingFlip = false;
static bool crtcSet = false; static bool crtcSet = false;
#endif // SUPPORT_DRM_CACHE #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
@ -253,7 +253,7 @@ static const short linuxToRaylibMap[KEYMAP_SIZE] = {
int InitPlatform(void); // Initialize platform (graphics, inputs and more) int InitPlatform(void); // Initialize platform (graphics, inputs and more)
void ClosePlatform(void); // Close platform 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 InitKeyboard(void); // Initialize raw keyboard system
static void RestoreKeyboard(void); // Restore keyboard system static void RestoreKeyboard(void); // Restore keyboard system
static void ProcessKeyboard(void); // Process keyboard events static void ProcessKeyboard(void); // Process keyboard events
@ -1065,7 +1065,7 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly // NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();
@ -1088,7 +1088,7 @@ void PollInputEvents(void)
PollKeyboardEvents(); 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 // 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 // stdin reading is still used for legacy purposes, it allows keyboard input trough SSH console
if (!platform.eventKeyboardMode) ProcessKeyboard(); if (!platform.eventKeyboardMode) ProcessKeyboard();
@ -1621,7 +1621,7 @@ int InitPlatform(void)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
InitEvdevInput(); // Evdev inputs initialization InitEvdevInput(); // Evdev inputs initialization
#if defined(SUPPORT_SSH_KEYBOARD_RPI) #if SUPPORT_SSH_KEYBOARD_RPI
InitKeyboard(); // Keyboard init (stdin) InitKeyboard(); // Keyboard init (stdin)
#endif #endif
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1741,7 +1741,7 @@ void ClosePlatform(void)
} }
} }
#if defined(SUPPORT_SSH_KEYBOARD_RPI) #if SUPPORT_SSH_KEYBOARD_RPI
// Initialize Keyboard system (using standard input) // Initialize Keyboard system (using standard input)
static void InitKeyboard(void) static void InitKeyboard(void)
{ {
@ -1900,7 +1900,7 @@ static void ProcessKeyboard(void)
} }
} }
} }
#endif // SUPPORT_SSH_KEYBOARD_RPI #endif // SUPPORT_SSH_KEYBOARD_RPI
// Initialize user input from evdev(/dev/input/event<N>) // Initialize user input from evdev(/dev/input/event<N>)
// this means mouse, keyboard or gamepad devices // this means mouse, keyboard or gamepad devices
@ -2196,7 +2196,7 @@ static void PollKeyboardEvents(void)
// Check if the event is a key event // Check if the event is a key event
if (event.type != EV_KEY) continue; 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 // If the event was a key, we know a working keyboard is connected, so disable the SSH keyboard
platform.eventKeyboardMode = true; platform.eventKeyboardMode = true;
#endif #endif
@ -2552,7 +2552,7 @@ static void PollMouseEvents(void)
CORE.Input.Touch.pointId[i] = -1; CORE.Input.Touch.pointId[i] = -1;
} }
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
if (touchAction > -1) if (touchAction > -1)
{ {
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };

View File

@ -435,7 +435,7 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly // NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();

View File

@ -1007,7 +1007,7 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly // NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();
@ -1210,7 +1210,7 @@ int InitPlatform(void)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE);
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) #if RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context
#endif #endif
} }
@ -1475,15 +1475,15 @@ static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float s
// GLFW3: Called on windows minimized/restored // GLFW3: Called on windows minimized/restored
static void WindowIconifyCallback(GLFWwindow *window, int iconified) static void WindowIconifyCallback(GLFWwindow *window, int iconified)
{ {
if (iconified) FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was iconified if (iconified) FLAG_SET(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was iconified
else FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was restored else FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_MINIMIZED); // The window was restored
} }
// GLFW3: Called on windows get/lose focus // GLFW3: Called on windows get/lose focus
static void WindowFocusCallback(GLFWwindow *window, int focused) static void WindowFocusCallback(GLFWwindow *window, int focused)
{ {
if (focused) FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); // The window was focused if (focused) FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); // The window was focused
else FLAG_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); // The window lost focus else FLAG_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); // The window lost focus
} }
// GLFW3: Called on file-drop over the window // GLFW3: Called on file-drop over the window
@ -1564,7 +1564,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
CORE.Input.Mouse.currentButtonState[button] = action; CORE.Input.Mouse.currentButtonState[button] = action;
CORE.Input.Touch.currentTouchState[button] = action; CORE.Input.Touch.currentTouchState[button] = action;
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) #if SUPPORT_GESTURES_SYSTEM && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
@ -1605,7 +1605,7 @@ static void MouseMoveCallback(GLFWwindow *window, double x, double y)
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
} }
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) #if SUPPORT_GESTURES_SYSTEM && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
@ -1748,7 +1748,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.position[0].y; CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.position[0].y;
} }
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
gestureEvent.pointCount = CORE.Input.Touch.pointCount; gestureEvent.pointCount = CORE.Input.Touch.pointCount;

View File

@ -983,7 +983,7 @@ const char *GetKeyName(int key)
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
// NOTE: Gestures update must be called every frame to reset gestures correctly // NOTE: Gestures update must be called every frame to reset gestures correctly
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();
@ -1321,7 +1321,7 @@ static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent
switch (eventType) switch (eventType)
{ {
case EMSCRIPTEN_EVENT_BLUR: FLAG_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); break; // The canvas lost focus case EMSCRIPTEN_EVENT_BLUR: FLAG_SET(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); break;
case EMSCRIPTEN_EVENT_FOCUS: FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); break; case EMSCRIPTEN_EVENT_FOCUS: FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_UNFOCUSED); break;
default: consumed = 0; break; default: consumed = 0; break;
} }
@ -1457,7 +1457,7 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
default: break; default: break;
} }
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) #if SUPPORT_GESTURES_SYSTEM && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
@ -1529,7 +1529,7 @@ static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseE
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
} }
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) #if SUPPORT_GESTURES_SYSTEM && defined(SUPPORT_MOUSE_GESTURES)
// Process mouse events as touches to be able to use mouse-gestures // Process mouse events as touches to be able to use mouse-gestures
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
@ -1639,7 +1639,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.position[0].y; CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.position[0].y;
} }
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
GestureEvent gestureEvent = { 0 }; GestureEvent gestureEvent = { 0 };
gestureEvent.pointCount = CORE.Input.Touch.pointCount; gestureEvent.pointCount = CORE.Input.Touch.pointCount;

View File

@ -77,7 +77,7 @@
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#endif #endif
#if defined(SUPPORT_MODULE_RAUDIO) || defined(RAUDIO_STANDALONE) #if SUPPORT_MODULE_RAUDIO || defined(RAUDIO_STANDALONE)
#if defined(_WIN32) #if defined(_WIN32)
// To avoid conflicting windows.h symbols with raylib, some flags are defined // To avoid conflicting windows.h symbols with raylib, some flags are defined
@ -205,7 +205,7 @@ typedef struct tagBITMAPINFOHEADER {
#endif #endif
#endif #endif
#if defined(SUPPORT_FILEFORMAT_WAV) #if SUPPORT_FILEFORMAT_WAV
#define DRWAV_MALLOC RL_MALLOC #define DRWAV_MALLOC RL_MALLOC
#define DRWAV_REALLOC RL_REALLOC #define DRWAV_REALLOC RL_REALLOC
#define DRWAV_FREE RL_FREE #define DRWAV_FREE RL_FREE
@ -214,12 +214,12 @@ typedef struct tagBITMAPINFOHEADER {
#include "external/dr_wav.h" // WAV loading functions #include "external/dr_wav.h" // WAV loading functions
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if SUPPORT_FILEFORMAT_OGG
// TODO: Remap stb_vorbis malloc()/free() calls to RL_MALLOC/RL_FREE // TODO: Remap stb_vorbis malloc()/free() calls to RL_MALLOC/RL_FREE
#include "external/stb_vorbis.c" // OGG loading functions #include "external/stb_vorbis.c" // OGG loading functions
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if SUPPORT_FILEFORMAT_MP3
#define DRMP3_MALLOC RL_MALLOC #define DRMP3_MALLOC RL_MALLOC
#define DRMP3_REALLOC RL_REALLOC #define DRMP3_REALLOC RL_REALLOC
#define DRMP3_FREE RL_FREE #define DRMP3_FREE RL_FREE
@ -228,7 +228,7 @@ typedef struct tagBITMAPINFOHEADER {
#include "external/dr_mp3.h" // MP3 loading functions #include "external/dr_mp3.h" // MP3 loading functions
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
#define QOA_MALLOC RL_MALLOC #define QOA_MALLOC RL_MALLOC
#define QOA_FREE RL_FREE #define QOA_FREE RL_FREE
@ -248,7 +248,7 @@ typedef struct tagBITMAPINFOHEADER {
#endif #endif
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if SUPPORT_FILEFORMAT_FLAC
#define DRFLAC_MALLOC RL_MALLOC #define DRFLAC_MALLOC RL_MALLOC
#define DRFLAC_REALLOC RL_REALLOC #define DRFLAC_REALLOC RL_REALLOC
#define DRFLAC_FREE RL_FREE #define DRFLAC_FREE RL_FREE
@ -258,7 +258,7 @@ typedef struct tagBITMAPINFOHEADER {
#include "external/dr_flac.h" // FLAC loading functions #include "external/dr_flac.h" // FLAC loading functions
#endif #endif
#if defined(SUPPORT_FILEFORMAT_XM) #if SUPPORT_FILEFORMAT_XM
#define JARXM_MALLOC RL_MALLOC #define JARXM_MALLOC RL_MALLOC
#define JARXM_FREE RL_FREE #define JARXM_FREE RL_FREE
@ -275,7 +275,7 @@ typedef struct tagBITMAPINFOHEADER {
#endif #endif
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MOD) #if SUPPORT_FILEFORMAT_MOD
#define JARMOD_MALLOC RL_MALLOC #define JARMOD_MALLOC RL_MALLOC
#define JARMOD_FREE RL_FREE #define JARMOD_FREE RL_FREE
@ -813,7 +813,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
Wave wave = { 0 }; Wave wave = { 0 };
if (false) { } if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV) #if SUPPORT_FILEFORMAT_WAV
else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0)) else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0))
{ {
drwav wav = { 0 }; drwav wav = { 0 };
@ -835,7 +835,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
drwav_uninit(&wav); drwav_uninit(&wav);
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if SUPPORT_FILEFORMAT_OGG
else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0)) else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0))
{ {
stb_vorbis *oggData = stb_vorbis_open_memory((unsigned char *)fileData, dataSize, NULL, NULL); stb_vorbis *oggData = stb_vorbis_open_memory((unsigned char *)fileData, dataSize, NULL, NULL);
@ -857,7 +857,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
else TRACELOG(LOG_WARNING, "WAVE: Failed to load OGG data"); else TRACELOG(LOG_WARNING, "WAVE: Failed to load OGG data");
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if SUPPORT_FILEFORMAT_MP3
else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0)) else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0))
{ {
drmp3_config config = { 0 }; drmp3_config config = { 0 };
@ -877,7 +877,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0)) else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0))
{ {
qoa_desc qoa = { 0 }; qoa_desc qoa = { 0 };
@ -896,7 +896,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if SUPPORT_FILEFORMAT_FLAC
else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0)) else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0))
{ {
unsigned long long int totalFrameCount = 0; unsigned long long int totalFrameCount = 0;
@ -1078,7 +1078,7 @@ bool ExportWave(Wave wave, const char *fileName)
bool success = false; bool success = false;
if (false) { } if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV) #if SUPPORT_FILEFORMAT_WAV
else if (IsFileExtension(fileName, ".wav")) else if (IsFileExtension(fileName, ".wav"))
{ {
drwav wav = { 0 }; drwav wav = { 0 };
@ -1101,7 +1101,7 @@ bool ExportWave(Wave wave, const char *fileName)
drwav_free(fileData, NULL); drwav_free(fileData, NULL);
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
else if (IsFileExtension(fileName, ".qoa")) else if (IsFileExtension(fileName, ".qoa"))
{ {
if (wave.sampleSize == 16) if (wave.sampleSize == 16)
@ -1359,7 +1359,7 @@ Music LoadMusicStream(const char *fileName)
bool musicLoaded = false; bool musicLoaded = false;
if (false) { } if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV) #if SUPPORT_FILEFORMAT_WAV
else if (IsFileExtension(fileName, ".wav")) else if (IsFileExtension(fileName, ".wav"))
{ {
drwav *ctxWav = (drwav *)RL_CALLOC(1, sizeof(drwav)); drwav *ctxWav = (drwav *)RL_CALLOC(1, sizeof(drwav));
@ -1383,7 +1383,7 @@ Music LoadMusicStream(const char *fileName)
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if SUPPORT_FILEFORMAT_OGG
else if (IsFileExtension(fileName, ".ogg")) else if (IsFileExtension(fileName, ".ogg"))
{ {
// Open ogg audio stream // Open ogg audio stream
@ -1409,7 +1409,7 @@ Music LoadMusicStream(const char *fileName)
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if SUPPORT_FILEFORMAT_MP3
else if (IsFileExtension(fileName, ".mp3")) else if (IsFileExtension(fileName, ".mp3"))
{ {
drmp3 *ctxMp3 = (drmp3 *)RL_CALLOC(1, sizeof(drmp3)); drmp3 *ctxMp3 = (drmp3 *)RL_CALLOC(1, sizeof(drmp3));
@ -1430,7 +1430,7 @@ Music LoadMusicStream(const char *fileName)
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
else if (IsFileExtension(fileName, ".qoa")) else if (IsFileExtension(fileName, ".qoa"))
{ {
qoaplay_desc *ctxQoa = qoaplay_open(fileName); qoaplay_desc *ctxQoa = qoaplay_open(fileName);
@ -1449,7 +1449,7 @@ Music LoadMusicStream(const char *fileName)
else{} //No uninit required else{} //No uninit required
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if SUPPORT_FILEFORMAT_FLAC
else if (IsFileExtension(fileName, ".flac")) else if (IsFileExtension(fileName, ".flac"))
{ {
drflac *ctxFlac = drflac_open_file(fileName, NULL); drflac *ctxFlac = drflac_open_file(fileName, NULL);
@ -1471,7 +1471,7 @@ Music LoadMusicStream(const char *fileName)
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_XM) #if SUPPORT_FILEFORMAT_XM
else if (IsFileExtension(fileName, ".xm")) else if (IsFileExtension(fileName, ".xm"))
{ {
jar_xm_context_t *ctxXm = NULL; jar_xm_context_t *ctxXm = NULL;
@ -1500,7 +1500,7 @@ Music LoadMusicStream(const char *fileName)
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MOD) #if SUPPORT_FILEFORMAT_MOD
else if (IsFileExtension(fileName, ".mod")) else if (IsFileExtension(fileName, ".mod"))
{ {
jar_mod_context_t *ctxMod = (jar_mod_context_t *)RL_CALLOC(1, sizeof(jar_mod_context_t)); jar_mod_context_t *ctxMod = (jar_mod_context_t *)RL_CALLOC(1, sizeof(jar_mod_context_t));
@ -1551,7 +1551,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
bool musicLoaded = false; bool musicLoaded = false;
if (false) { } if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV) #if SUPPORT_FILEFORMAT_WAV
else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0)) else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0))
{ {
drwav *ctxWav = (drwav *)RL_CALLOC(1, sizeof(drwav)); drwav *ctxWav = (drwav *)RL_CALLOC(1, sizeof(drwav));
@ -1577,7 +1577,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if SUPPORT_FILEFORMAT_OGG
else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0)) else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0))
{ {
// Open ogg audio stream // Open ogg audio stream
@ -1603,7 +1603,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if SUPPORT_FILEFORMAT_MP3
else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0)) else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0))
{ {
drmp3 *ctxMp3 = (drmp3 *)RL_CALLOC(1, sizeof(drmp3)); drmp3 *ctxMp3 = (drmp3 *)RL_CALLOC(1, sizeof(drmp3));
@ -1625,7 +1625,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0)) else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0))
{ {
qoaplay_desc *ctxQoa = NULL; qoaplay_desc *ctxQoa = NULL;
@ -1648,7 +1648,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
else{} //No uninit required else{} //No uninit required
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if SUPPORT_FILEFORMAT_FLAC
else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0)) else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0))
{ {
drflac *ctxFlac = drflac_open_memory((const void *)data, dataSize, NULL); drflac *ctxFlac = drflac_open_memory((const void *)data, dataSize, NULL);
@ -1670,7 +1670,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_XM) #if SUPPORT_FILEFORMAT_XM
else if ((strcmp(fileType, ".xm") == 0) || (strcmp(fileType, ".XM") == 0)) else if ((strcmp(fileType, ".xm") == 0) || (strcmp(fileType, ".XM") == 0))
{ {
jar_xm_context_t *ctxXm = NULL; jar_xm_context_t *ctxXm = NULL;
@ -1699,7 +1699,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MOD) #if SUPPORT_FILEFORMAT_MOD
else if ((strcmp(fileType, ".mod") == 0) || (strcmp(fileType, ".MOD") == 0)) 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)); jar_mod_context_t *ctxMod = (jar_mod_context_t *)RL_MALLOC(sizeof(jar_mod_context_t));
@ -1775,25 +1775,25 @@ void UnloadMusicStream(Music music)
if (music.ctxData != NULL) if (music.ctxData != NULL)
{ {
if (false) { } if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV) #if SUPPORT_FILEFORMAT_WAV
else if (music.ctxType == MUSIC_AUDIO_WAV) drwav_uninit((drwav *)music.ctxData); else if (music.ctxType == MUSIC_AUDIO_WAV) drwav_uninit((drwav *)music.ctxData);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if SUPPORT_FILEFORMAT_OGG
else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData); else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData);
#endif #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); } else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData); else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if SUPPORT_FILEFORMAT_FLAC
else if (music.ctxType == MUSIC_AUDIO_FLAC) { drflac_close((drflac *)music.ctxData); drflac_free((drflac *)music.ctxData, NULL); } else if (music.ctxType == MUSIC_AUDIO_FLAC) { drflac_close((drflac *)music.ctxData); drflac_free((drflac *)music.ctxData, NULL); }
#endif #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); else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData);
#endif #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); } else if (music.ctxType == MUSIC_MODULE_MOD) { jar_mod_unload((jar_mod_context_t *)music.ctxData); RL_FREE(music.ctxData); }
#endif #endif
} }
@ -1824,25 +1824,25 @@ void StopMusicStream(Music music)
switch (music.ctxType) 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; case MUSIC_AUDIO_WAV: drwav_seek_to_first_pcm_frame((drwav *)music.ctxData); break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if SUPPORT_FILEFORMAT_OGG
case MUSIC_AUDIO_OGG: stb_vorbis_seek_start((stb_vorbis *)music.ctxData); break; case MUSIC_AUDIO_OGG: stb_vorbis_seek_start((stb_vorbis *)music.ctxData); break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if SUPPORT_FILEFORMAT_MP3
case MUSIC_AUDIO_MP3: drmp3_seek_to_start_of_stream((drmp3 *)music.ctxData); break; case MUSIC_AUDIO_MP3: drmp3_seek_to_start_of_stream((drmp3 *)music.ctxData); break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
case MUSIC_AUDIO_QOA: qoaplay_rewind((qoaplay_desc *)music.ctxData); break; case MUSIC_AUDIO_QOA: qoaplay_rewind((qoaplay_desc *)music.ctxData); break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if SUPPORT_FILEFORMAT_FLAC
case MUSIC_AUDIO_FLAC: drflac__seek_to_first_frame((drflac *)music.ctxData); break; case MUSIC_AUDIO_FLAC: drflac__seek_to_first_frame((drflac *)music.ctxData); break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_XM) #if SUPPORT_FILEFORMAT_XM
case MUSIC_MODULE_XM: jar_xm_reset((jar_xm_context_t *)music.ctxData); break; case MUSIC_MODULE_XM: jar_xm_reset((jar_xm_context_t *)music.ctxData); break;
#endif #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; case MUSIC_MODULE_MOD: jar_mod_seek_start((jar_mod_context_t *)music.ctxData); break;
#endif #endif
default: break; default: break;
@ -1859,16 +1859,16 @@ void SeekMusicStream(Music music, float position)
switch (music.ctxType) 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; case MUSIC_AUDIO_WAV: drwav_seek_to_pcm_frame((drwav *)music.ctxData, positionInFrames); break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if SUPPORT_FILEFORMAT_OGG
case MUSIC_AUDIO_OGG: stb_vorbis_seek_frame((stb_vorbis *)music.ctxData, positionInFrames); break; case MUSIC_AUDIO_OGG: stb_vorbis_seek_frame((stb_vorbis *)music.ctxData, positionInFrames); break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if SUPPORT_FILEFORMAT_MP3
case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break; case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
case MUSIC_AUDIO_QOA: case MUSIC_AUDIO_QOA:
{ {
int qoaFrame = positionInFrames/QOA_FRAME_LEN; int qoaFrame = positionInFrames/QOA_FRAME_LEN;
@ -1878,7 +1878,7 @@ void SeekMusicStream(Music music, float position)
positionInFrames = ((qoaplay_desc *)music.ctxData)->sample_position; positionInFrames = ((qoaplay_desc *)music.ctxData)->sample_position;
} break; } break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if SUPPORT_FILEFORMAT_FLAC
case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break; case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break;
#endif #endif
default: break; default: break;
@ -1942,7 +1942,7 @@ void UpdateMusicStream(Music music)
switch (music.ctxType) switch (music.ctxType)
{ {
#if defined(SUPPORT_FILEFORMAT_WAV) #if SUPPORT_FILEFORMAT_WAV
case MUSIC_AUDIO_WAV: case MUSIC_AUDIO_WAV:
{ {
if (music.stream.sampleSize == 16) if (music.stream.sampleSize == 16)
@ -1969,7 +1969,7 @@ void UpdateMusicStream(Music music)
} }
} break; } break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OGG) #if SUPPORT_FILEFORMAT_OGG
case MUSIC_AUDIO_OGG: case MUSIC_AUDIO_OGG:
{ {
while (true) while (true)
@ -1982,7 +1982,7 @@ void UpdateMusicStream(Music music)
} }
} break; } break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MP3) #if SUPPORT_FILEFORMAT_MP3
case MUSIC_AUDIO_MP3: case MUSIC_AUDIO_MP3:
{ {
while (true) while (true)
@ -1995,7 +1995,7 @@ void UpdateMusicStream(Music music)
} }
} break; } break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOA) #if SUPPORT_FILEFORMAT_QOA
case MUSIC_AUDIO_QOA: case MUSIC_AUDIO_QOA:
{ {
unsigned int frameCountRead = qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)AUDIO.System.pcmBuffer, framesToStream); unsigned int frameCountRead = qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)AUDIO.System.pcmBuffer, framesToStream);
@ -2012,7 +2012,7 @@ void UpdateMusicStream(Music music)
*/ */
} break; } break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FLAC) #if SUPPORT_FILEFORMAT_FLAC
case MUSIC_AUDIO_FLAC: case MUSIC_AUDIO_FLAC:
{ {
while (true) while (true)
@ -2025,7 +2025,7 @@ void UpdateMusicStream(Music music)
} }
} break; } break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_XM) #if SUPPORT_FILEFORMAT_XM
case MUSIC_MODULE_XM: case MUSIC_MODULE_XM:
{ {
// NOTE: Internally we consider 2 channels generation, so sampleCount/2 // NOTE: Internally we consider 2 channels generation, so sampleCount/2
@ -2036,7 +2036,7 @@ void UpdateMusicStream(Music music)
} break; } break;
#endif #endif
#if defined(SUPPORT_FILEFORMAT_MOD) #if SUPPORT_FILEFORMAT_MOD
case MUSIC_MODULE_MOD: case MUSIC_MODULE_MOD:
{ {
// NOTE: 3rd parameter (nbsample) specify the number of stereo 16bits samples desired, so sampleCount/2 // NOTE: 3rd parameter (nbsample) specify the number of stereo 16bits samples desired, so sampleCount/2
@ -2094,7 +2094,7 @@ float GetMusicTimePlayed(Music music)
float secondsPlayed = 0.0f; float secondsPlayed = 0.0f;
if (music.stream.buffer != NULL) if (music.stream.buffer != NULL)
{ {
#if defined(SUPPORT_FILEFORMAT_XM) #if SUPPORT_FILEFORMAT_XM
if (music.ctxType == MUSIC_MODULE_XM) if (music.ctxType == MUSIC_MODULE_XM)
{ {
uint64_t framesPlayed = 0; uint64_t framesPlayed = 0;
@ -2952,4 +2952,4 @@ static bool SaveFileText(const char *fileName, char *text)
#undef AudioBuffer #undef AudioBuffer
#endif // SUPPORT_MODULE_RAUDIO #endif // SUPPORT_MODULE_RAUDIO

View File

@ -30,7 +30,7 @@
* #define RAYMATH_DISABLE_CPP_OPERATORS * #define RAYMATH_DISABLE_CPP_OPERATORS
* Disables C++ operator overloads for raymath types. * Disables C++ operator overloads for raymath types.
* *
* #define RAYMATH_USE_SIMD_INTRINSICS * #define RAYMATH_USE_SIMD_INTRINSICS 1
* Try to enable SIMD intrinsics for MatrixMultiply() * Try to enable SIMD intrinsics for MatrixMultiply()
* Note that users enabling it must be aware of the target platform where application will * Note that users enabling it must be aware of the target platform where application will
* run to support the selected SIMD intrinsic, for now, only SSE is supported * run to support the selected SIMD intrinsic, for now, only SSE is supported
@ -180,7 +180,7 @@ typedef struct float16 {
#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabsf() #include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabsf()
#if defined(RAYMATH_USE_SIMD_INTRINSICS) #if RAYMATH_USE_SIMD_INTRINSICS
// SIMD is used on the most costly raymath function MatrixMultiply() // SIMD is used on the most costly raymath function MatrixMultiply()
// NOTE: Only SSE intrinsics support implemented // NOTE: Only SSE intrinsics support implemented
// TODO: Consider support for other SIMD instrinsics: // TODO: Consider support for other SIMD instrinsics:
@ -3112,6 +3112,6 @@ inline const Matrix& operator *= (Matrix& lhs, const Matrix& rhs)
return lhs; return lhs;
} }
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
#endif // C++ operators #endif // C++ operators
#endif // RAYMATH_H #endif // RAYMATH_H

View File

@ -35,10 +35,6 @@
* - Memory framebuffer output, using software renderer, no OS required * - Memory framebuffer output, using software renderer, no OS required
* *
* CONFIGURATION: * CONFIGURATION:
* #define SUPPORT_DEFAULT_FONT (default)
* 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 (module: text)
*
* #define SUPPORT_CAMERA_SYSTEM * #define SUPPORT_CAMERA_SYSTEM
* Camera module is included (rcamera.h) and multiple predefined cameras are available: * Camera module is included (rcamera.h) and multiple predefined cameras are available:
* free, 1st/3rd person, orbital, custom * free, 1st/3rd person, orbital, custom
@ -126,17 +122,17 @@
#define RAYMATH_IMPLEMENTATION #define RAYMATH_IMPLEMENTATION
#include "raymath.h" // Vector2, Vector3, Quaternion and Matrix functionality #include "raymath.h" // Vector2, Vector3, Quaternion and Matrix functionality
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
#define RGESTURES_IMPLEMENTATION #define RGESTURES_IMPLEMENTATION
#include "rgestures.h" // Gestures detection functionality #include "rgestures.h" // Gestures detection functionality
#endif #endif
#if defined(SUPPORT_CAMERA_SYSTEM) #if SUPPORT_CAMERA_SYSTEM
#define RCAMERA_IMPLEMENTATION #define RCAMERA_IMPLEMENTATION
#include "rcamera.h" // Camera system functionality #include "rcamera.h" // Camera system functionality
#endif #endif
#if defined(SUPPORT_COMPRESSION_API) #if SUPPORT_COMPRESSION_API
#define SINFL_IMPLEMENTATION #define SINFL_IMPLEMENTATION
#define SINFL_NO_SIMD #define SINFL_NO_SIMD
#include "external/sinfl.h" // Deflate (RFC 1951) decompressor #include "external/sinfl.h" // Deflate (RFC 1951) decompressor
@ -145,7 +141,7 @@
#include "external/sdefl.h" // Deflate (RFC 1951) compressor #include "external/sdefl.h" // Deflate (RFC 1951) compressor
#endif #endif
#if defined(SUPPORT_RPRAND_GENERATOR) #if SUPPORT_RPRAND_GENERATOR
#define RPRAND_IMPLEMENTATION #define RPRAND_IMPLEMENTATION
#include "external/rprand.h" #include "external/rprand.h"
#endif #endif
@ -181,7 +177,7 @@
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <sys/syslimits.h> #include <sys/syslimits.h>
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#endif // OSs #endif
#define _CRT_INTERNAL_NONSTDC_NAMES 1 #define _CRT_INTERNAL_NONSTDC_NAMES 1
#include <sys/stat.h> // Required for: stat(), S_ISREG [Used in GetFileModTime(), IsFilePath()] #include <sys/stat.h> // Required for: stat(), S_ISREG [Used in GetFileModTime(), IsFilePath()]
@ -407,11 +403,11 @@ static SaveFileDataCallback saveFileData = NULL; // SaveFileText callback fun
static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback function pointer static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback function pointer
static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback function pointer static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback function pointer
#if defined(SUPPORT_SCREEN_CAPTURE) #if SUPPORT_SCREEN_CAPTURE
static int screenshotCounter = 0; // Screenshots counter static int screenshotCounter = 0; // Screenshots counter
#endif #endif
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
// Automation events type // Automation events type
typedef enum AutomationEventType { typedef enum AutomationEventType {
EVENT_NONE = 0, EVENT_NONE = 0,
@ -503,8 +499,7 @@ static bool automationEventRecording = false; // Recording automat
// Module Functions Declaration // Module Functions Declaration
// NOTE: Those functions are common for all platforms! // NOTE: Those functions are common for all platforms!
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if SUPPORT_MODULE_RTEXT
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
extern void LoadFontDefault(void); // [Module: text] Loads default font on InitWindow() extern void LoadFontDefault(void); // [Module: text] Loads default font on InitWindow()
extern void UnloadFontDefault(void); // [Module: text] Unloads default font from GPU memory extern void UnloadFontDefault(void); // [Module: text] Unloads default font from GPU memory
#endif #endif
@ -517,7 +512,7 @@ static void SetupViewport(int width, int height); // Set viewport for
static void ScanDirectoryFiles(const char *basePath, FilePathList *list, const char *filter, unsigned int expectedFileCount, bool scanSubdirs); // Scan all files and directories in a base path static void ScanDirectoryFiles(const char *basePath, FilePathList *list, const char *filter, unsigned int expectedFileCount, bool scanSubdirs); // Scan all files and directories in a base path
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
static void RecordAutomationEvent(void); // Record frame events (to internal events array) static void RecordAutomationEvent(void); // Record frame events (to internal events array)
#endif #endif
@ -526,30 +521,30 @@ static void RecordAutomationEvent(void); // Record frame events (to internal eve
__declspec(dllimport) void __stdcall Sleep(unsigned long msTimeout); // Required for: WaitTime() __declspec(dllimport) void __stdcall Sleep(unsigned long msTimeout); // Required for: WaitTime()
#endif #endif
#if !defined(SUPPORT_MODULE_RTEXT) #if !SUPPORT_MODULE_RTEXT
const char *TextFormat(const char *text, ...); // Formatting of text with variables to 'embed' const char *TextFormat(const char *text, ...); // Formatting of text with variables to 'embed'
#endif // !SUPPORT_MODULE_RTEXT #endif
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
#define PLATFORM_DESKTOP_GLFW #define PLATFORM_DESKTOP_GLFW
#endif #endif
// Using '#pragma message' because '#warning' is not adopted by MSVC // Using '#pragma message' because '#warning' is not adopted by MSVC
#if defined(SUPPORT_CLIPBOARD_IMAGE) #if SUPPORT_CLIPBOARD_IMAGE
#if !defined(SUPPORT_MODULE_RTEXTURES) #if !SUPPORT_MODULE_RTEXTURES
#pragma message ("WARNING: Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly") #pragma message ("WARNING: Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly")
#endif #endif
// It's nice to have support Bitmap on Linux as well, but not as necessary as Windows // 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") #pragma message ("WARNING: Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_FILEFORMAT_BMP, specially on Windows")
#endif #endif
// From what I've tested applications on Wayland saves images on clipboard as PNG // 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") #pragma message ("WARNING: Getting image from the clipboard might not work without SUPPORT_FILEFORMAT_PNG or SUPPORT_FILEFORMAT_JPG")
#endif #endif
#endif // SUPPORT_CLIPBOARD_IMAGE #endif
// Include platform-specific submodules // Include platform-specific submodules
#if defined(PLATFORM_DESKTOP_GLFW) #if defined(PLATFORM_DESKTOP_GLFW)
@ -653,27 +648,27 @@ void InitWindow(int width, int height, const char *title)
TRACELOG(LOG_INFO, "Supported raylib modules:"); TRACELOG(LOG_INFO, "Supported raylib modules:");
TRACELOG(LOG_INFO, " > rcore:..... loaded (mandatory)"); TRACELOG(LOG_INFO, " > rcore:..... loaded (mandatory)");
TRACELOG(LOG_INFO, " > rlgl:...... loaded (mandatory)"); TRACELOG(LOG_INFO, " > rlgl:...... loaded (mandatory)");
#if defined(SUPPORT_MODULE_RSHAPES) #if SUPPORT_MODULE_RSHAPES
TRACELOG(LOG_INFO, " > rshapes:... loaded (optional)"); TRACELOG(LOG_INFO, " > rshapes:... loaded (optional)");
#else #else
TRACELOG(LOG_INFO, " > rshapes:... not loaded (optional)"); TRACELOG(LOG_INFO, " > rshapes:... not loaded (optional)");
#endif #endif
#if defined(SUPPORT_MODULE_RTEXTURES) #if SUPPORT_MODULE_RTEXTURES
TRACELOG(LOG_INFO, " > rtextures:. loaded (optional)"); TRACELOG(LOG_INFO, " > rtextures:. loaded (optional)");
#else #else
TRACELOG(LOG_INFO, " > rtextures:. not loaded (optional)"); TRACELOG(LOG_INFO, " > rtextures:. not loaded (optional)");
#endif #endif
#if defined(SUPPORT_MODULE_RTEXT) #if SUPPORT_MODULE_RTEXT
TRACELOG(LOG_INFO, " > rtext:..... loaded (optional)"); TRACELOG(LOG_INFO, " > rtext:..... loaded (optional)");
#else #else
TRACELOG(LOG_INFO, " > rtext:..... not loaded (optional)"); TRACELOG(LOG_INFO, " > rtext:..... not loaded (optional)");
#endif #endif
#if defined(SUPPORT_MODULE_RMODELS) #if SUPPORT_MODULE_RMODELS
TRACELOG(LOG_INFO, " > rmodels:... loaded (optional)"); TRACELOG(LOG_INFO, " > rmodels:... loaded (optional)");
#else #else
TRACELOG(LOG_INFO, " > rmodels:... not loaded (optional)"); TRACELOG(LOG_INFO, " > rmodels:... not loaded (optional)");
#endif #endif
#if defined(SUPPORT_MODULE_RAUDIO) #if SUPPORT_MODULE_RAUDIO
TRACELOG(LOG_INFO, " > raudio:.... loaded (optional)"); TRACELOG(LOG_INFO, " > raudio:.... loaded (optional)");
#else #else
TRACELOG(LOG_INFO, " > raudio:.... not loaded (optional)"); TRACELOG(LOG_INFO, " > raudio:.... not loaded (optional)");
@ -712,29 +707,27 @@ void InitWindow(int width, int height, const char *title)
// Setup default viewport // Setup default viewport
SetupViewport(CORE.Window.render.width, CORE.Window.render.height); SetupViewport(CORE.Window.render.width, CORE.Window.render.height);
#if defined(SUPPORT_MODULE_RTEXT) #if SUPPORT_MODULE_RTEXT
#if defined(SUPPORT_DEFAULT_FONT) // Load default font
// Load default font // WARNING: External function: Module required: rtext
// WARNING: External function: Module required: rtext LoadFontDefault();
LoadFontDefault(); #if SUPPORT_MODULE_RSHAPES
#if defined(SUPPORT_MODULE_RSHAPES) // Set font white rectangle for shapes drawing, so shapes and text can be batched together
// 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
// WARNING: rshapes module is required, if not available, default internal white rectangle is used Rectangle rec = GetFontDefault().recs[95];
Rectangle rec = GetFontDefault().recs[95]; if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT))
if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT)) {
{ // NOTE: We try to maxime rec padding to avoid pixel bleeding on MSAA filtering
// NOTE: We try to maxime rec padding to avoid pixel bleeding on MSAA filtering SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 });
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 }); }
} else
else {
{ // NOTE: We set up a 1px padding on char rectangle to avoid pixel bleeding
// NOTE: We set up a 1px padding on char rectangle to avoid pixel bleeding SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2 });
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 1, rec.y + 1, rec.width - 2, rec.height - 2 }); }
}
#endif
#endif #endif
#else #else
#if defined(SUPPORT_MODULE_RSHAPES) #if SUPPORT_MODULE_RSHAPES
// Set default texture and rectangle to be used for shapes drawing // Set default texture and rectangle to be used for shapes drawing
// NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8 // NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 }; Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
@ -754,7 +747,7 @@ void InitWindow(int width, int height, const char *title)
// Close window and unload OpenGL context // Close window and unload OpenGL context
void CloseWindow(void) void CloseWindow(void)
{ {
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT) #if SUPPORT_MODULE_RTEXT
UnloadFontDefault(); // WARNING: Module required: rtext UnloadFontDefault(); // WARNING: Module required: rtext
#endif #endif
@ -908,11 +901,11 @@ void EndDrawing(void)
{ {
rlDrawRenderBatchActive(); // Update and draw internal render batch rlDrawRenderBatchActive(); // Update and draw internal render batch
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
if (automationEventRecording) RecordAutomationEvent(); // Event recording if (automationEventRecording) RecordAutomationEvent(); // Event recording
#endif #endif
#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL) #if !SUPPORT_CUSTOM_FRAME_CONTROL
SwapScreenBuffer(); // Copy back buffer to front buffer (screen) SwapScreenBuffer(); // Copy back buffer to front buffer (screen)
// Frame time control system // Frame time control system
@ -937,13 +930,13 @@ void EndDrawing(void)
PollInputEvents(); // Poll user events (before next frame update) PollInputEvents(); // Poll user events (before next frame update)
#endif #endif
#if defined(SUPPORT_SCREEN_CAPTURE) #if SUPPORT_SCREEN_CAPTURE
if (IsKeyPressed(KEY_F12)) if (IsKeyPressed(KEY_F12))
{ {
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter)); TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
screenshotCounter++; screenshotCounter++;
} }
#endif // SUPPORT_SCREEN_CAPTURE #endif
CORE.Time.frameCounter++; CORE.Time.frameCounter++;
} }
@ -1674,14 +1667,14 @@ void WaitTime(double seconds)
{ {
if (seconds < 0) return; // Security check 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; double destinationTime = GetTime() + seconds;
#endif #endif
#if defined(SUPPORT_BUSY_WAIT_LOOP) #if SUPPORT_BUSY_WAIT_LOOP
while (GetTime() < destinationTime) { } while (GetTime() < destinationTime) { }
#else #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 double sleepSeconds = seconds - seconds*0.05; // NOTE: We reserve a percentage of the time for busy waiting
#else #else
double sleepSeconds = seconds; double sleepSeconds = seconds;
@ -1705,7 +1698,7 @@ void WaitTime(double seconds)
usleep(sleepSeconds*1000000.0); usleep(sleepSeconds*1000000.0);
#endif #endif
#if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) #if SUPPORT_PARTIALBUSY_WAIT_LOOP
while (GetTime() < destinationTime) { } while (GetTime() < destinationTime) { }
#endif #endif
#endif #endif
@ -1721,7 +1714,7 @@ void WaitTime(double seconds)
// Set the seed for the random number generator // Set the seed for the random number generator
void SetRandomSeed(unsigned int seed) void SetRandomSeed(unsigned int seed)
{ {
#if defined(SUPPORT_RPRAND_GENERATOR) #if SUPPORT_RPRAND_GENERATOR
rprand_set_seed(seed); rprand_set_seed(seed);
#else #else
srand(seed); srand(seed);
@ -1740,7 +1733,7 @@ int GetRandomValue(int min, int max)
min = tmp; min = tmp;
} }
#if defined(SUPPORT_RPRAND_GENERATOR) #if SUPPORT_RPRAND_GENERATOR
value = rprand_get_value(min, max); value = rprand_get_value(min, max);
#else #else
// WARNING: Ranges higher than RAND_MAX will return invalid results // WARNING: Ranges higher than RAND_MAX will return invalid results
@ -1779,6 +1772,7 @@ int GetRandomValue(int min, int max)
value = min + (int)(r%m); value = min + (int)(r%m);
} }
#endif #endif
return value; return value;
} }
@ -1787,7 +1781,7 @@ int *LoadRandomSequence(unsigned int count, int min, int max)
{ {
int *values = NULL; int *values = NULL;
#if defined(SUPPORT_RPRAND_GENERATOR) #if SUPPORT_RPRAND_GENERATOR
values = rprand_load_sequence(count, min, max); values = rprand_load_sequence(count, min, max);
#else #else
if (count > ((unsigned int)abs(max - min) + 1)) return values; // Security check if (count > ((unsigned int)abs(max - min) + 1)) return values; // Security check
@ -1818,13 +1812,14 @@ int *LoadRandomSequence(unsigned int count, int min, int max)
} }
} }
#endif #endif
return values; return values;
} }
// Unload random values sequence // Unload random values sequence
void UnloadRandomSequence(int *sequence) void UnloadRandomSequence(int *sequence)
{ {
#if defined(SUPPORT_RPRAND_GENERATOR) #if SUPPORT_RPRAND_GENERATOR
rprand_unload_sequence(sequence); rprand_unload_sequence(sequence);
#else #else
RL_FREE(sequence); RL_FREE(sequence);
@ -1835,7 +1830,7 @@ void UnloadRandomSequence(int *sequence)
// NOTE: Provided fileName should not contain paths, saving to working directory // NOTE: Provided fileName should not contain paths, saving to working directory
void TakeScreenshot(const char *fileName) void TakeScreenshot(const char *fileName)
{ {
#if defined(SUPPORT_MODULE_RTEXTURES) #if SUPPORT_MODULE_RTEXTURES
// Security check to (partially) avoid malicious code // Security check to (partially) avoid malicious code
if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; } if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; }
@ -1883,7 +1878,7 @@ void SetTraceLogLevel(int logType) { logTypeLevel = logType; }
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG) // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
void TraceLog(int logType, const char *text, ...) void TraceLog(int logType, const char *text, ...)
{ {
#if defined(SUPPORT_TRACELOG) #if SUPPORT_TRACELOG
// Message has level below current threshold, don't emit // Message has level below current threshold, don't emit
if ((logType < logTypeLevel) || (text == NULL)) return; if ((logType < logTypeLevel) || (text == NULL)) return;
@ -1932,8 +1927,7 @@ void TraceLog(int logType, const char *text, ...)
va_end(args); va_end(args);
if (logType == LOG_FATAL) exit(EXIT_FAILURE); // If fatal logging, exit program if (logType == LOG_FATAL) exit(EXIT_FAILURE); // If fatal logging, exit program
#endif
#endif // SUPPORT_TRACELOG
} }
// Set custom trace log // Set custom trace log
@ -1977,12 +1971,8 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize)
if (fileName != NULL) if (fileName != NULL)
{ {
if (loadFileData) if (loadFileData) return loadFileData(fileName, dataSize);
{
data = loadFileData(fileName, dataSize);
return data;
}
#if defined(SUPPORT_STANDARD_FILEIO)
FILE *file = fopen(fileName, "rb"); FILE *file = fopen(fileName, "rb");
if (file != NULL) if (file != NULL)
@ -2026,9 +2016,6 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize)
fclose(file); fclose(file);
} }
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open file", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open file", fileName);
#else
TRACELOG(LOG_WARNING, "FILEIO: Standard file io not supported, use custom file callback");
#endif
} }
else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid"); else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid");
@ -2048,11 +2035,8 @@ bool SaveFileData(const char *fileName, void *data, int dataSize)
if (fileName != NULL) if (fileName != NULL)
{ {
if (saveFileData) if (saveFileData) return saveFileData(fileName, data, dataSize);
{
return saveFileData(fileName, data, dataSize);
}
#if defined(SUPPORT_STANDARD_FILEIO)
FILE *file = fopen(fileName, "wb"); FILE *file = fopen(fileName, "wb");
if (file != NULL) if (file != NULL)
@ -2069,9 +2053,6 @@ bool SaveFileData(const char *fileName, void *data, int dataSize)
if (result == 0) success = true; if (result == 0) success = true;
} }
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open file", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open file", fileName);
#else
TRACELOG(LOG_WARNING, "FILEIO: Standard file io not supported, use custom file callback");
#endif
} }
else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid"); else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid");
@ -2139,12 +2120,8 @@ char *LoadFileText(const char *fileName)
if (fileName != NULL) if (fileName != NULL)
{ {
if (loadFileText) if (loadFileText) return loadFileText(fileName);
{
text = loadFileText(fileName);
return text;
}
#if defined(SUPPORT_STANDARD_FILEIO)
FILE *file = fopen(fileName, "rt"); FILE *file = fopen(fileName, "rt");
if (file != NULL) if (file != NULL)
@ -2180,9 +2157,6 @@ char *LoadFileText(const char *fileName)
fclose(file); fclose(file);
} }
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open text file", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open text file", fileName);
#else
TRACELOG(LOG_WARNING, "FILEIO: Standard file io not supported, use custom file callback");
#endif
} }
else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid"); else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid");
@ -2202,11 +2176,8 @@ bool SaveFileText(const char *fileName, const char *text)
if (fileName != NULL) if (fileName != NULL)
{ {
if (saveFileText) if (saveFileText) return saveFileText(fileName, text);
{
return saveFileText(fileName, text);
}
#if defined(SUPPORT_STANDARD_FILEIO)
FILE *file = fopen(fileName, "wt"); FILE *file = fopen(fileName, "wt");
if (file != NULL) if (file != NULL)
@ -2220,9 +2191,6 @@ bool SaveFileText(const char *fileName, const char *text)
if (result == 0) success = true; if (result == 0) success = true;
} }
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open text file", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open text file", fileName);
#else
TRACELOG(LOG_WARNING, "FILEIO: Standard file io not supported, use custom file callback");
#endif
} }
else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid"); else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid");
@ -2332,7 +2300,7 @@ int FileTextReplace(const char *fileName, const char *search, const char *replac
char *fileText = NULL; char *fileText = NULL;
char *fileTextUpdated = { 0 }; char *fileTextUpdated = { 0 };
#if defined(SUPPORT_MODULE_RTEXT) #if SUPPORT_MODULE_RTEXT
if (FileExists(fileName)) if (FileExists(fileName))
{ {
fileText = LoadFileText(fileName); fileText = LoadFileText(fileName);
@ -3025,7 +2993,7 @@ unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDa
unsigned char *compData = NULL; unsigned char *compData = NULL;
#if defined(SUPPORT_COMPRESSION_API) #if SUPPORT_COMPRESSION_API
// Compress data and generate a valid DEFLATE stream // Compress data and generate a valid DEFLATE stream
struct sdefl *sdefl = (struct sdefl *)RL_CALLOC(1, sizeof(struct sdefl)); // WARNING: Possible stack overflow, struct sdefl is almost 1MB struct sdefl *sdefl = (struct sdefl *)RL_CALLOC(1, sizeof(struct sdefl)); // WARNING: Possible stack overflow, struct sdefl is almost 1MB
int bounds = sdefl_bound(dataSize); int bounds = sdefl_bound(dataSize);
@ -3045,7 +3013,7 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i
{ {
unsigned char *data = NULL; unsigned char *data = NULL;
#if defined(SUPPORT_COMPRESSION_API) #if SUPPORT_COMPRESSION_API
// Decompress data from a valid DEFLATE stream // Decompress data from a valid DEFLATE stream
unsigned char *data0 = (unsigned char *)RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1); unsigned char *data0 = (unsigned char *)RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
int size = sinflate(data0, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize); int size = sinflate(data0, MAX_DECOMPRESSION_SIZE*1024*1024, compData, compDataSize);
@ -3582,7 +3550,7 @@ AutomationEventList LoadAutomationEventList(const char *fileName)
list.events = (AutomationEvent *)RL_CALLOC(MAX_AUTOMATION_EVENTS, sizeof(AutomationEvent)); list.events = (AutomationEvent *)RL_CALLOC(MAX_AUTOMATION_EVENTS, sizeof(AutomationEvent));
list.capacity = MAX_AUTOMATION_EVENTS; 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"); if (fileName == NULL) TRACELOG(LOG_INFO, "AUTOMATION: New empty events list loaded successfully");
else else
{ {
@ -3658,7 +3626,7 @@ AutomationEventList LoadAutomationEventList(const char *fileName)
// Unload automation events list from file // Unload automation events list from file
void UnloadAutomationEventList(AutomationEventList list) void UnloadAutomationEventList(AutomationEventList list)
{ {
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
RL_FREE(list.events); RL_FREE(list.events);
#endif #endif
} }
@ -3668,7 +3636,7 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName)
{ {
bool success = false; bool success = false;
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
// Export events as binary file // Export events as binary file
// NOTE: Code not used, only for reference if required in the future // NOTE: Code not used, only for reference if required in the future
/* /*
@ -3726,7 +3694,7 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName)
// Setup automation event list to record to // Setup automation event list to record to
void SetAutomationEventList(AutomationEventList *list) void SetAutomationEventList(AutomationEventList *list)
{ {
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
currentEventList = list; currentEventList = list;
#endif #endif
} }
@ -3740,7 +3708,7 @@ void SetAutomationEventBaseFrame(int frame)
// Start recording automation events (AutomationEventList must be set) // Start recording automation events (AutomationEventList must be set)
void StartAutomationEventRecording(void) void StartAutomationEventRecording(void)
{ {
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
automationEventRecording = true; automationEventRecording = true;
#endif #endif
} }
@ -3748,7 +3716,7 @@ void StartAutomationEventRecording(void)
// Stop recording automation events // Stop recording automation events
void StopAutomationEventRecording(void) void StopAutomationEventRecording(void)
{ {
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
automationEventRecording = false; automationEventRecording = false;
#endif #endif
} }
@ -3756,7 +3724,7 @@ void StopAutomationEventRecording(void)
// Play a recorded automation event // Play a recorded automation event
void PlayAutomationEvent(AutomationEvent 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! // WARNING: When should event be played? After/before/replace PollInputEvents()? -> Up to the user!
if (!automationEventRecording) if (!automationEventRecording)
@ -3805,7 +3773,7 @@ void PlayAutomationEvent(AutomationEvent event)
{ {
CORE.Input.Gamepad.axisState[event.params[0]][event.params[1]] = ((float)event.params[2]/32768.0f); CORE.Input.Gamepad.axisState[event.params[0]][event.params[1]] = ((float)event.params[2]/32768.0f);
} break; } 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 case INPUT_GESTURE: GESTURES.current = event.params[0]; break; // param[0]: gesture (enum Gesture) -> rgestures.h: GESTURES.current
#endif #endif
// Window event // Window event
@ -3813,9 +3781,8 @@ void PlayAutomationEvent(AutomationEvent event)
case WINDOW_MAXIMIZE: MaximizeWindow(); break; case WINDOW_MAXIMIZE: MaximizeWindow(); break;
case WINDOW_MINIMIZE: MinimizeWindow(); break; case WINDOW_MINIMIZE: MinimizeWindow(); break;
case WINDOW_RESIZE: SetWindowSize(event.params[0], event.params[1]); break; case WINDOW_RESIZE: SetWindowSize(event.params[0], event.params[1]); break;
// Custom event // Custom event
#if defined(SUPPORT_SCREEN_CAPTURE) #if SUPPORT_SCREEN_CAPTURE
case ACTION_TAKE_SCREENSHOT: case ACTION_TAKE_SCREENSHOT:
{ {
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter)); TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
@ -4259,7 +4226,7 @@ void InitTimer(void)
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often // 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 // 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 // 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) timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
#endif #endif
@ -4352,7 +4319,7 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
else TRACELOG(LOG_WARNING, "FILEIO: Directory cannot be opened (%s)", basePath); // Maybe it's a file... else TRACELOG(LOG_WARNING, "FILEIO: Directory cannot be opened (%s)", basePath); // Maybe it's a file...
} }
#if defined(SUPPORT_AUTOMATION_EVENTS) #if SUPPORT_AUTOMATION_EVENTS
// Automation event recording // Automation event recording
// Checking events in current frame and save them into currentEventList // Checking events in current frame and save them into currentEventList
// NOTE: Recording is by default done at EndDrawing(), before PollInputEvents() // NOTE: Recording is by default done at EndDrawing(), before PollInputEvents()
@ -4593,7 +4560,7 @@ static void RecordAutomationEvent(void)
} }
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#if defined(SUPPORT_GESTURES_SYSTEM) #if SUPPORT_GESTURES_SYSTEM
// Gestures input currentEventList->events recording // Gestures input currentEventList->events recording
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
if (GESTURES.current != GESTURE_NONE) if (GESTURES.current != GESTURE_NONE)
@ -4655,5 +4622,4 @@ const char *TextFormat(const char *text, ...)
return currentBuffer; return currentBuffer;
} }
#endif
#endif // !SUPPORT_MODULE_RTEXT

View File

@ -1134,7 +1134,7 @@ typedef struct rlglData {
} ExtSupported; // Extensions supported flags } ExtSupported; // Extensions supported flags
} rlglData; } rlglData;
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
@ -1144,7 +1144,7 @@ static double rlCullDistanceFar = RL_CULL_DISTANCE_FAR;
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
static rlglData RLGL = { 0 }; static rlglData RLGL = { 0 };
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
static bool isGpuReady = false; static bool isGpuReady = false;
#if defined(GRAPHICS_API_OPENGL_ES2) && !defined(GRAPHICS_API_OPENGL_ES3) #if defined(GRAPHICS_API_OPENGL_ES2) && !defined(GRAPHICS_API_OPENGL_ES3)
@ -1165,10 +1165,10 @@ static PFNGLVERTEXATTRIBDIVISOREXTPROC glVertexAttribDivisor = NULL;
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
static void rlLoadShaderDefault(void); // Load default shader static void rlLoadShaderDefault(void); // Load default shader
static void rlUnloadShaderDefault(void); // Unload default shader static void rlUnloadShaderDefault(void); // Unload default shader
#if defined(RLGL_SHOW_GL_DETAILS_INFO) #if RLGL_SHOW_GL_DETAILS_INFO
static const char *rlGetCompressedFormatName(int format); // Get compressed format official GL identifier name static const char *rlGetCompressedFormatName(int format); // Get compressed format official GL identifier name
#endif // RLGL_SHOW_GL_DETAILS_INFO #endif
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 #endif
static int rlGetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes (image or texture) static int rlGetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes (image or texture)
@ -2210,7 +2210,7 @@ void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int g
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition - OpenGL Debug // Module Functions Definition - OpenGL Debug
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) && defined(GRAPHICS_API_OPENGL_43) #if defined(GRAPHICS_API_OPENGL_43) && RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) static void GLAPIENTRY rlDebugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
{ {
// Ignore non-significant error/warning codes (NVidia drivers) // Ignore non-significant error/warning codes (NVidia drivers)
@ -2276,8 +2276,8 @@ void rlglInit(int width, int height)
{ {
isGpuReady = true; isGpuReady = true;
// Enable OpenGL debug context if required // Enable OpenGL debug context if requested (and supported)
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) && defined(GRAPHICS_API_OPENGL_43) #if defined(GRAPHICS_API_OPENGL_43) && RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
if ((glDebugMessageCallback != NULL) && (glDebugMessageControl != NULL)) if ((glDebugMessageCallback != NULL) && (glDebugMessageControl != NULL))
{ {
glDebugMessageCallback(rlDebugMessageCallback, 0); glDebugMessageCallback(rlDebugMessageCallback, 0);
@ -2321,7 +2321,7 @@ void rlglInit(int width, int height)
RLGL.State.projection = rlMatrixIdentity(); RLGL.State.projection = rlMatrixIdentity();
RLGL.State.modelview = rlMatrixIdentity(); RLGL.State.modelview = rlMatrixIdentity();
RLGL.State.currentMatrix = &RLGL.State.modelview; RLGL.State.currentMatrix = &RLGL.State.modelview;
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
#if defined(GRAPHICS_API_OPENGL_11_SOFTWARE) #if defined(GRAPHICS_API_OPENGL_11_SOFTWARE)
// Initialize software renderer backend // Initialize software renderer backend
@ -2405,7 +2405,7 @@ void rlLoadExtensions(void *loader)
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt); glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt); TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt);
#if defined(RLGL_SHOW_GL_DETAILS_INFO) #if RLGL_SHOW_GL_DETAILS_INFO
// Get supported extensions list // Get supported extensions list
// WARNING: glGetStringi() not available on OpenGL 2.1 // WARNING: glGetStringi() not available on OpenGL 2.1
TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:"); TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:");
@ -2447,7 +2447,7 @@ void rlLoadExtensions(void *loader)
RLGL.ExtSupported.ssbo = GLAD_GL_ARB_shader_storage_buffer_object; RLGL.ExtSupported.ssbo = GLAD_GL_ARB_shader_storage_buffer_object;
#endif #endif
#endif // GRAPHICS_API_OPENGL_33 #endif // GRAPHICS_API_OPENGL_33
#if defined(GRAPHICS_API_OPENGL_ES3) #if defined(GRAPHICS_API_OPENGL_ES3)
// Register supported extensions flags // Register supported extensions flags
@ -2503,7 +2503,7 @@ void rlLoadExtensions(void *loader)
TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt); TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt);
#if defined(RLGL_SHOW_GL_DETAILS_INFO) #if RLGL_SHOW_GL_DETAILS_INFO
TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:"); TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:");
for (int i = 0; i < numExt; i++) TRACELOG(RL_LOG_INFO, " %s", extList[i]); for (int i = 0; i < numExt; i++) TRACELOG(RL_LOG_INFO, " %s", extList[i]);
#endif #endif
@ -2613,7 +2613,7 @@ void rlLoadExtensions(void *loader)
// Free extensions pointers // Free extensions pointers
RL_FREE(extList); RL_FREE(extList);
RL_FREE(extensionsDup); // Duplicated string must be deallocated RL_FREE(extensionsDup); // Duplicated string must be deallocated
#endif // GRAPHICS_API_OPENGL_ES2 #endif // GRAPHICS_API_OPENGL_ES2
// Check OpenGL information and capabilities // Check OpenGL information and capabilities
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -2633,7 +2633,7 @@ void rlLoadExtensions(void *loader)
#endif #endif
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &RLGL.ExtSupported.maxAnisotropyLevel); glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &RLGL.ExtSupported.maxAnisotropyLevel);
#if defined(RLGL_SHOW_GL_DETAILS_INFO) #if RLGL_SHOW_GL_DETAILS_INFO
// Show some OpenGL GPU capabilities // Show some OpenGL GPU capabilities
TRACELOG(RL_LOG_INFO, "GL: OpenGL capabilities:"); TRACELOG(RL_LOG_INFO, "GL: OpenGL capabilities:");
GLint capability = 0; GLint capability = 0;
@ -2664,8 +2664,9 @@ void rlLoadExtensions(void *loader)
TRACELOG(RL_LOG_INFO, " GL_MAX_VERTEX_ATTRIB_BINDINGS: %i", capability); TRACELOG(RL_LOG_INFO, " GL_MAX_VERTEX_ATTRIB_BINDINGS: %i", capability);
glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &capability); glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &capability);
TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_LOCATIONS: %i", capability); TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_LOCATIONS: %i", capability);
#endif // GRAPHICS_API_OPENGL_43 #endif
#else // RLGL_SHOW_GL_DETAILS_INFO
#else // !RLGL_SHOW_GL_DETAILS_INFO
// Show some basic info about GL supported features // Show some basic info about GL supported features
if (RLGL.ExtSupported.vao) TRACELOG(RL_LOG_INFO, "GL: VAO extension detected, VAO functions loaded successfully"); if (RLGL.ExtSupported.vao) TRACELOG(RL_LOG_INFO, "GL: VAO extension detected, VAO functions loaded successfully");
@ -2679,9 +2680,9 @@ void rlLoadExtensions(void *loader)
if (RLGL.ExtSupported.texCompASTC) TRACELOG(RL_LOG_INFO, "GL: ASTC compressed textures supported"); if (RLGL.ExtSupported.texCompASTC) TRACELOG(RL_LOG_INFO, "GL: ASTC compressed textures supported");
if (RLGL.ExtSupported.computeShader) TRACELOG(RL_LOG_INFO, "GL: Compute shaders supported"); if (RLGL.ExtSupported.computeShader) TRACELOG(RL_LOG_INFO, "GL: Compute shaders supported");
if (RLGL.ExtSupported.ssbo) TRACELOG(RL_LOG_INFO, "GL: Shader storage buffer objects supported"); if (RLGL.ExtSupported.ssbo) TRACELOG(RL_LOG_INFO, "GL: Shader storage buffer objects supported");
#endif // RLGL_SHOW_GL_DETAILS_INFO #endif
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
} }
// Get OpenGL procedure address // Get OpenGL procedure address
@ -3291,7 +3292,7 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
return id; return id;
} }
#endif #endif
#endif // GRAPHICS_API_OPENGL_11 #endif // GRAPHICS_API_OPENGL_11
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@ -5109,7 +5110,7 @@ static void rlUnloadShaderDefault(void)
TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Default shader unloaded successfully", RLGL.State.defaultShaderId); TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Default shader unloaded successfully", RLGL.State.defaultShaderId);
} }
#if defined(RLGL_SHOW_GL_DETAILS_INFO) #if RLGL_SHOW_GL_DETAILS_INFO
// Get compressed format official GL identifier name // Get compressed format official GL identifier name
static const char *rlGetCompressedFormatName(int format) static const char *rlGetCompressedFormatName(int format)
{ {
@ -5183,9 +5184,9 @@ static const char *rlGetCompressedFormatName(int format)
default: return "GL_COMPRESSED_UNKNOWN"; break; default: return "GL_COMPRESSED_UNKNOWN"; break;
} }
} }
#endif // RLGL_SHOW_GL_DETAILS_INFO #endif
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2 #endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
// Get pixel data size in bytes (image or texture) // Get pixel data size in bytes (image or texture)
// NOTE: Size depends on pixel format // NOTE: Size depends on pixel format
@ -5388,4 +5389,4 @@ static Matrix rlMatrixInvert(Matrix mat)
} }
#endif #endif
#endif // RLGL_IMPLEMENTATION #endif // RLGL_IMPLEMENTATION

View File

@ -44,7 +44,7 @@
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#if defined(SUPPORT_MODULE_RMODELS) #if SUPPORT_MODULE_RMODELS
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 #include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2
#include "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality #include "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality
@ -54,7 +54,7 @@
#include <string.h> // Required for: memcmp(), strlen(), strncpy() #include <string.h> // Required for: memcmp(), strlen(), strncpy()
#include <math.h> // Required for: sinf(), cosf(), sqrtf(), fabsf() #include <math.h> // 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_MALLOC RL_MALLOC
#define TINYOBJ_CALLOC RL_CALLOC #define TINYOBJ_CALLOC RL_CALLOC
#define TINYOBJ_REALLOC RL_REALLOC #define TINYOBJ_REALLOC RL_REALLOC
@ -64,7 +64,7 @@
#include "external/tinyobj_loader_c.h" // OBJ/MTL file formats loading #include "external/tinyobj_loader_c.h" // OBJ/MTL file formats loading
#endif #endif
#if defined(SUPPORT_FILEFORMAT_GLTF) #if SUPPORT_FILEFORMAT_GLTF
#define CGLTF_MALLOC RL_MALLOC #define CGLTF_MALLOC RL_MALLOC
#define CGLTF_FREE RL_FREE #define CGLTF_FREE RL_FREE
@ -72,7 +72,7 @@
#include "external/cgltf.h" // glTF file format loading #include "external/cgltf.h" // glTF file format loading
#endif #endif
#if defined(SUPPORT_FILEFORMAT_VOX) #if SUPPORT_FILEFORMAT_VOX
#define VOX_MALLOC RL_MALLOC #define VOX_MALLOC RL_MALLOC
#define VOX_CALLOC RL_CALLOC #define VOX_CALLOC RL_CALLOC
#define VOX_REALLOC RL_REALLOC #define VOX_REALLOC RL_REALLOC
@ -82,7 +82,7 @@
#include "external/vox_loader.h" // VOX file format loading (MagikaVoxel) #include "external/vox_loader.h" // VOX file format loading (MagikaVoxel)
#endif #endif
#if defined(SUPPORT_FILEFORMAT_M3D) #if SUPPORT_FILEFORMAT_M3D
#define M3D_MALLOC RL_MALLOC #define M3D_MALLOC RL_MALLOC
#define M3D_REALLOC RL_REALLOC #define M3D_REALLOC RL_REALLOC
#define M3D_FREE RL_FREE #define M3D_FREE RL_FREE
@ -91,7 +91,7 @@
#include "external/m3d.h" // Model3D file format loading #include "external/m3d.h" // Model3D file format loading
#endif #endif
#if defined(SUPPORT_MESH_GENERATION) #if SUPPORT_MESH_GENERATION
#define PAR_MALLOC(T, N) ((T *)RL_MALLOC(N*sizeof(T))) #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_CALLOC(T, N) ((T *)RL_CALLOC(N*sizeof(T), 1))
#define PAR_REALLOC(T, BUF, N) ((T *)RL_REALLOC(BUF, sizeof(T)*(N))) #define PAR_REALLOC(T, BUF, N) ((T *)RL_REALLOC(BUF, sizeof(T)*(N)))
@ -126,7 +126,13 @@
#define MAX_MATERIAL_MAPS 12 // Maximum number of maps supported #define MAX_MATERIAL_MAPS 12 // Maximum number of maps supported
#endif #endif
#ifndef MAX_MESH_VERTEX_BUFFERS #ifndef MAX_MESH_VERTEX_BUFFERS
#if SUPPORT_GPU_SKINNING
// NOTE: Two additional vertex buffers required to store bone indices and bone weights
// WARNING: Some GPUs could not support more than 8 VBOs
#define MAX_MESH_VERTEX_BUFFERS 9 // Maximum vertex buffers (VBO) per mesh #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 #endif
#ifndef MAX_FILEPATH_LENGTH #ifndef MAX_FILEPATH_LENGTH
#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value) #define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value)
@ -145,25 +151,25 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Internal Functions Declaration // Module Internal Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_OBJ) #if SUPPORT_FILEFORMAT_OBJ
static Model LoadOBJ(const char *fileName); // Load OBJ mesh data static Model LoadOBJ(const char *fileName); // Load OBJ mesh data
#endif #endif
#if defined(SUPPORT_FILEFORMAT_IQM) #if SUPPORT_FILEFORMAT_IQM
static Model LoadIQM(const char *fileName); // Load IQM mesh data static Model LoadIQM(const char *fileName); // Load IQM mesh data
static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCount); // Load IQM animation data static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCount); // Load IQM animation data
#endif #endif
#if defined(SUPPORT_FILEFORMAT_GLTF) #if SUPPORT_FILEFORMAT_GLTF
static Model LoadGLTF(const char *fileName); // Load GLTF mesh data static Model LoadGLTF(const char *fileName); // Load GLTF mesh data
static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCount); // Load GLTF animation data static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCount); // Load GLTF animation data
#endif #endif
#if defined(SUPPORT_FILEFORMAT_VOX) #if SUPPORT_FILEFORMAT_VOX
static Model LoadVOX(const char *filename); // Load VOX mesh data static Model LoadVOX(const char *filename); // Load VOX mesh data
#endif #endif
#if defined(SUPPORT_FILEFORMAT_M3D) #if SUPPORT_FILEFORMAT_M3D
static Model LoadM3D(const char *filename); // Load M3D mesh data static Model LoadM3D(const char *filename); // Load M3D mesh data
static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCount); // Load M3D animation data static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCount); // Load M3D animation data
#endif #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 static void ProcessMaterialsOBJ(Material *rayMaterials, tinyobj_material_t *materials, int materialCount); // Process obj materials
#endif #endif
@ -1099,19 +1105,19 @@ Model LoadModel(const char *fileName)
{ {
Model model = { 0 }; Model model = { 0 };
#if defined(SUPPORT_FILEFORMAT_OBJ) #if SUPPORT_FILEFORMAT_OBJ
if (IsFileExtension(fileName, ".obj")) model = LoadOBJ(fileName); if (IsFileExtension(fileName, ".obj")) model = LoadOBJ(fileName);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_IQM) #if SUPPORT_FILEFORMAT_IQM
if (IsFileExtension(fileName, ".iqm")) model = LoadIQM(fileName); if (IsFileExtension(fileName, ".iqm")) model = LoadIQM(fileName);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_GLTF) #if SUPPORT_FILEFORMAT_GLTF
if (IsFileExtension(fileName, ".gltf") || IsFileExtension(fileName, ".glb")) model = LoadGLTF(fileName); if (IsFileExtension(fileName, ".gltf") || IsFileExtension(fileName, ".glb")) model = LoadGLTF(fileName);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_VOX) #if SUPPORT_FILEFORMAT_VOX
if (IsFileExtension(fileName, ".vox")) model = LoadVOX(fileName); if (IsFileExtension(fileName, ".vox")) model = LoadVOX(fileName);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_M3D) #if SUPPORT_FILEFORMAT_M3D
if (IsFileExtension(fileName, ".m3d")) model = LoadM3D(fileName); if (IsFileExtension(fileName, ".m3d")) model = LoadM3D(fileName);
#endif #endif
@ -1276,7 +1282,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT] = 0; // Vertex buffer: tangents mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT] = 0; // Vertex buffer: tangents
mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2] = 0; // Vertex buffer: texcoords2 mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2] = 0; // Vertex buffer: texcoords2
mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES] = 0; // Vertex buffer: indices mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES] = 0; // Vertex buffer: indices
#ifdef SUPPORT_GPU_SKINNING #if SUPPORT_GPU_SKINNING
mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES] = 0; // Vertex buffer: boneIndices mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES] = 0; // Vertex buffer: boneIndices
mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS] = 0; // Vertex buffer: boneWeights mesh->vboId[RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS] = 0; // Vertex buffer: boneWeights
#endif #endif
@ -1377,7 +1383,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2); rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2);
} }
#ifdef SUPPORT_GPU_SKINNING #if SUPPORT_GPU_SKINNING
if (mesh->boneIndices != NULL) if (mesh->boneIndices != NULL)
{ {
// Enable vertex attribute: boneIndices (shader-location = 7) // Enable vertex attribute: boneIndices (shader-location = 7)
@ -1609,7 +1615,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]); rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]);
} }
#ifdef SUPPORT_GPU_SKINNING #if SUPPORT_GPU_SKINNING
// Bind mesh VBO data: vertex bone ids (shader-location = 6, if available) // Bind mesh VBO data: vertex bone ids (shader-location = 6, if available)
if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1) if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1)
{ {
@ -1848,7 +1854,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]); rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_TEXCOORD02]);
} }
#ifdef SUPPORT_GPU_SKINNING #if SUPPORT_GPU_SKINNING
// Bind mesh VBO data: vertex bone ids (shader-location = 6, if available) // Bind mesh VBO data: vertex bone ids (shader-location = 6, if available)
if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1) if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1)
{ {
@ -2125,7 +2131,7 @@ bool ExportMeshAsCode(Mesh mesh, const char *fileName)
return success; return success;
} }
#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL) #if SUPPORT_FILEFORMAT_OBJ || SUPPORT_FILEFORMAT_MTL
// Process obj materials // Process obj materials
static void ProcessMaterialsOBJ(Material *materials, tinyobj_material_t *mats, int materialCount) static void ProcessMaterialsOBJ(Material *materials, tinyobj_material_t *mats, int materialCount)
{ {
@ -2169,7 +2175,7 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
// TODO: Support IQM and GLTF for materials parsing // TODO: Support IQM and GLTF for materials parsing
#if defined(SUPPORT_FILEFORMAT_MTL) #if SUPPORT_FILEFORMAT_MTL
if (IsFileExtension(fileName, ".mtl")) if (IsFileExtension(fileName, ".mtl"))
{ {
tinyobj_material_t *mats = NULL; tinyobj_material_t *mats = NULL;
@ -2263,13 +2269,13 @@ ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount)
{ {
ModelAnimation *animations = NULL; ModelAnimation *animations = NULL;
#if defined(SUPPORT_FILEFORMAT_IQM) #if SUPPORT_FILEFORMAT_IQM
if (IsFileExtension(fileName, ".iqm")) animations = LoadModelAnimationsIQM(fileName, animCount); if (IsFileExtension(fileName, ".iqm")) animations = LoadModelAnimationsIQM(fileName, animCount);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_M3D) #if SUPPORT_FILEFORMAT_M3D
if (IsFileExtension(fileName, ".m3d")) animations = LoadModelAnimationsM3D(fileName, animCount); if (IsFileExtension(fileName, ".m3d")) animations = LoadModelAnimationsM3D(fileName, animCount);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_GLTF) #if SUPPORT_FILEFORMAT_GLTF
if (IsFileExtension(fileName, ".gltf;.glb")) animations = LoadModelAnimationsGLTF(fileName, animCount); if (IsFileExtension(fileName, ".gltf;.glb")) animations = LoadModelAnimationsGLTF(fileName, animCount);
#endif #endif
@ -2548,7 +2554,7 @@ bool IsModelAnimationValid(Model model, ModelAnimation anim)
return result; return result;
} }
#if defined(SUPPORT_MESH_GENERATION) #if SUPPORT_MESH_GENERATION
// Generate polygonal mesh // Generate polygonal mesh
Mesh GenMeshPoly(int sides, float radius) Mesh GenMeshPoly(int sides, float radius)
{ {
@ -3691,7 +3697,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
return mesh; return mesh;
} }
#endif // SUPPORT_MESH_GENERATION #endif // SUPPORT_MESH_GENERATION
// Compute mesh bounding box limits // Compute mesh bounding box limits
// NOTE: minVertex and maxVertex should be transformed by model transform matrix // NOTE: minVertex and maxVertex should be transformed by model transform matrix
@ -4378,7 +4384,7 @@ RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Ve
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Internal Functions Definition // Module Internal Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_IQM) || defined(SUPPORT_FILEFORMAT_GLTF) #if SUPPORT_FILEFORMAT_IQM || SUPPORT_FILEFORMAT_GLTF
// Build pose from parent joints // Build pose from parent joints
// NOTE: Required for animations loading (required by IQM and GLTF) // NOTE: Required for animations loading (required by IQM and GLTF)
static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform *transforms) static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform *transforms)
@ -4402,7 +4408,7 @@ static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_OBJ) #if SUPPORT_FILEFORMAT_OBJ
// Load OBJ mesh data // Load OBJ mesh data
// Notes to keep in mind: // Notes to keep in mind:
// - A mesh is created for every material present in the obj file // - A mesh is created for every material present in the obj file
@ -4653,7 +4659,7 @@ static Model LoadOBJ(const char *fileName)
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_IQM) #if SUPPORT_FILEFORMAT_IQM
// Load IQM mesh data // Load IQM mesh data
static Model LoadIQM(const char *fileName) static Model LoadIQM(const char *fileName)
{ {
@ -4834,7 +4840,7 @@ static Model LoadIQM(const char *fileName)
model.meshes[i].triangleCount = imesh[i].num_triangles; model.meshes[i].triangleCount = imesh[i].num_triangles;
model.meshes[i].indices = (unsigned short *)RL_CALLOC(model.meshes[i].triangleCount*3, sizeof(unsigned short)); model.meshes[i].indices = (unsigned short *)RL_CALLOC(model.meshes[i].triangleCount*3, sizeof(unsigned short));
#if !defined(SUPPORT_GPU_SKINNING) #if !SUPPORT_GPU_SKINNING
// Animated vertex data, what we actually process for rendering // Animated vertex data, what we actually process for rendering
// NOTE: Animated vertex should be re-uploaded to GPU (if not using GPU skinning) // NOTE: Animated vertex should be re-uploaded to GPU (if not using GPU skinning)
model.meshes[i].animVertices = (float *)RL_CALLOC(model.meshes[i].vertexCount*3, sizeof(float)); model.meshes[i].animVertices = (float *)RL_CALLOC(model.meshes[i].vertexCount*3, sizeof(float));
@ -5276,7 +5282,7 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCou
#endif #endif
#if defined(SUPPORT_FILEFORMAT_GLTF) #if SUPPORT_FILEFORMAT_GLTF
// Load file data callback for cgltf // 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) static cgltf_result LoadFileGLTFCallback(const struct cgltf_memory_options *memoryOptions, const struct cgltf_file_options *fileOptions, const char *path, cgltf_size *size, void **data)
{ {
@ -6317,7 +6323,7 @@ static Model LoadGLTF(const char *fileName)
} }
} }
#if !defined(SUPPORT_GPU_SKINNING) #if !SUPPORT_GPU_SKINNING
// Animated vertex data (CPU skinning) // Animated vertex data (CPU skinning)
model.meshes[meshIndex].animVertices = (float *)RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float)); model.meshes[meshIndex].animVertices = (float *)RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float));
memcpy(model.meshes[meshIndex].animVertices, model.meshes[meshIndex].vertices, model.meshes[meshIndex].vertexCount*3*sizeof(float)); memcpy(model.meshes[meshIndex].animVertices, model.meshes[meshIndex].vertices, model.meshes[meshIndex].vertexCount*3*sizeof(float));
@ -6676,7 +6682,7 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_VOX) #if SUPPORT_FILEFORMAT_VOX
// Load VOX (MagicaVoxel) mesh data // Load VOX (MagicaVoxel) mesh data
static Model LoadVOX(const char *fileName) static Model LoadVOX(const char *fileName)
{ {
@ -6786,7 +6792,7 @@ static Model LoadVOX(const char *fileName)
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_M3D) #if SUPPORT_FILEFORMAT_M3D
// Hook LoadFileData()/UnloadFileData() calls to M3D loaders // Hook LoadFileData()/UnloadFileData() calls to M3D loaders
unsigned char *m3d_loaderhook(char *fn, unsigned int *len) { return LoadFileData((const char *)fn, (int *)len); } 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); } void m3d_freehook(void *data) { UnloadFileData((unsigned char *)data); }
@ -6924,7 +6930,7 @@ static Model LoadM3D(const char *fileName)
{ {
model.meshes[k].boneIndices = (unsigned char *)RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char)); model.meshes[k].boneIndices = (unsigned char *)RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(unsigned char));
model.meshes[k].boneWeights = (float *)RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(float)); model.meshes[k].boneWeights = (float *)RL_CALLOC(model.meshes[k].vertexCount*4, sizeof(float));
#if !defined(SUPPORT_GPU_SKINNING) #if !SUPPORT_GPU_SKINNING
model.meshes[k].animVertices = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float)); model.meshes[k].animVertices = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float));
model.meshes[k].animNormals = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float)); model.meshes[k].animNormals = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float));
#endif #endif
@ -7131,7 +7137,7 @@ static Model LoadM3D(const char *fileName)
{ {
model.meshes[i].boneCount = model.skeleton.boneCount; model.meshes[i].boneCount = model.skeleton.boneCount;
#if !defined(SUPPORT_GPU_SKINNING) #if !SUPPORT_GPU_SKINNING
// Initialize vertex buffers for CPU skinning // Initialize vertex buffers for CPU skinning
memcpy(model.meshes[i].animVertices, model.meshes[i].vertices, model.meshes[i].vertexCount*3*sizeof(float)); memcpy(model.meshes[i].animVertices, model.meshes[i].vertices, model.meshes[i].vertexCount*3*sizeof(float));
memcpy(model.meshes[i].animNormals, model.meshes[i].normals, model.meshes[i].vertexCount*3*sizeof(float)); memcpy(model.meshes[i].animNormals, model.meshes[i].normals, model.meshes[i].vertexCount*3*sizeof(float));
@ -7268,4 +7274,4 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCou
} }
#endif #endif
#endif // SUPPORT_MODULE_RMODELS #endif // SUPPORT_MODULE_RMODELS

View File

@ -48,7 +48,7 @@
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#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 #include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2
@ -128,7 +128,7 @@ void DrawPixel(int posX, int posY, Color color)
// Draw a pixel (Vector version) // Draw a pixel (Vector version)
void DrawPixelV(Vector2 position, Color color) void DrawPixelV(Vector2 position, Color color)
{ {
#if defined(SUPPORT_QUADS_DRAW_MODE) #if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -353,7 +353,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
float stepLength = (endAngle - startAngle)/(float)segments; float stepLength = (endAngle - startAngle)/(float)segments;
float angle = startAngle; float angle = startAngle;
#if defined(SUPPORT_QUADS_DRAW_MODE) #if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -594,7 +594,7 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
float stepLength = (endAngle - startAngle)/(float)segments; float stepLength = (endAngle - startAngle)/(float)segments;
float angle = startAngle; float angle = startAngle;
#if defined(SUPPORT_QUADS_DRAW_MODE) #if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -774,7 +774,7 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
bottomRight.y = y + (dx + rec.width)*sinRotation + (dy + rec.height)*cosRotation; 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); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -884,7 +884,7 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color)
/* /*
// Previous implementation, it has issues... but it does not require view matrix... // 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, posY, width, 1, color);
DrawRectangle(posX + width - 1, posY + 1, 1, height - 2, color); DrawRectangle(posX + width - 1, posY + 1, 1, height - 2, color);
DrawRectangle(posX, posY + height - 1, width, 1, color); DrawRectangle(posX, posY + height - 1, width, 1, color);
@ -994,7 +994,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
const Vector2 centers[4] = { point[8], point[9], point[10], point[11] }; const Vector2 centers[4] = { point[8], point[9], point[10], point[11] };
const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f }; 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); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -1248,7 +1248,7 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
if (lineThick > 1) if (lineThick > 1)
{ {
#if defined(SUPPORT_QUADS_DRAW_MODE) #if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -1422,7 +1422,7 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
// NOTE: Vertex must be provided in counter-clockwise order // NOTE: Vertex must be provided in counter-clockwise order
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
{ {
#if defined(SUPPORT_QUADS_DRAW_MODE) #if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -1538,7 +1538,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
float centralAngle = rotation*DEG2RAD; float centralAngle = rotation*DEG2RAD;
float angleStep = 360.0f/(float)sides*DEG2RAD; float angleStep = 360.0f/(float)sides*DEG2RAD;
#if defined(SUPPORT_QUADS_DRAW_MODE) #if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -1607,7 +1607,7 @@ void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, fl
float exteriorAngle = 360.0f/(float)sides*DEG2RAD; float exteriorAngle = 360.0f/(float)sides*DEG2RAD;
float innerRadius = radius - (lineThick*cosf(DEG2RAD*exteriorAngle/2.0f)); float innerRadius = radius - (lineThick*cosf(DEG2RAD*exteriorAngle/2.0f));
#if defined(SUPPORT_QUADS_DRAW_MODE) #if SUPPORT_QUADS_DRAW_MODE
rlSetTexture(GetShapesTexture().id); rlSetTexture(GetShapesTexture().id);
Rectangle shapeRect = GetShapesTextureRectangle(); Rectangle shapeRect = GetShapesTextureRectangle();
@ -1663,7 +1663,7 @@ void DrawSplineLinear(const Vector2 *points, int pointCount, float thick, Color
{ {
if (pointCount < 2) return; if (pointCount < 2) return;
#if defined(SUPPORT_SPLINE_MITERS) #if SUPPORT_SPLINE_MITERS
Vector2 prevNormal = (Vector2){-(points[1].y - points[0].y), (points[1].x - points[0].x)}; Vector2 prevNormal = (Vector2){-(points[1].y - points[0].y), (points[1].x - points[0].x)};
float prevLength = sqrtf(prevNormal.x*prevNormal.x + prevNormal.y*prevNormal.y); float prevLength = sqrtf(prevNormal.x*prevNormal.x + prevNormal.y*prevNormal.y);
@ -1770,8 +1770,8 @@ void DrawSplineLinear(const Vector2 *points, int pointCount, float thick, Color
} }
#endif #endif
#if defined(SUPPORT_SPLINE_SEGMENT_CAPS) #if SUPPORT_SPLINE_SEGMENT_CAPS
// TODO: Add spline segment rounded caps at the begin/end of the spline // TODO: Add spline segment rounded caps at the begin/end of the spline?
#endif #endif
} }
@ -2484,4 +2484,4 @@ static float EaseCubicInOut(float t, float b, float c, float d)
return result; return result;
} }
#endif // SUPPORT_MODULE_RSHAPES #endif // SUPPORT_MODULE_RSHAPES

View File

@ -6,27 +6,23 @@
* #define SUPPORT_MODULE_RTEXT * #define SUPPORT_MODULE_RTEXT
* rtext module is included in the build * rtext module is included in the build
* *
* #define SUPPORT_DEFAULT_FONT
* Load default raylib font on initialization to be used by DrawText() and MeasureText()
* If no default font loaded, DrawTextEx() and MeasureTextEx() are required
*
* #define SUPPORT_FILEFORMAT_FNT * #define SUPPORT_FILEFORMAT_FNT
* #define SUPPORT_FILEFORMAT_TTF * #define SUPPORT_FILEFORMAT_TTF
* #define SUPPORT_FILEFORMAT_BDF * #define SUPPORT_FILEFORMAT_BDF
* Selected desired fileformats to be supported for loading. Some of those formats are * Selected desired fileformats to be supported for loading. Some of those formats are
* supported by default, to remove support, just comment unrequired #define in this module * supported by default, to remove support, just comment unrequired #define in this module
* *
* #define SUPPORT_FONT_ATLAS_WHITE_REC
* 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()]
*
* #define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH * #define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH
* TextSplit() function static buffer max size * TextSplit() function static buffer max size
* *
* #define MAX_TEXTSPLIT_COUNT * #define MAX_TEXTSPLIT_COUNT
* TextSplit() function static substrings pointers array (pointing to static buffer) * TextSplit() function static substrings pointers array (pointing to static buffer)
* *
* #define FONT_ATLAS_CORNER_REC_SIZE
* On font atlas image generation [GenImageFontAtlas()], add a NxN 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()]
*
* DEPENDENCIES: * DEPENDENCIES:
* stb_truetype - Load TTF file and rasterize characters data * stb_truetype - Load TTF file and rasterize characters data
* stb_rect_pack - Rectangles packing algorithms, required for font atlas generation * stb_rect_pack - Rectangles packing algorithms, required for font atlas generation
@ -57,7 +53,7 @@
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#if defined(SUPPORT_MODULE_RTEXT) #if SUPPORT_MODULE_RTEXT
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 -> Only DrawTextPro() #include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2 -> Only DrawTextPro()
@ -67,7 +63,7 @@
#include <stdarg.h> // Required for: va_list, va_start(), vsprintf(), va_end() [Used in TextFormat()] #include <stdarg.h> // Required for: va_list, va_start(), vsprintf(), va_end() [Used in TextFormat()]
#include <ctype.h> // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()] #include <ctype.h> // 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 #if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-function"
@ -83,7 +79,7 @@
#endif #endif
#endif #endif
#if defined(SUPPORT_FILEFORMAT_TTF) #if SUPPORT_FILEFORMAT_TTF
#if defined(__GNUC__) // GCC and Clang #if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-function"
@ -105,14 +101,18 @@
// Defines and Macros // Defines and Macros
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#ifndef MAX_TEXT_BUFFER_LENGTH #ifndef MAX_TEXT_BUFFER_LENGTH
#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions: #define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
// TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit() // TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit()
#endif
#ifndef MAX_TEXT_UNICODE_CHARS
#define MAX_TEXT_UNICODE_CHARS 512 // Maximum number of unicode codepoints: GetCodepoints()
#endif #endif
#ifndef MAX_TEXTSPLIT_COUNT #ifndef MAX_TEXTSPLIT_COUNT
#define MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit() #define MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit()
#endif
#ifndef FONT_ATLAS_CORNER_REC_SIZE
// On font atlas image generation [GenImageFontAtlas()], add a 3x3 pixels white rectangle
// at the bottom-right corner of the atlas. It can be useful for shapes drawing, to allow
// drawing text and shapes with a single draw call [SetShapesTexture()]
#define FONT_ATLAS_CORNER_REC_SIZE 3 // Size of white rectangle drawn on font atlas on font loading
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -123,12 +123,12 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global variables // Global variables
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_DEFAULT_FONT)
// Default font provided by raylib // Default font provided by raylib
// NOTE: Default font is loaded on InitWindow() and disposed on CloseWindow() [module: core] // NOTE: Default font is loaded on InitWindow() and disposed on CloseWindow() [module: core]
static Font defaultFont = { 0 }; static Font defaultFont = { 0 };
#endif
static int textLineSpacing = 2; // Text vertical line spacing in pixels (between lines) // Text vertical line spacing in pixels (between lines)
static int textLineSpacing = 2;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Other Modules Functions Declaration (required by text) // Other Modules Functions Declaration (required by text)
@ -138,22 +138,19 @@ static int textLineSpacing = 2; // Text vertical line spacing in pixels (between
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Internal Functions Declaration // Module Internal Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_FNT) #if SUPPORT_FILEFORMAT_FNT
static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file) static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
#endif #endif
#if defined(SUPPORT_FILEFORMAT_BDF) #if SUPPORT_FILEFORMAT_BDF
static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, const int *codepoints, int codepointCount, int *outFontSize); static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, const int *codepoints, int codepointCount, int *outFontSize);
#endif #endif
#if defined(SUPPORT_DEFAULT_FONT)
extern void LoadFontDefault(void); extern void LoadFontDefault(void);
extern void UnloadFontDefault(void); extern void UnloadFontDefault(void);
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Definition // Module Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_DEFAULT_FONT)
// Load raylib default font // Load raylib default font
extern void LoadFontDefault(void) extern void LoadFontDefault(void)
{ {
@ -329,17 +326,11 @@ extern void UnloadFontDefault(void)
defaultFont.glyphs = NULL; defaultFont.glyphs = NULL;
defaultFont.recs = NULL; defaultFont.recs = NULL;
} }
#endif // SUPPORT_DEFAULT_FONT
// Get the default font, useful to be used with extended parameters // Get the default font, useful to be used with extended parameters
Font GetFontDefault() Font GetFontDefault()
{ {
#if defined(SUPPORT_DEFAULT_FONT)
return defaultFont; return defaultFont;
#else
Font font = { 0 };
return font;
#endif
} }
// Load Font from file into GPU memory (VRAM) // Load Font from file into GPU memory (VRAM)
@ -361,15 +352,15 @@ Font LoadFont(const char *fileName)
Font font = { 0 }; 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); if (IsFileExtension(fileName, ".ttf") || IsFileExtension(fileName, ".otf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS);
else else
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FNT) #if SUPPORT_FILEFORMAT_FNT
if (IsFileExtension(fileName, ".fnt")) font = LoadBMFont(fileName); if (IsFileExtension(fileName, ".fnt")) font = LoadBMFont(fileName);
else else
#endif #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); if (IsFileExtension(fileName, ".bdf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS);
else else
#endif #endif
@ -548,7 +539,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
font.baseSize = fontSize; font.baseSize = fontSize;
font.glyphPadding = 0; font.glyphPadding = 0;
#if defined(SUPPORT_FILEFORMAT_TTF) #if SUPPORT_FILEFORMAT_TTF
if (TextIsEqual(fileExtLower, ".ttf") || if (TextIsEqual(fileExtLower, ".ttf") ||
TextIsEqual(fileExtLower, ".otf")) TextIsEqual(fileExtLower, ".otf"))
{ {
@ -556,7 +547,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
} }
else else
#endif #endif
#if defined(SUPPORT_FILEFORMAT_BDF) #if SUPPORT_FILEFORMAT_BDF
if (TextIsEqual(fileExtLower, ".bdf")) if (TextIsEqual(fileExtLower, ".bdf"))
{ {
font.glyphs = LoadFontDataBDF(fileData, dataSize, codepoints, (codepointCount > 0)? codepointCount : 95, &font.baseSize); font.glyphs = LoadFontDataBDF(fileData, dataSize, codepoints, (codepointCount > 0)? codepointCount : 95, &font.baseSize);
@ -568,7 +559,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
font.glyphs = NULL; font.glyphs = NULL;
} }
#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF) #if SUPPORT_FILEFORMAT_TTF || SUPPORT_FILEFORMAT_BDF
if (font.glyphs != NULL) if (font.glyphs != NULL)
{ {
font.glyphPadding = FONT_TTF_DEFAULT_CHARS_PADDING; font.glyphPadding = FONT_TTF_DEFAULT_CHARS_PADDING;
@ -629,7 +620,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
GlyphInfo *glyphs = NULL; GlyphInfo *glyphs = NULL;
int glyphCounter = 0; int glyphCounter = 0;
#if defined(SUPPORT_FILEFORMAT_TTF) #if SUPPORT_FILEFORMAT_TTF
// Load font data (including pixel data) from TTF memory file // 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 // NOTE: Loaded information should be enough to generate font image atlas, using any packaging method
if (fileData != NULL) if (fileData != NULL)
@ -789,7 +780,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
// Generate image font atlas using chars info // Generate image font atlas using chars info
// NOTE: Packing method: 0-Default, 1-Skyline // 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 GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod)
{ {
Image atlas = { 0 }; Image atlas = { 0 };
@ -961,13 +952,12 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp
RL_FREE(context); RL_FREE(context);
} }
#if defined(SUPPORT_FONT_ATLAS_WHITE_REC)
// Add a 3x3 white rectangle at the bottom-right corner of the generated atlas, // 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 // useful to use as the white texture to draw shapes with raylib
// Security: ensure the atlas is large enough to hold a 3x3 rectangle // Security: ensure the atlas is large enough to hold a 3x3 rectangle
if ((atlas.width >= 3) && (atlas.height >= 3)) if ((FONT_ATLAS_CORNER_REC_SIZE > 0) && (atlas.width >= 3) && (atlas.height >= 3))
{ {
for (int i = 0, k = atlas.width*atlas.height - 1; i < 3; i++) for (int i = 0, k = atlas.width*atlas.height - 1; i < FONT_ATLAS_CORNER_REC_SIZE; i++)
{ {
((unsigned char *)atlas.data)[k - 0] = 255; ((unsigned char *)atlas.data)[k - 0] = 255;
((unsigned char *)atlas.data)[k - 1] = 255; ((unsigned char *)atlas.data)[k - 1] = 255;
@ -975,7 +965,6 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp
k -= atlas.width; k -= atlas.width;
} }
} }
#endif
// Convert image data from GRAYSCALE to GRAY_ALPHA // Convert image data from GRAYSCALE to GRAY_ALPHA
unsigned char *dataGrayAlpha = (unsigned char *)RL_MALLOC(atlas.width*atlas.height*sizeof(unsigned char)*2); // Two channels unsigned char *dataGrayAlpha = (unsigned char *)RL_MALLOC(atlas.width*atlas.height*sizeof(unsigned char)*2); // Two channels
@ -1601,7 +1590,6 @@ float TextToFloat(const char *text)
return value*sign; return value*sign;
} }
#if defined(SUPPORT_TEXT_MANIPULATION)
// Copy one string to another, returns bytes copied // Copy one string to another, returns bytes copied
// NOTE: Alternative implementation to strcpy(dst, src) from C standard library // NOTE: Alternative implementation to strcpy(dst, src) from C standard library
int TextCopy(char *dst, const char *src) int TextCopy(char *dst, const char *src)
@ -2195,7 +2183,6 @@ const char *CodepointToUTF8(int codepoint, int *utf8Size)
return utf8; return utf8;
} }
#endif // SUPPORT_TEXT_MANIPULATION
// Get next codepoint in a UTF-8 encoded text, scanning until '\0' is found // Get next codepoint in a UTF-8 encoded text, scanning until '\0' is found
// When an invalid UTF-8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned // When an invalid UTF-8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned
@ -2370,7 +2357,7 @@ int GetCodepointPrevious(const char *text, int *codepointSize)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Internal Functions Definition // Module Internal Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_FNT) || defined(SUPPORT_FILEFORMAT_BDF) #if SUPPORT_FILEFORMAT_FNT || SUPPORT_FILEFORMAT_BDF
// Read a line from memory // Read a line from memory
// REQUIRES: memcpy() // REQUIRES: memcpy()
// NOTE: Returns the number of bytes read // NOTE: Returns the number of bytes read
@ -2384,7 +2371,7 @@ static int GetLine(const char *origin, char *buffer, int maxLength)
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_FNT) #if SUPPORT_FILEFORMAT_FNT
// Load a BMFont file (AngelCode font file) // Load a BMFont file (AngelCode font file)
// REQUIRES: strstr(), sscanf(), strrchr(), memcpy() // REQUIRES: strstr(), sscanf(), strrchr(), memcpy()
static Font LoadBMFont(const char *fileName) static Font LoadBMFont(const char *fileName)
@ -2561,7 +2548,7 @@ static Font LoadBMFont(const char *fileName)
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_BDF) #if SUPPORT_FILEFORMAT_BDF
// Convert hexadecimal to decimal (single digit) // Convert hexadecimal to decimal (single digit)
static unsigned char HexToInt(char hex) static unsigned char HexToInt(char hex)
{ {

View File

@ -27,10 +27,6 @@
* #define SUPPORT_IMAGE_EXPORT * #define SUPPORT_IMAGE_EXPORT
* Support image export in multiple file formats * Support image export in multiple file formats
* *
* #define SUPPORT_IMAGE_MANIPULATION
* Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
* If not defined only some image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageResize*()
*
* #define SUPPORT_IMAGE_GENERATION * #define SUPPORT_IMAGE_GENERATION
* Support procedural image generation functionality (gradient, spot, perlin-noise, cellular) * Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
* *
@ -65,7 +61,7 @@
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#if defined(SUPPORT_MODULE_RTEXTURES) #if SUPPORT_MODULE_RTEXTURES
#include "rlgl.h" // OpenGL abstraction layer to multiple versions #include "rlgl.h" // OpenGL abstraction layer to multiple versions
@ -103,32 +99,32 @@
#define STBI_NO_PNM #define STBI_NO_PNM
#endif #endif
#if defined(SUPPORT_FILEFORMAT_DDS) #if SUPPORT_FILEFORMAT_DDS
#define RL_GPUTEX_SUPPORT_DDS #define RL_GPUTEX_SUPPORT_DDS
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PKM) #if SUPPORT_FILEFORMAT_PKM
#define RL_GPUTEX_SUPPORT_PKM #define RL_GPUTEX_SUPPORT_PKM
#endif #endif
#if defined(SUPPORT_FILEFORMAT_KTX) #if SUPPORT_FILEFORMAT_KTX
#define RL_GPUTEX_SUPPORT_KTX #define RL_GPUTEX_SUPPORT_KTX
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PVR) #if SUPPORT_FILEFORMAT_PVR
#define RL_GPUTEX_SUPPORT_PVR #define RL_GPUTEX_SUPPORT_PVR
#endif #endif
#if defined(SUPPORT_FILEFORMAT_ASTC) #if SUPPORT_FILEFORMAT_ASTC
#define RL_GPUTEX_SUPPORT_ASTC #define RL_GPUTEX_SUPPORT_ASTC
#endif #endif
// Image fileformats not supported by default // Image fileformats not supported by default
#if (defined(SUPPORT_FILEFORMAT_BMP) || \ #if (SUPPORT_FILEFORMAT_BMP || \
defined(SUPPORT_FILEFORMAT_PNG) || \ SUPPORT_FILEFORMAT_PNG || \
defined(SUPPORT_FILEFORMAT_TGA) || \ SUPPORT_FILEFORMAT_TGA || \
defined(SUPPORT_FILEFORMAT_JPG) || \ SUPPORT_FILEFORMAT_JPG || \
defined(SUPPORT_FILEFORMAT_PSD) || \ SUPPORT_FILEFORMAT_PSD || \
defined(SUPPORT_FILEFORMAT_GIF) || \ SUPPORT_FILEFORMAT_GIF || \
defined(SUPPORT_FILEFORMAT_HDR) || \ SUPPORT_FILEFORMAT_HDR || \
defined(SUPPORT_FILEFORMAT_PIC) || \ SUPPORT_FILEFORMAT_PIC || \
defined(SUPPORT_FILEFORMAT_PNM)) SUPPORT_FILEFORMAT_PNM)
#if defined(__GNUC__) // GCC and Clang #if defined(__GNUC__) // GCC and Clang
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -177,7 +173,7 @@
#endif #endif
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOI) #if SUPPORT_FILEFORMAT_QOI
#define QOI_MALLOC RL_MALLOC #define QOI_MALLOC RL_MALLOC
#define QOI_FREE RL_FREE #define QOI_FREE RL_FREE
@ -195,7 +191,7 @@
#endif #endif
#if defined(SUPPORT_IMAGE_EXPORT) #if SUPPORT_IMAGE_EXPORT
#define STBIW_MALLOC RL_MALLOC #define STBIW_MALLOC RL_MALLOC
#define STBIW_FREE RL_FREE #define STBIW_FREE RL_FREE
#define STBIW_REALLOC RL_REALLOC #define STBIW_REALLOC RL_REALLOC
@ -204,7 +200,7 @@
#include "external/stb_image_write.h" // Required for: stbi_write_*() #include "external/stb_image_write.h" // Required for: stbi_write_*()
#endif #endif
#if defined(SUPPORT_IMAGE_GENERATION) #if SUPPORT_IMAGE_GENERATION
#define STB_PERLIN_IMPLEMENTATION #define STB_PERLIN_IMPLEMENTATION
#include "external/stb_perlin.h" // Required for: stb_perlin_fbm_noise3 #include "external/stb_perlin.h" // Required for: stb_perlin_fbm_noise3
#endif #endif
@ -268,15 +264,15 @@ Image LoadImage(const char *fileName)
{ {
Image image = { 0 }; Image image = { 0 };
#if defined(SUPPORT_FILEFORMAT_PNG) || \ #if SUPPORT_FILEFORMAT_PNG || \
defined(SUPPORT_FILEFORMAT_BMP) || \ SUPPORT_FILEFORMAT_BMP || \
defined(SUPPORT_FILEFORMAT_TGA) || \ SUPPORT_FILEFORMAT_TGA || \
defined(SUPPORT_FILEFORMAT_JPG) || \ SUPPORT_FILEFORMAT_JPG || \
defined(SUPPORT_FILEFORMAT_GIF) || \ SUPPORT_FILEFORMAT_GIF || \
defined(SUPPORT_FILEFORMAT_PIC) || \ SUPPORT_FILEFORMAT_PIC || \
defined(SUPPORT_FILEFORMAT_HDR) || \ SUPPORT_FILEFORMAT_HDR || \
defined(SUPPORT_FILEFORMAT_PNM) || \ SUPPORT_FILEFORMAT_PNM || \
defined(SUPPORT_FILEFORMAT_PSD) SUPPORT_FILEFORMAT_PSD
#define STBI_REQUIRED #define STBI_REQUIRED
#endif #endif
@ -338,7 +334,7 @@ Image LoadImageAnim(const char *fileName, int *frames)
Image image = { 0 }; Image image = { 0 };
int frameCount = 0; int frameCount = 0;
#if defined(SUPPORT_FILEFORMAT_GIF) #if SUPPORT_FILEFORMAT_GIF
if (IsFileExtension(fileName, ".gif")) if (IsFileExtension(fileName, ".gif"))
{ {
int dataSize = 0; int dataSize = 0;
@ -383,7 +379,7 @@ Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileDat
// Security check for input data // Security check for input data
if ((fileType == NULL) || (fileData == NULL) || (dataSize == 0)) return image; 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 ((strcmp(fileType, ".gif") == 0) || (strcmp(fileType, ".GIF") == 0))
{ {
if (fileData != NULL) if (fileData != NULL)
@ -430,30 +426,30 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
} }
if ((false) if ((false)
#if defined(SUPPORT_FILEFORMAT_PNG) #if SUPPORT_FILEFORMAT_PNG
|| (strcmp(fileType, ".png") == 0) || (strcmp(fileType, ".PNG") == 0) || (strcmp(fileType, ".png") == 0) || (strcmp(fileType, ".PNG") == 0)
#endif #endif
#if defined(SUPPORT_FILEFORMAT_BMP) #if SUPPORT_FILEFORMAT_BMP
|| (strcmp(fileType, ".bmp") == 0) || (strcmp(fileType, ".BMP") == 0) || (strcmp(fileType, ".bmp") == 0) || (strcmp(fileType, ".BMP") == 0)
#endif #endif
#if defined(SUPPORT_FILEFORMAT_TGA) #if SUPPORT_FILEFORMAT_TGA
|| (strcmp(fileType, ".tga") == 0) || (strcmp(fileType, ".TGA") == 0) || (strcmp(fileType, ".tga") == 0) || (strcmp(fileType, ".TGA") == 0)
#endif #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)
|| (strcmp(fileType, ".JPG") == 0) || (strcmp(fileType, ".JPEG") == 0) || (strcmp(fileType, ".JPG") == 0) || (strcmp(fileType, ".JPEG") == 0)
#endif #endif
#if defined(SUPPORT_FILEFORMAT_GIF) #if SUPPORT_FILEFORMAT_GIF
|| (strcmp(fileType, ".gif") == 0) || (strcmp(fileType, ".GIF") == 0) || (strcmp(fileType, ".gif") == 0) || (strcmp(fileType, ".GIF") == 0)
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PIC) #if SUPPORT_FILEFORMAT_PIC
|| (strcmp(fileType, ".pic") == 0) || (strcmp(fileType, ".PIC") == 0) || (strcmp(fileType, ".pic") == 0) || (strcmp(fileType, ".PIC") == 0)
#endif #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)
|| (strcmp(fileType, ".PPM") == 0) || (strcmp(fileType, ".PGM") == 0) || (strcmp(fileType, ".PPM") == 0) || (strcmp(fileType, ".PGM") == 0)
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PSD) #if SUPPORT_FILEFORMAT_PSD
|| (strcmp(fileType, ".psd") == 0) || (strcmp(fileType, ".PSD") == 0) || (strcmp(fileType, ".psd") == 0) || (strcmp(fileType, ".PSD") == 0)
#endif #endif
) )
@ -478,7 +474,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
} }
#endif #endif
} }
#if defined(SUPPORT_FILEFORMAT_HDR) #if SUPPORT_FILEFORMAT_HDR
else if ((strcmp(fileType, ".hdr") == 0) || (strcmp(fileType, ".HDR") == 0)) else if ((strcmp(fileType, ".hdr") == 0) || (strcmp(fileType, ".HDR") == 0))
{ {
#if defined(STBI_REQUIRED) #if defined(STBI_REQUIRED)
@ -501,7 +497,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
#endif #endif
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOI) #if SUPPORT_FILEFORMAT_QOI
else if ((strcmp(fileType, ".qoi") == 0) || (strcmp(fileType, ".QOI") == 0)) else if ((strcmp(fileType, ".qoi") == 0) || (strcmp(fileType, ".QOI") == 0))
{ {
if (fileData != NULL) if (fileData != NULL)
@ -515,31 +511,31 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_DDS) #if SUPPORT_FILEFORMAT_DDS
else if ((strcmp(fileType, ".dds") == 0) || (strcmp(fileType, ".DDS") == 0)) 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); image.data = rl_load_dds_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PKM) #if SUPPORT_FILEFORMAT_PKM
else if ((strcmp(fileType, ".pkm") == 0) || (strcmp(fileType, ".PKM") == 0)) 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); image.data = rl_load_pkm_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_KTX) #if SUPPORT_FILEFORMAT_KTX
else if ((strcmp(fileType, ".ktx") == 0) || (strcmp(fileType, ".KTX") == 0)) 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); image.data = rl_load_ktx_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PVR) #if SUPPORT_FILEFORMAT_PVR
else if ((strcmp(fileType, ".pvr") == 0) || (strcmp(fileType, ".PVR") == 0)) 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); image.data = rl_load_pvr_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_ASTC) #if SUPPORT_FILEFORMAT_ASTC
else if ((strcmp(fileType, ".astc") == 0) || (strcmp(fileType, ".ASTC") == 0)) 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); image.data = rl_load_astc_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
@ -628,7 +624,7 @@ bool ExportImage(Image image, const char *fileName)
// Security check for input data // Security check for input data
if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return result; if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return result;
#if defined(SUPPORT_IMAGE_EXPORT) #if SUPPORT_IMAGE_EXPORT
int channels = 4; int channels = 4;
bool allocatedData = false; bool allocatedData = false;
unsigned char *imgData = (unsigned char *)image.data; unsigned char *imgData = (unsigned char *)image.data;
@ -645,7 +641,7 @@ bool ExportImage(Image image, const char *fileName)
} }
if (false) { } // Required to attach following 'else' cases if (false) { } // Required to attach following 'else' cases
#if defined(SUPPORT_FILEFORMAT_PNG) #if SUPPORT_FILEFORMAT_PNG
else if (IsFileExtension(fileName, ".png")) else if (IsFileExtension(fileName, ".png"))
{ {
int dataSize = 0; int dataSize = 0;
@ -654,17 +650,17 @@ bool ExportImage(Image image, const char *fileName)
RL_FREE(fileData); RL_FREE(fileData);
} }
#endif #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); else if (IsFileExtension(fileName, ".bmp")) result = stbi_write_bmp(fileName, image.width, image.height, channels, imgData);
#endif #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); else if (IsFileExtension(fileName, ".tga")) result = stbi_write_tga(fileName, image.width, image.height, channels, imgData);
#endif #endif
#if defined(SUPPORT_FILEFORMAT_JPG) #if SUPPORT_FILEFORMAT_JPG
else if (IsFileExtension(fileName, ".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 IsFileExtension(fileName, ".jpeg")) result = stbi_write_jpg(fileName, image.width, image.height, channels, imgData, 90); // JPG quality: between 1 and 100
#endif #endif
#if defined(SUPPORT_FILEFORMAT_QOI) #if SUPPORT_FILEFORMAT_QOI
else if (IsFileExtension(fileName, ".qoi")) else if (IsFileExtension(fileName, ".qoi"))
{ {
channels = 0; channels = 0;
@ -684,7 +680,7 @@ bool ExportImage(Image image, const char *fileName)
} }
} }
#endif #endif
#if defined(SUPPORT_FILEFORMAT_KTX) #if SUPPORT_FILEFORMAT_KTX
else if (IsFileExtension(fileName, ".ktx")) else if (IsFileExtension(fileName, ".ktx"))
{ {
result = rl_save_ktx(fileName, image.data, image.width, image.height, image.format, image.mipmaps); result = rl_save_ktx(fileName, image.data, image.width, image.height, image.format, image.mipmaps);
@ -699,7 +695,7 @@ bool ExportImage(Image image, const char *fileName)
else TRACELOG(LOG_WARNING, "IMAGE: Export image format requested not supported"); else TRACELOG(LOG_WARNING, "IMAGE: Export image format requested not supported");
if (allocatedData) RL_FREE(imgData); if (allocatedData) RL_FREE(imgData);
#endif // SUPPORT_IMAGE_EXPORT #endif // SUPPORT_IMAGE_EXPORT
if (result != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image exported successfully", fileName); if (result != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image exported successfully", fileName);
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export image", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export image", fileName);
@ -716,7 +712,6 @@ unsigned char *ExportImageToMemory(Image image, const char *fileType, int *dataS
// Security check for input data // Security check for input data
if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return NULL; if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return NULL;
#if defined(SUPPORT_IMAGE_EXPORT)
int channels = 4; int channels = 4;
if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) channels = 1; if (image.format == PIXELFORMAT_UNCOMPRESSED_GRAYSCALE) channels = 1;
@ -724,13 +719,13 @@ 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_R8G8B8) channels = 3;
else if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8) channels = 4; else if (image.format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8) channels = 4;
#if defined(SUPPORT_FILEFORMAT_PNG) #if SUPPORT_IMAGE_EXPORT
if ((strcmp(fileType, ".png") == 0) || (strcmp(fileType, ".PNG") == 0)) 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); fileData = stbi_write_png_to_mem((const unsigned char *)image.data, image.width*channels, image.width, image.height, channels, dataSize);
} }
#endif #else
TRACELOG(LOG_WARNING, "IMAGE: To export image, enable flag SUPPORT_IMAGE_EXPORT");
#endif #endif
return fileData; return fileData;
@ -741,8 +736,6 @@ bool ExportImageAsCode(Image image, const char *fileName)
{ {
bool success = false; bool success = false;
#if defined(SUPPORT_IMAGE_EXPORT)
#ifndef TEXT_BYTES_PER_LINE #ifndef TEXT_BYTES_PER_LINE
#define TEXT_BYTES_PER_LINE 20 #define TEXT_BYTES_PER_LINE 20
#endif #endif
@ -785,8 +778,6 @@ bool ExportImageAsCode(Image image, const char *fileName)
RL_FREE(txtData); RL_FREE(txtData);
#endif // SUPPORT_IMAGE_EXPORT
if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image as code exported successfully", fileName); if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image as code exported successfully", fileName);
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export image as code", fileName); else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export image as code", fileName);
@ -814,7 +805,7 @@ Image GenImageColor(int width, int height, Color color)
return image; return image;
} }
#if defined(SUPPORT_IMAGE_GENERATION) #if SUPPORT_IMAGE_GENERATION
// Generate image: linear gradient // Generate image: linear gradient
// The direction value specifies the direction of the gradient (in degrees) // 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) // with 0 being vertical (from top to bottom), 90 being horizontal (from left to right)
@ -1137,7 +1128,7 @@ Image GenImageText(int width, int height, const char *text)
return image; return image;
} }
#endif // SUPPORT_IMAGE_GENERATION #endif // SUPPORT_IMAGE_GENERATION
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Image manipulation functions // Image manipulation functions
@ -1451,9 +1442,7 @@ void ImageFormat(Image *image, int newFormat)
if (image->mipmaps > 1) if (image->mipmaps > 1)
{ {
image->mipmaps = 1; image->mipmaps = 1;
#if defined(SUPPORT_IMAGE_MANIPULATION)
if (image->data != NULL) ImageMipmaps(image); if (image->data != NULL) ImageMipmaps(image);
#endif
} }
} }
else TRACELOG(LOG_WARNING, "IMAGE: Data format is compressed, can not be converted"); else TRACELOG(LOG_WARNING, "IMAGE: Data format is compressed, can not be converted");
@ -1464,7 +1453,7 @@ void ImageFormat(Image *image, int newFormat)
Image ImageText(const char *text, int fontSize, Color color) Image ImageText(const char *text, int fontSize, Color color)
{ {
Image imText = { 0 }; Image imText = { 0 };
#if defined(SUPPORT_MODULE_RTEXT) #if SUPPORT_MODULE_RTEXT
int defaultFontSize = 10; // Default Font chars height in pixel int defaultFontSize = 10; // Default Font chars height in pixel
if (fontSize < defaultFontSize) fontSize = defaultFontSize; if (fontSize < defaultFontSize) fontSize = defaultFontSize;
int spacing = fontSize/defaultFontSize; int spacing = fontSize/defaultFontSize;
@ -1481,7 +1470,7 @@ Image ImageText(const char *text, int fontSize, Color color)
Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint) Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint)
{ {
Image imText = { 0 }; Image imText = { 0 };
#if defined(SUPPORT_MODULE_RTEXT) #if SUPPORT_MODULE_RTEXT
if (text == NULL) return imText; if (text == NULL) return imText;
int textLength = (int)strlen(text); // Get length of text in bytes int textLength = (int)strlen(text); // Get length of text in bytes
@ -1873,7 +1862,6 @@ void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, i
} }
} }
#if defined(SUPPORT_IMAGE_MANIPULATION)
// Convert image to POT (power-of-two) // Convert image to POT (power-of-two)
// NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5) // NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5)
void ImageToPOT(Image *image, Color fill) void ImageToPOT(Image *image, Color fill)
@ -2944,7 +2932,6 @@ void ImageColorReplace(Image *image, Color color, Color replace)
(format == PIXELFORMAT_COMPRESSED_ETC2_RGB) || (format == PIXELFORMAT_COMPRESSED_ETC2_RGB) ||
(format == PIXELFORMAT_COMPRESSED_PVRT_RGB)) ImageFormat(image, format); (format == PIXELFORMAT_COMPRESSED_PVRT_RGB)) ImageFormat(image, format);
} }
#endif // SUPPORT_IMAGE_MANIPULATION
// Load color data from image as a Color array (RGBA - 32bit) // Load color data from image as a Color array (RGBA - 32bit)
// NOTE: Memory allocated should be freed using UnloadImageColors(); // NOTE: Memory allocated should be freed using UnloadImageColors();
@ -4095,7 +4082,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
// Draw text (default font) within an image (destination) // Draw text (default font) within an image (destination)
void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color) 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
// Make sure default font is loaded to be used on image text drawing // Make sure default font is loaded to be used on image text drawing
if (GetFontDefault().texture.id == 0) LoadFontDefault(); if (GetFontDefault().texture.id == 0) LoadFontDefault();
@ -4234,13 +4221,11 @@ TextureCubemap LoadTextureCubemap(Image image, int layout)
ImageFormat(&faces, image.format); ImageFormat(&faces, image.format);
Image mipmapped = ImageCopy(image); Image mipmapped = ImageCopy(image);
#if defined(SUPPORT_IMAGE_MANIPULATION)
if (image.mipmaps > 1) if (image.mipmaps > 1)
{ {
ImageMipmaps(&mipmapped); ImageMipmaps(&mipmapped);
ImageMipmaps(&faces); ImageMipmaps(&faces);
} }
#endif
for (int i = 0; i < 6; i++) ImageDraw(&faces, mipmapped, faceRecs[i], (Rectangle){ 0, (float)size*i, (float)size, (float)size }, WHITE); for (int i = 0; i < 6; i++) ImageDraw(&faces, mipmapped, faceRecs[i], (Rectangle){ 0, (float)size*i, (float)size, (float)size }, WHITE);
@ -5599,4 +5584,4 @@ static Vector4 *LoadImageDataNormalized(Image image)
return pixels; return pixels;
} }
#endif // SUPPORT_MODULE_RTEXTURES #endif // SUPPORT_MODULE_RTEXTURES