mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-27 05:45:04 +00:00
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:
498
src/config.h
498
src/config.h
@@ -2,7 +2,9 @@
|
||||
*
|
||||
* 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
|
||||
*
|
||||
@@ -28,288 +30,342 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module selection - Some modules could be avoided
|
||||
// Mandatory modules: rcore, rlgl
|
||||
//------------------------------------------------------------------------------------
|
||||
#if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
#define SUPPORT_MODULE_RSHAPES 1
|
||||
#define SUPPORT_MODULE_RTEXTURES 1
|
||||
#define SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures
|
||||
#define SUPPORT_MODULE_RMODELS 1
|
||||
#define SUPPORT_MODULE_RAUDIO 1
|
||||
#ifndef SUPPORT_MODULE_RSHAPES
|
||||
#define SUPPORT_MODULE_RSHAPES 1
|
||||
#endif
|
||||
#ifndef SUPPORT_MODULE_RTEXTURES
|
||||
#define SUPPORT_MODULE_RTEXTURES 1
|
||||
#endif
|
||||
#ifndef SUPPORT_MODULE_RTEXT
|
||||
#define SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures
|
||||
#endif
|
||||
#ifndef SUPPORT_MODULE_RMODELS
|
||||
#define SUPPORT_MODULE_RMODELS 1
|
||||
#endif
|
||||
#ifndef SUPPORT_MODULE_RAUDIO
|
||||
#define SUPPORT_MODULE_RAUDIO 1
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module: rcore - Configuration Flags
|
||||
//------------------------------------------------------------------------------------
|
||||
#if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
// Standard file io library (stdio.h) included
|
||||
#define SUPPORT_STANDARD_FILEIO 1
|
||||
// Show TRACELOG() output messages
|
||||
#define SUPPORT_TRACELOG 1
|
||||
// Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital
|
||||
#define SUPPORT_CAMERA_SYSTEM 1
|
||||
// Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
|
||||
#define SUPPORT_GESTURES_SYSTEM 1
|
||||
// Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64
|
||||
#define SUPPORT_RPRAND_GENERATOR 1
|
||||
// Mouse gestures are directly mapped like touches and processed by gestures system
|
||||
#define SUPPORT_MOUSE_GESTURES 1
|
||||
// Reconfigure standard input to receive key inputs, works with SSH connection
|
||||
#define SUPPORT_SSH_KEYBOARD_RPI 1
|
||||
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions
|
||||
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often
|
||||
#define SUPPORT_WINMM_HIGHRES_TIMER 1
|
||||
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used
|
||||
//#define SUPPORT_BUSY_WAIT_LOOP 1
|
||||
// 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
|
||||
// Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()
|
||||
// WARNING: It also requires SUPPORT_IMAGE_EXPORT and SUPPORT_FILEFORMAT_PNG flags
|
||||
#define SUPPORT_SCREEN_CAPTURE 1
|
||||
// Support CompressData() and DecompressData() functions
|
||||
#define SUPPORT_COMPRESSION_API 1
|
||||
// Support automatic generated events, loading and recording of those events when required
|
||||
#define SUPPORT_AUTOMATION_EVENTS 1
|
||||
// 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 1
|
||||
// Support for clipboard image loading
|
||||
// NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows)
|
||||
#define SUPPORT_CLIPBOARD_IMAGE 1
|
||||
#ifndef SUPPORT_TRACELOG
|
||||
// Show TRACELOG() output messages
|
||||
#define SUPPORT_TRACELOG 1
|
||||
#endif
|
||||
#ifndef SUPPORT_CAMERA_SYSTEM
|
||||
// Camera module is included (rcamera.h) and multiple predefined
|
||||
// cameras are available: free, 1st/3rd person, orbital
|
||||
#define SUPPORT_CAMERA_SYSTEM 1
|
||||
#endif
|
||||
#ifndef SUPPORT_GESTURES_SYSTEM
|
||||
// Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag
|
||||
#define SUPPORT_GESTURES_SYSTEM 1
|
||||
#endif
|
||||
#ifndef SUPPORT_RPRAND_GENERATOR
|
||||
// Include pseudo-random numbers generator (rprand.h), based on Xoshiro128** and SplitMix64
|
||||
#define SUPPORT_RPRAND_GENERATOR 1
|
||||
#endif
|
||||
#ifndef SUPPORT_MOUSE_GESTURES
|
||||
// Mouse gestures are directly mapped like touches and processed by gestures system
|
||||
#define SUPPORT_MOUSE_GESTURES 1
|
||||
#endif
|
||||
#ifndef SUPPORT_SSH_KEYBOARD_RPI
|
||||
// Reconfigure standard input to receive key inputs, works with SSH connection
|
||||
#define SUPPORT_SSH_KEYBOARD_RPI 1
|
||||
#endif
|
||||
#ifndef SUPPORT_WINMM_HIGHRES_TIMER
|
||||
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions
|
||||
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often
|
||||
#define SUPPORT_WINMM_HIGHRES_TIMER 1
|
||||
#endif
|
||||
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && !SUPPORT_PARTIALBUSY_WAIT_LOOP
|
||||
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used
|
||||
#define SUPPORT_BUSY_WAIT_LOOP 0 // Disabled by default
|
||||
#endif
|
||||
#if !defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) && !SUPPORT_BUSY_WAIT_LOOP
|
||||
// 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
|
||||
|
||||
// NOTE: Clipboard image loading requires support for some image file formats
|
||||
// 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)
|
||||
#if SUPPORT_TRACELOG
|
||||
#define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__)
|
||||
#else
|
||||
#define TRACELOG(level, ...) (void)0
|
||||
#endif
|
||||
|
||||
// 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
|
||||
//------------------------------------------------------------------------------------
|
||||
#if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
//#define SUPPORT_GPU_SKINNING 1 // GPU skinning, comment if your GPU does not support more than 8 VBOs
|
||||
|
||||
// Enable OpenGL Debug Context (only available on OpenGL 4.3)
|
||||
//#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT 1 // OpenGL debug context requested
|
||||
|
||||
// Show OpenGL extensions and capabilities detailed logs on init
|
||||
//#define RLGL_SHOW_GL_DETAILS_INFO 1 // Show OpenGL detailed info on initialization (limits and extensions)
|
||||
#ifndef RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
|
||||
// Request OpenGL debug context (only available on OpenGL 4.3)
|
||||
#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT 0
|
||||
#endif
|
||||
#ifndef RLGL_SHOW_GL_DETAILS_INFO
|
||||
// Show OpenGL detailed info on initialization,
|
||||
// supported GL extensions and GL capabilities
|
||||
#define RLGL_SHOW_GL_DETAILS_INFO 0
|
||||
#endif
|
||||
|
||||
//#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_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_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||
|
||||
#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
|
||||
// rlgl: 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 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_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_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||
//#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
|
||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0
|
||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1
|
||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2
|
||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR 3
|
||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT 4
|
||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5
|
||||
#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_BONEWEIGHTS 8
|
||||
#endif
|
||||
#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORMS 9
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION 0
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD 1
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL 2
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR 3
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT 4
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2 5
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INDICES 6
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEINDICES 7
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8
|
||||
//#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCETRANSFORM 9
|
||||
|
||||
// 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,
|
||||
// if the following names are found in the shader, if not, it's up to the user to set locations
|
||||
#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_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_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_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_UNIFORM_NAME_MVP "mvp" // model-view-projection 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_MODEL "matModel" // model matrix
|
||||
#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_BONEMATRICES "boneMatrices" // bone matrices
|
||||
#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_TEXTURE2 "texture2" // texture2 (texture slot active 2)
|
||||
// NOTE: When a new shader is loaded, locations are tried to be set for convenience, looking for the names defined here
|
||||
// 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_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_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_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_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_VIEW "matView" // view 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_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_BONEMATRICES "boneMatrices" // bone matrices
|
||||
//#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_TEXTURE2 "texture2" // texture2 (texture slot active 2)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module: rshapes - Configuration Flags
|
||||
//------------------------------------------------------------------------------------
|
||||
#if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
// Use QUADS instead of TRIANGLES for drawing when possible
|
||||
// Some lines-based shapes could still use lines
|
||||
#define SUPPORT_QUADS_DRAW_MODE 1
|
||||
#ifndef SUPPORT_QUADS_DRAW_MODE
|
||||
// Use QUADS instead of TRIANGLES for drawing when possible
|
||||
// Some lines-based shapes could still use lines
|
||||
#define SUPPORT_QUADS_DRAW_MODE 1
|
||||
#endif
|
||||
|
||||
// rshapes: Configuration values
|
||||
//------------------------------------------------------------------------------------
|
||||
#define SPLINE_SEGMENT_DIVISIONS 24 // Spline segments subdivisions
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module: rtextures - Configuration Flags
|
||||
//------------------------------------------------------------------------------------
|
||||
#if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
// Selected desired fileformats to be supported for image data loading
|
||||
#define SUPPORT_FILEFORMAT_PNG 1
|
||||
//#define SUPPORT_FILEFORMAT_BMP 1
|
||||
//#define SUPPORT_FILEFORMAT_TGA 1
|
||||
//#define SUPPORT_FILEFORMAT_JPG 1
|
||||
#define SUPPORT_FILEFORMAT_GIF 1
|
||||
#define SUPPORT_FILEFORMAT_QOI 1
|
||||
//#define SUPPORT_FILEFORMAT_PSD 1
|
||||
#define SUPPORT_FILEFORMAT_DDS 1
|
||||
//#define SUPPORT_FILEFORMAT_HDR 1
|
||||
//#define SUPPORT_FILEFORMAT_PIC 1
|
||||
//#define SUPPORT_FILEFORMAT_KTX 1
|
||||
//#define SUPPORT_FILEFORMAT_ASTC 1
|
||||
//#define SUPPORT_FILEFORMAT_PKM 1
|
||||
//#define SUPPORT_FILEFORMAT_PVR 1
|
||||
#ifndef SUPPORT_FILEFORMAT_PNG
|
||||
#define SUPPORT_FILEFORMAT_PNG 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_BMP
|
||||
// NOTE: BMP support required for clipboard images on Windows
|
||||
#define SUPPORT_FILEFORMAT_BMP 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_TGA
|
||||
#define SUPPORT_FILEFORMAT_TGA 0 // Disabled by default
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_JPG
|
||||
#define SUPPORT_FILEFORMAT_JPG 0 // Disabled by default
|
||||
#endif
|
||||
#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)
|
||||
#define SUPPORT_IMAGE_EXPORT 1
|
||||
// Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
|
||||
#define SUPPORT_IMAGE_GENERATION 1
|
||||
// Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop...
|
||||
// If not defined, still some functions are supported: ImageFormat(), ImageCrop(), ImageToPOT()
|
||||
#define SUPPORT_IMAGE_MANIPULATION 1
|
||||
#ifndef SUPPORT_IMAGE_EXPORT
|
||||
// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
|
||||
// NOTE: Image export requires stb_image_write.h library
|
||||
#define SUPPORT_IMAGE_EXPORT 1
|
||||
#endif
|
||||
#ifndef SUPPORT_IMAGE_GENERATION
|
||||
// Support procedural image generation functionality: gradient, spot, perlin-noise, cellular...
|
||||
// NOTE: Perlin noise requires stb_perlin.h library
|
||||
#define SUPPORT_IMAGE_GENERATION 1
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// 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
|
||||
#define SUPPORT_FILEFORMAT_TTF 1
|
||||
#define SUPPORT_FILEFORMAT_FNT 1
|
||||
//#define SUPPORT_FILEFORMAT_BDF 1
|
||||
|
||||
// Support text management functions
|
||||
// If not defined, still some functions are supported: TextLength(), TextFormat()
|
||||
#define SUPPORT_TEXT_MANIPULATION 1
|
||||
|
||||
// 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
|
||||
#ifndef SUPPORT_FILEFORMAT_TTF
|
||||
#define SUPPORT_FILEFORMAT_TTF 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_FNT
|
||||
#define SUPPORT_FILEFORMAT_FNT 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_BDF
|
||||
#define SUPPORT_FILEFORMAT_BDF 0 // Disabled by default
|
||||
#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
|
||||
//------------------------------------------------------------------------------------
|
||||
#if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
// Selected desired model fileformats to be supported for loading
|
||||
#define SUPPORT_FILEFORMAT_OBJ 1
|
||||
#define SUPPORT_FILEFORMAT_MTL 1
|
||||
#define SUPPORT_FILEFORMAT_IQM 1
|
||||
#define SUPPORT_FILEFORMAT_GLTF 1
|
||||
#define SUPPORT_FILEFORMAT_VOX 1
|
||||
#define SUPPORT_FILEFORMAT_M3D 1
|
||||
// Support procedural mesh generation functions, uses external par_shapes.h library
|
||||
// NOTE: Some generated meshes DO NOT include generated texture coordinates
|
||||
#define SUPPORT_MESH_GENERATION 1
|
||||
#ifndef SUPPORT_FILEFORMAT_OBJ
|
||||
#define SUPPORT_FILEFORMAT_OBJ 1
|
||||
#endif
|
||||
|
||||
// rmodels: Configuration values
|
||||
//------------------------------------------------------------------------------------
|
||||
#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported
|
||||
|
||||
#ifdef SUPPORT_GPU_SKINNING
|
||||
// NOTE: Two additional vertex buffers required to store bone indices and bone weights
|
||||
#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
|
||||
#ifndef SUPPORT_FILEFORMAT_MTL
|
||||
#define SUPPORT_FILEFORMAT_MTL 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_IQM
|
||||
#define SUPPORT_FILEFORMAT_IQM 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_GLTF
|
||||
#define SUPPORT_FILEFORMAT_GLTF 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_VOX
|
||||
#define SUPPORT_FILEFORMAT_VOX 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_M3D
|
||||
#define SUPPORT_FILEFORMAT_M3D 1
|
||||
#endif
|
||||
#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
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module: raudio - Configuration Flags
|
||||
//------------------------------------------------------------------------------------
|
||||
#if !defined(EXTERNAL_CONFIG_FLAGS)
|
||||
// Desired audio fileformats to be supported for loading
|
||||
#define SUPPORT_FILEFORMAT_WAV 1
|
||||
#define SUPPORT_FILEFORMAT_OGG 1
|
||||
#define SUPPORT_FILEFORMAT_MP3 1
|
||||
#define SUPPORT_FILEFORMAT_QOA 1
|
||||
//#define SUPPORT_FILEFORMAT_FLAC 1
|
||||
#define SUPPORT_FILEFORMAT_XM 1
|
||||
#define SUPPORT_FILEFORMAT_MOD 1
|
||||
#ifndef SUPPORT_FILEFORMAT_WAV
|
||||
#define SUPPORT_FILEFORMAT_WAV 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_OGG
|
||||
#define SUPPORT_FILEFORMAT_OGG 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_MP3
|
||||
#define SUPPORT_FILEFORMAT_MP3 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_QOA
|
||||
#define SUPPORT_FILEFORMAT_QOA 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_FLAC
|
||||
#define SUPPORT_FILEFORMAT_FLAC 0 // Disabled by default
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_XM
|
||||
#define SUPPORT_FILEFORMAT_XM 1
|
||||
#endif
|
||||
#ifndef SUPPORT_FILEFORMAT_MOD
|
||||
#define SUPPORT_FILEFORMAT_MOD 1
|
||||
#endif
|
||||
|
||||
// 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
|
||||
|
||||
4
src/external/rlsw.h
vendored
4
src/external/rlsw.h
vendored
@@ -644,7 +644,7 @@ SWAPI void swBindTexture(uint32_t id);
|
||||
#define SW_ARCH_RISCV
|
||||
#endif
|
||||
|
||||
#if defined(RLSW_USE_SIMD_INTRINSICS)
|
||||
#if RLSW_USE_SIMD_INTRINSICS
|
||||
// Check for SIMD vector instructions
|
||||
// NOTE: Compiler is responsible to enable required flags for host device,
|
||||
// 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
|
||||
#include <riscv_vector.h>
|
||||
#endif
|
||||
#endif // RLSW_USE_SIMD_INTRINSICS
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define SW_CURLY_INIT(name) name
|
||||
|
||||
@@ -713,7 +713,7 @@ const char *GetKeyName(int key)
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
// NOTE: Gestures update must be called every frame to reset gestures correctly
|
||||
// because ProcessGestureEvent() is just called on an event, not every frame
|
||||
UpdateGestures();
|
||||
@@ -1065,11 +1065,11 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
|
||||
// Initialize hi-res timer
|
||||
InitTimer();
|
||||
|
||||
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
|
||||
#if SUPPORT_MODULE_RTEXT
|
||||
// Load default font
|
||||
// WARNING: External function: Module required: rtext
|
||||
LoadFontDefault();
|
||||
#if defined(SUPPORT_MODULE_RSHAPES)
|
||||
#if SUPPORT_MODULE_RSHAPES
|
||||
// Set font white rectangle for shapes drawing, so shapes and text can be batched together
|
||||
// WARNING: rshapes module is required, if not available, default internal white rectangle is used
|
||||
Rectangle rec = GetFontDefault().recs[95];
|
||||
@@ -1085,7 +1085,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#if defined(SUPPORT_MODULE_RSHAPES)
|
||||
#if SUPPORT_MODULE_RSHAPES
|
||||
// Set default texture and rectangle to be used for shapes drawing
|
||||
// NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
|
||||
Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
|
||||
@@ -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.pointCount = 0;
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
#define GLFW_NATIVE_INCLUDE_NONE // To avoid some symbols re-definition in windows.h
|
||||
#include "GLFW/glfw3native.h"
|
||||
|
||||
#if defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
#if SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP
|
||||
// NOTE: Those functions require linking with winmm library
|
||||
//#pragma warning(disable: 4273)
|
||||
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
|
||||
@@ -1048,7 +1048,7 @@ Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#if SUPPORT_CLIPBOARD_IMAGE
|
||||
#if defined(_WIN32)
|
||||
unsigned long long int dataSize = 0;
|
||||
void *bmpData = NULL;
|
||||
@@ -1062,7 +1062,7 @@ Image GetClipboardImage(void)
|
||||
#else
|
||||
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
|
||||
#endif
|
||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
||||
#endif
|
||||
|
||||
return image;
|
||||
}
|
||||
@@ -1202,7 +1202,7 @@ const char *GetKeyName(int key)
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
// NOTE: Gestures update must be called every frame to reset gestures correctly
|
||||
// because ProcessGestureEvent() is just called on an event, not every frame
|
||||
UpdateGestures();
|
||||
@@ -1514,7 +1514,7 @@ int InitPlatform(void)
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
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
|
||||
#endif
|
||||
}
|
||||
@@ -1819,7 +1819,7 @@ void ClosePlatform(void)
|
||||
glfwDestroyWindow(platform.handle);
|
||||
glfwTerminate();
|
||||
|
||||
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
#if defined(_WIN32) && SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP
|
||||
timeEndPeriod(1); // Restore time period
|
||||
#endif
|
||||
}
|
||||
@@ -2049,7 +2049,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
|
||||
CORE.Input.Mouse.currentButtonState[button] = action;
|
||||
CORE.Input.Touch.currentTouchState[button] = action;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES)
|
||||
#if SUPPORT_GESTURES_SYSTEM && defined(SUPPORT_MOUSE_GESTURES)
|
||||
// Process mouse events as touches to be able to use mouse-gestures
|
||||
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.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
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
|
||||
@@ -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
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // USING_VERSION_SDL3
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@@ -1163,7 +1162,7 @@ Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#if SUPPORT_CLIPBOARD_IMAGE
|
||||
// Let's hope compiler put these arrays in static memory
|
||||
const char *imageFormats[] = {
|
||||
"image/bmp",
|
||||
@@ -1350,7 +1349,7 @@ const char *GetKeyName(int key)
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
// NOTE: Gestures update must be called every frame to reset gestures correctly
|
||||
// because ProcessGestureEvent() is just called on an event, not every frame
|
||||
UpdateGestures();
|
||||
@@ -1892,7 +1891,7 @@ void PollInputEvents(void)
|
||||
default: break;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
if (touchAction > -1)
|
||||
{
|
||||
// Process mouse events as touches to be able to use mouse-gestures
|
||||
@@ -1989,7 +1988,7 @@ int InitPlatform(void)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||
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
|
||||
#endif
|
||||
}
|
||||
@@ -2113,7 +2112,7 @@ int InitPlatform(void)
|
||||
// NOTE: No need to call InitTimer(), let SDL manage it internally
|
||||
CORE.Time.previous = GetTime(); // Get time as double
|
||||
|
||||
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
#if defined(_WIN32) && SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP
|
||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "1"); // SDL equivalent of timeBeginPeriod() and timeEndPeriod()
|
||||
#endif
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
#include <errno.h> // Required for: EBUSY, EAGAIN
|
||||
|
||||
#define MAX_DRM_CACHED_BUFFERS 3
|
||||
#endif // SUPPORT_DRM_CACHE
|
||||
#endif
|
||||
|
||||
#ifndef EGL_OPENGL_ES3_BIT
|
||||
#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 bool pendingFlip = false;
|
||||
static bool crtcSet = false;
|
||||
#endif // SUPPORT_DRM_CACHE
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
@@ -253,7 +253,7 @@ static const short linuxToRaylibMap[KEYMAP_SIZE] = {
|
||||
int InitPlatform(void); // Initialize platform (graphics, inputs and more)
|
||||
void ClosePlatform(void); // Close platform
|
||||
|
||||
#if defined(SUPPORT_SSH_KEYBOARD_RPI)
|
||||
#if SUPPORT_SSH_KEYBOARD_RPI
|
||||
static void InitKeyboard(void); // Initialize raw keyboard system
|
||||
static void RestoreKeyboard(void); // Restore keyboard system
|
||||
static void ProcessKeyboard(void); // Process keyboard events
|
||||
@@ -1065,7 +1065,7 @@ const char *GetKeyName(int key)
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
// NOTE: Gestures update must be called every frame to reset gestures correctly
|
||||
// because ProcessGestureEvent() is just called on an event, not every frame
|
||||
UpdateGestures();
|
||||
@@ -1088,7 +1088,7 @@ void PollInputEvents(void)
|
||||
|
||||
PollKeyboardEvents();
|
||||
|
||||
#if defined(SUPPORT_SSH_KEYBOARD_RPI)
|
||||
#if SUPPORT_SSH_KEYBOARD_RPI
|
||||
// NOTE: Keyboard reading could be done using input_event(s) or just read from stdin, both methods are used here
|
||||
// stdin reading is still used for legacy purposes, it allows keyboard input trough SSH console
|
||||
if (!platform.eventKeyboardMode) ProcessKeyboard();
|
||||
@@ -1621,7 +1621,7 @@ int InitPlatform(void)
|
||||
//----------------------------------------------------------------------------
|
||||
InitEvdevInput(); // Evdev inputs initialization
|
||||
|
||||
#if defined(SUPPORT_SSH_KEYBOARD_RPI)
|
||||
#if SUPPORT_SSH_KEYBOARD_RPI
|
||||
InitKeyboard(); // Keyboard init (stdin)
|
||||
#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)
|
||||
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>)
|
||||
// this means mouse, keyboard or gamepad devices
|
||||
@@ -2196,7 +2196,7 @@ static void PollKeyboardEvents(void)
|
||||
// Check if the event is a key event
|
||||
if (event.type != EV_KEY) continue;
|
||||
|
||||
#if defined(SUPPORT_SSH_KEYBOARD_RPI)
|
||||
#if SUPPORT_SSH_KEYBOARD_RPI
|
||||
// If the event was a key, we know a working keyboard is connected, so disable the SSH keyboard
|
||||
platform.eventKeyboardMode = true;
|
||||
#endif
|
||||
@@ -2552,7 +2552,7 @@ static void PollMouseEvents(void)
|
||||
CORE.Input.Touch.pointId[i] = -1;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
if (touchAction > -1)
|
||||
{
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
@@ -435,7 +435,7 @@ const char *GetKeyName(int key)
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
// NOTE: Gestures update must be called every frame to reset gestures correctly
|
||||
// because ProcessGestureEvent() is just called on an event, not every frame
|
||||
UpdateGestures();
|
||||
|
||||
@@ -1007,7 +1007,7 @@ const char *GetKeyName(int key)
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
// NOTE: Gestures update must be called every frame to reset gestures correctly
|
||||
// because ProcessGestureEvent() is just called on an event, not every frame
|
||||
UpdateGestures();
|
||||
@@ -1210,7 +1210,7 @@ int InitPlatform(void)
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
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
|
||||
#endif
|
||||
}
|
||||
@@ -1475,15 +1475,15 @@ static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float s
|
||||
// GLFW3: Called on windows minimized/restored
|
||||
static void WindowIconifyCallback(GLFWwindow *window, int 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
|
||||
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
|
||||
}
|
||||
|
||||
// GLFW3: Called on windows get/lose focus
|
||||
static void WindowFocusCallback(GLFWwindow *window, int 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
|
||||
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
|
||||
}
|
||||
|
||||
// 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.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
|
||||
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;
|
||||
}
|
||||
|
||||
#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
|
||||
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;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
gestureEvent.pointCount = CORE.Input.Touch.pointCount;
|
||||
|
||||
|
||||
@@ -983,7 +983,7 @@ const char *GetKeyName(int key)
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
// NOTE: Gestures update must be called every frame to reset gestures correctly
|
||||
// because ProcessGestureEvent() is just called on an event, not every frame
|
||||
UpdateGestures();
|
||||
@@ -1321,7 +1321,7 @@ static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent
|
||||
|
||||
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;
|
||||
default: consumed = 0; break;
|
||||
}
|
||||
@@ -1457,7 +1457,7 @@ static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent
|
||||
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
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
|
||||
@@ -1529,7 +1529,7 @@ static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseE
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
gestureEvent.pointCount = CORE.Input.Touch.pointCount;
|
||||
|
||||
|
||||
114
src/raudio.c
114
src/raudio.c
@@ -77,7 +77,7 @@
|
||||
#include "config.h" // Defines module configuration flags
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_MODULE_RAUDIO) || defined(RAUDIO_STANDALONE)
|
||||
#if SUPPORT_MODULE_RAUDIO || defined(RAUDIO_STANDALONE)
|
||||
|
||||
#if defined(_WIN32)
|
||||
// To avoid conflicting windows.h symbols with raylib, some flags are defined
|
||||
@@ -205,7 +205,7 @@ typedef struct tagBITMAPINFOHEADER {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
#define DRWAV_MALLOC RL_MALLOC
|
||||
#define DRWAV_REALLOC RL_REALLOC
|
||||
#define DRWAV_FREE RL_FREE
|
||||
@@ -214,12 +214,12 @@ typedef struct tagBITMAPINFOHEADER {
|
||||
#include "external/dr_wav.h" // WAV loading functions
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
#if SUPPORT_FILEFORMAT_OGG
|
||||
// TODO: Remap stb_vorbis malloc()/free() calls to RL_MALLOC/RL_FREE
|
||||
#include "external/stb_vorbis.c" // OGG loading functions
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
#if SUPPORT_FILEFORMAT_MP3
|
||||
#define DRMP3_MALLOC RL_MALLOC
|
||||
#define DRMP3_REALLOC RL_REALLOC
|
||||
#define DRMP3_FREE RL_FREE
|
||||
@@ -228,7 +228,7 @@ typedef struct tagBITMAPINFOHEADER {
|
||||
#include "external/dr_mp3.h" // MP3 loading functions
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
#define QOA_MALLOC RL_MALLOC
|
||||
#define QOA_FREE RL_FREE
|
||||
|
||||
@@ -248,7 +248,7 @@ typedef struct tagBITMAPINFOHEADER {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
#if SUPPORT_FILEFORMAT_FLAC
|
||||
#define DRFLAC_MALLOC RL_MALLOC
|
||||
#define DRFLAC_REALLOC RL_REALLOC
|
||||
#define DRFLAC_FREE RL_FREE
|
||||
@@ -258,7 +258,7 @@ typedef struct tagBITMAPINFOHEADER {
|
||||
#include "external/dr_flac.h" // FLAC loading functions
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||
#if SUPPORT_FILEFORMAT_XM
|
||||
#define JARXM_MALLOC RL_MALLOC
|
||||
#define JARXM_FREE RL_FREE
|
||||
|
||||
@@ -275,7 +275,7 @@ typedef struct tagBITMAPINFOHEADER {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||
#if SUPPORT_FILEFORMAT_MOD
|
||||
#define JARMOD_MALLOC RL_MALLOC
|
||||
#define JARMOD_FREE RL_FREE
|
||||
|
||||
@@ -813,7 +813,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||
Wave wave = { 0 };
|
||||
|
||||
if (false) { }
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0))
|
||||
{
|
||||
drwav wav = { 0 };
|
||||
@@ -835,7 +835,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||
drwav_uninit(&wav);
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
#if SUPPORT_FILEFORMAT_OGG
|
||||
else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0))
|
||||
{
|
||||
stb_vorbis *oggData = stb_vorbis_open_memory((unsigned char *)fileData, dataSize, NULL, NULL);
|
||||
@@ -857,7 +857,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||
else TRACELOG(LOG_WARNING, "WAVE: Failed to load OGG data");
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
#if SUPPORT_FILEFORMAT_MP3
|
||||
else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0))
|
||||
{
|
||||
drmp3_config config = { 0 };
|
||||
@@ -877,7 +877,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0))
|
||||
{
|
||||
qoa_desc qoa = { 0 };
|
||||
@@ -896,7 +896,7 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
#if SUPPORT_FILEFORMAT_FLAC
|
||||
else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0))
|
||||
{
|
||||
unsigned long long int totalFrameCount = 0;
|
||||
@@ -1078,7 +1078,7 @@ bool ExportWave(Wave wave, const char *fileName)
|
||||
bool success = false;
|
||||
|
||||
if (false) { }
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
else if (IsFileExtension(fileName, ".wav"))
|
||||
{
|
||||
drwav wav = { 0 };
|
||||
@@ -1101,7 +1101,7 @@ bool ExportWave(Wave wave, const char *fileName)
|
||||
drwav_free(fileData, NULL);
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
else if (IsFileExtension(fileName, ".qoa"))
|
||||
{
|
||||
if (wave.sampleSize == 16)
|
||||
@@ -1359,7 +1359,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
bool musicLoaded = false;
|
||||
|
||||
if (false) { }
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
else if (IsFileExtension(fileName, ".wav"))
|
||||
{
|
||||
drwav *ctxWav = (drwav *)RL_CALLOC(1, sizeof(drwav));
|
||||
@@ -1383,7 +1383,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
#if SUPPORT_FILEFORMAT_OGG
|
||||
else if (IsFileExtension(fileName, ".ogg"))
|
||||
{
|
||||
// Open ogg audio stream
|
||||
@@ -1409,7 +1409,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
#if SUPPORT_FILEFORMAT_MP3
|
||||
else if (IsFileExtension(fileName, ".mp3"))
|
||||
{
|
||||
drmp3 *ctxMp3 = (drmp3 *)RL_CALLOC(1, sizeof(drmp3));
|
||||
@@ -1430,7 +1430,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
else if (IsFileExtension(fileName, ".qoa"))
|
||||
{
|
||||
qoaplay_desc *ctxQoa = qoaplay_open(fileName);
|
||||
@@ -1449,7 +1449,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
else{} //No uninit required
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
#if SUPPORT_FILEFORMAT_FLAC
|
||||
else if (IsFileExtension(fileName, ".flac"))
|
||||
{
|
||||
drflac *ctxFlac = drflac_open_file(fileName, NULL);
|
||||
@@ -1471,7 +1471,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||
#if SUPPORT_FILEFORMAT_XM
|
||||
else if (IsFileExtension(fileName, ".xm"))
|
||||
{
|
||||
jar_xm_context_t *ctxXm = NULL;
|
||||
@@ -1500,7 +1500,7 @@ Music LoadMusicStream(const char *fileName)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||
#if SUPPORT_FILEFORMAT_MOD
|
||||
else if (IsFileExtension(fileName, ".mod"))
|
||||
{
|
||||
jar_mod_context_t *ctxMod = (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;
|
||||
|
||||
if (false) { }
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
else if ((strcmp(fileType, ".wav") == 0) || (strcmp(fileType, ".WAV") == 0))
|
||||
{
|
||||
drwav *ctxWav = (drwav *)RL_CALLOC(1, sizeof(drwav));
|
||||
@@ -1577,7 +1577,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
#if SUPPORT_FILEFORMAT_OGG
|
||||
else if ((strcmp(fileType, ".ogg") == 0) || (strcmp(fileType, ".OGG") == 0))
|
||||
{
|
||||
// Open ogg audio stream
|
||||
@@ -1603,7 +1603,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
#if SUPPORT_FILEFORMAT_MP3
|
||||
else if ((strcmp(fileType, ".mp3") == 0) || (strcmp(fileType, ".MP3") == 0))
|
||||
{
|
||||
drmp3 *ctxMp3 = (drmp3 *)RL_CALLOC(1, sizeof(drmp3));
|
||||
@@ -1625,7 +1625,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
else if ((strcmp(fileType, ".qoa") == 0) || (strcmp(fileType, ".QOA") == 0))
|
||||
{
|
||||
qoaplay_desc *ctxQoa = NULL;
|
||||
@@ -1648,7 +1648,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
|
||||
else{} //No uninit required
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
#if SUPPORT_FILEFORMAT_FLAC
|
||||
else if ((strcmp(fileType, ".flac") == 0) || (strcmp(fileType, ".FLAC") == 0))
|
||||
{
|
||||
drflac *ctxFlac = drflac_open_memory((const void *)data, dataSize, NULL);
|
||||
@@ -1670,7 +1670,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||
#if SUPPORT_FILEFORMAT_XM
|
||||
else if ((strcmp(fileType, ".xm") == 0) || (strcmp(fileType, ".XM") == 0))
|
||||
{
|
||||
jar_xm_context_t *ctxXm = NULL;
|
||||
@@ -1699,7 +1699,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||
#if SUPPORT_FILEFORMAT_MOD
|
||||
else if ((strcmp(fileType, ".mod") == 0) || (strcmp(fileType, ".MOD") == 0))
|
||||
{
|
||||
jar_mod_context_t *ctxMod = (jar_mod_context_t *)RL_MALLOC(sizeof(jar_mod_context_t));
|
||||
@@ -1775,25 +1775,25 @@ void UnloadMusicStream(Music music)
|
||||
if (music.ctxData != NULL)
|
||||
{
|
||||
if (false) { }
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
else if (music.ctxType == MUSIC_AUDIO_WAV) drwav_uninit((drwav *)music.ctxData);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
#if SUPPORT_FILEFORMAT_OGG
|
||||
else if (music.ctxType == MUSIC_AUDIO_OGG) stb_vorbis_close((stb_vorbis *)music.ctxData);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
#if SUPPORT_FILEFORMAT_MP3
|
||||
else if (music.ctxType == MUSIC_AUDIO_MP3) { drmp3_uninit((drmp3 *)music.ctxData); RL_FREE(music.ctxData); }
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
else if (music.ctxType == MUSIC_AUDIO_QOA) qoaplay_close((qoaplay_desc *)music.ctxData);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
#if SUPPORT_FILEFORMAT_FLAC
|
||||
else if (music.ctxType == MUSIC_AUDIO_FLAC) { drflac_close((drflac *)music.ctxData); drflac_free((drflac *)music.ctxData, NULL); }
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||
#if SUPPORT_FILEFORMAT_XM
|
||||
else if (music.ctxType == MUSIC_MODULE_XM) jar_xm_free_context((jar_xm_context_t *)music.ctxData);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||
#if SUPPORT_FILEFORMAT_MOD
|
||||
else if (music.ctxType == MUSIC_MODULE_MOD) { jar_mod_unload((jar_mod_context_t *)music.ctxData); RL_FREE(music.ctxData); }
|
||||
#endif
|
||||
}
|
||||
@@ -1824,25 +1824,25 @@ void StopMusicStream(Music music)
|
||||
|
||||
switch (music.ctxType)
|
||||
{
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
case MUSIC_AUDIO_WAV: drwav_seek_to_first_pcm_frame((drwav *)music.ctxData); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
#if SUPPORT_FILEFORMAT_OGG
|
||||
case MUSIC_AUDIO_OGG: stb_vorbis_seek_start((stb_vorbis *)music.ctxData); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
#if SUPPORT_FILEFORMAT_MP3
|
||||
case MUSIC_AUDIO_MP3: drmp3_seek_to_start_of_stream((drmp3 *)music.ctxData); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
case MUSIC_AUDIO_QOA: qoaplay_rewind((qoaplay_desc *)music.ctxData); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
#if SUPPORT_FILEFORMAT_FLAC
|
||||
case MUSIC_AUDIO_FLAC: drflac__seek_to_first_frame((drflac *)music.ctxData); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||
#if SUPPORT_FILEFORMAT_XM
|
||||
case MUSIC_MODULE_XM: jar_xm_reset((jar_xm_context_t *)music.ctxData); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||
#if SUPPORT_FILEFORMAT_MOD
|
||||
case MUSIC_MODULE_MOD: jar_mod_seek_start((jar_mod_context_t *)music.ctxData); break;
|
||||
#endif
|
||||
default: break;
|
||||
@@ -1859,16 +1859,16 @@ void SeekMusicStream(Music music, float position)
|
||||
|
||||
switch (music.ctxType)
|
||||
{
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
case MUSIC_AUDIO_WAV: drwav_seek_to_pcm_frame((drwav *)music.ctxData, positionInFrames); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
#if SUPPORT_FILEFORMAT_OGG
|
||||
case MUSIC_AUDIO_OGG: stb_vorbis_seek_frame((stb_vorbis *)music.ctxData, positionInFrames); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
#if SUPPORT_FILEFORMAT_MP3
|
||||
case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
case MUSIC_AUDIO_QOA:
|
||||
{
|
||||
int qoaFrame = positionInFrames/QOA_FRAME_LEN;
|
||||
@@ -1878,7 +1878,7 @@ void SeekMusicStream(Music music, float position)
|
||||
positionInFrames = ((qoaplay_desc *)music.ctxData)->sample_position;
|
||||
} break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
#if SUPPORT_FILEFORMAT_FLAC
|
||||
case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break;
|
||||
#endif
|
||||
default: break;
|
||||
@@ -1942,7 +1942,7 @@ void UpdateMusicStream(Music music)
|
||||
|
||||
switch (music.ctxType)
|
||||
{
|
||||
#if defined(SUPPORT_FILEFORMAT_WAV)
|
||||
#if SUPPORT_FILEFORMAT_WAV
|
||||
case MUSIC_AUDIO_WAV:
|
||||
{
|
||||
if (music.stream.sampleSize == 16)
|
||||
@@ -1969,7 +1969,7 @@ void UpdateMusicStream(Music music)
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OGG)
|
||||
#if SUPPORT_FILEFORMAT_OGG
|
||||
case MUSIC_AUDIO_OGG:
|
||||
{
|
||||
while (true)
|
||||
@@ -1982,7 +1982,7 @@ void UpdateMusicStream(Music music)
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MP3)
|
||||
#if SUPPORT_FILEFORMAT_MP3
|
||||
case MUSIC_AUDIO_MP3:
|
||||
{
|
||||
while (true)
|
||||
@@ -1995,7 +1995,7 @@ void UpdateMusicStream(Music music)
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOA)
|
||||
#if SUPPORT_FILEFORMAT_QOA
|
||||
case MUSIC_AUDIO_QOA:
|
||||
{
|
||||
unsigned int frameCountRead = qoaplay_decode((qoaplay_desc *)music.ctxData, (float *)AUDIO.System.pcmBuffer, framesToStream);
|
||||
@@ -2012,7 +2012,7 @@ void UpdateMusicStream(Music music)
|
||||
*/
|
||||
} break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FLAC)
|
||||
#if SUPPORT_FILEFORMAT_FLAC
|
||||
case MUSIC_AUDIO_FLAC:
|
||||
{
|
||||
while (true)
|
||||
@@ -2025,7 +2025,7 @@ void UpdateMusicStream(Music music)
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||
#if SUPPORT_FILEFORMAT_XM
|
||||
case MUSIC_MODULE_XM:
|
||||
{
|
||||
// NOTE: Internally we consider 2 channels generation, so sampleCount/2
|
||||
@@ -2036,7 +2036,7 @@ void UpdateMusicStream(Music music)
|
||||
|
||||
} break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||
#if SUPPORT_FILEFORMAT_MOD
|
||||
case MUSIC_MODULE_MOD:
|
||||
{
|
||||
// NOTE: 3rd parameter (nbsample) specify the number of stereo 16bits samples desired, so sampleCount/2
|
||||
@@ -2094,7 +2094,7 @@ float GetMusicTimePlayed(Music music)
|
||||
float secondsPlayed = 0.0f;
|
||||
if (music.stream.buffer != NULL)
|
||||
{
|
||||
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||
#if SUPPORT_FILEFORMAT_XM
|
||||
if (music.ctxType == MUSIC_MODULE_XM)
|
||||
{
|
||||
uint64_t framesPlayed = 0;
|
||||
@@ -2952,4 +2952,4 @@ static bool SaveFileText(const char *fileName, char *text)
|
||||
|
||||
#undef AudioBuffer
|
||||
|
||||
#endif // SUPPORT_MODULE_RAUDIO
|
||||
#endif // SUPPORT_MODULE_RAUDIO
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* #define RAYMATH_DISABLE_CPP_OPERATORS
|
||||
* 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()
|
||||
* 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
|
||||
@@ -180,7 +180,7 @@ typedef struct float16 {
|
||||
|
||||
#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()
|
||||
// NOTE: Only SSE intrinsics support implemented
|
||||
// TODO: Consider support for other SIMD instrinsics:
|
||||
@@ -3112,6 +3112,6 @@ inline const Matrix& operator *= (Matrix& lhs, const Matrix& rhs)
|
||||
return lhs;
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
#endif // C++ operators
|
||||
#endif // C++ operators
|
||||
|
||||
#endif // RAYMATH_H
|
||||
#endif // RAYMATH_H
|
||||
|
||||
198
src/rcore.c
198
src/rcore.c
@@ -35,10 +35,6 @@
|
||||
* - Memory framebuffer output, using software renderer, no OS required
|
||||
*
|
||||
* 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
|
||||
* Camera module is included (rcamera.h) and multiple predefined cameras are available:
|
||||
* free, 1st/3rd person, orbital, custom
|
||||
@@ -126,17 +122,17 @@
|
||||
#define RAYMATH_IMPLEMENTATION
|
||||
#include "raymath.h" // Vector2, Vector3, Quaternion and Matrix functionality
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
#define RGESTURES_IMPLEMENTATION
|
||||
#include "rgestures.h" // Gestures detection functionality
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_CAMERA_SYSTEM)
|
||||
#if SUPPORT_CAMERA_SYSTEM
|
||||
#define RCAMERA_IMPLEMENTATION
|
||||
#include "rcamera.h" // Camera system functionality
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_COMPRESSION_API)
|
||||
#if SUPPORT_COMPRESSION_API
|
||||
#define SINFL_IMPLEMENTATION
|
||||
#define SINFL_NO_SIMD
|
||||
#include "external/sinfl.h" // Deflate (RFC 1951) decompressor
|
||||
@@ -145,7 +141,7 @@
|
||||
#include "external/sdefl.h" // Deflate (RFC 1951) compressor
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_RPRAND_GENERATOR)
|
||||
#if SUPPORT_RPRAND_GENERATOR
|
||||
#define RPRAND_IMPLEMENTATION
|
||||
#include "external/rprand.h"
|
||||
#endif
|
||||
@@ -181,7 +177,7 @@
|
||||
#elif defined(__APPLE__)
|
||||
#include <sys/syslimits.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#endif // OSs
|
||||
#endif
|
||||
|
||||
#define _CRT_INTERNAL_NONSTDC_NAMES 1
|
||||
#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 SaveFileTextCallback saveFileText = NULL; // SaveFileText callback function pointer
|
||||
|
||||
#if defined(SUPPORT_SCREEN_CAPTURE)
|
||||
#if SUPPORT_SCREEN_CAPTURE
|
||||
static int screenshotCounter = 0; // Screenshots counter
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
// Automation events type
|
||||
typedef enum AutomationEventType {
|
||||
EVENT_NONE = 0,
|
||||
@@ -503,8 +499,7 @@ static bool automationEventRecording = false; // Recording automat
|
||||
// Module Functions Declaration
|
||||
// NOTE: Those functions are common for all platforms!
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
|
||||
#if SUPPORT_MODULE_RTEXT
|
||||
extern void LoadFontDefault(void); // [Module: text] Loads default font on InitWindow()
|
||||
extern void UnloadFontDefault(void); // [Module: text] Unloads default font from GPU memory
|
||||
#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
|
||||
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
static void RecordAutomationEvent(void); // Record frame events (to internal events array)
|
||||
#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()
|
||||
#endif
|
||||
|
||||
#if !defined(SUPPORT_MODULE_RTEXT)
|
||||
#if !SUPPORT_MODULE_RTEXT
|
||||
const char *TextFormat(const char *text, ...); // Formatting of text with variables to 'embed'
|
||||
#endif // !SUPPORT_MODULE_RTEXT
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
#define PLATFORM_DESKTOP_GLFW
|
||||
#endif
|
||||
|
||||
// Using '#pragma message' because '#warning' is not adopted by MSVC
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#if !defined(SUPPORT_MODULE_RTEXTURES)
|
||||
#if SUPPORT_CLIPBOARD_IMAGE
|
||||
#if !SUPPORT_MODULE_RTEXTURES
|
||||
#pragma message ("WARNING: Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_MODULE_RTEXTURES to work properly")
|
||||
#endif
|
||||
|
||||
// It's nice to have support Bitmap on Linux as well, but not as necessary as Windows
|
||||
#if !defined(SUPPORT_FILEFORMAT_BMP) && defined(_WIN32)
|
||||
#if !SUPPORT_FILEFORMAT_BMP && defined(_WIN32)
|
||||
#pragma message ("WARNING: Enabling SUPPORT_CLIPBOARD_IMAGE requires SUPPORT_FILEFORMAT_BMP, specially on Windows")
|
||||
#endif
|
||||
|
||||
// From what I've tested applications on Wayland saves images on clipboard as PNG
|
||||
#if (!defined(SUPPORT_FILEFORMAT_PNG) || !defined(SUPPORT_FILEFORMAT_JPG)) && !defined(_WIN32)
|
||||
#if (!SUPPORT_FILEFORMAT_PNG || !SUPPORT_FILEFORMAT_JPG) && !defined(_WIN32)
|
||||
#pragma message ("WARNING: Getting image from the clipboard might not work without SUPPORT_FILEFORMAT_PNG or SUPPORT_FILEFORMAT_JPG")
|
||||
#endif
|
||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
||||
#endif
|
||||
|
||||
// Include platform-specific submodules
|
||||
#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, " > rcore:..... loaded (mandatory)");
|
||||
TRACELOG(LOG_INFO, " > rlgl:...... loaded (mandatory)");
|
||||
#if defined(SUPPORT_MODULE_RSHAPES)
|
||||
#if SUPPORT_MODULE_RSHAPES
|
||||
TRACELOG(LOG_INFO, " > rshapes:... loaded (optional)");
|
||||
#else
|
||||
TRACELOG(LOG_INFO, " > rshapes:... not loaded (optional)");
|
||||
#endif
|
||||
#if defined(SUPPORT_MODULE_RTEXTURES)
|
||||
#if SUPPORT_MODULE_RTEXTURES
|
||||
TRACELOG(LOG_INFO, " > rtextures:. loaded (optional)");
|
||||
#else
|
||||
TRACELOG(LOG_INFO, " > rtextures:. not loaded (optional)");
|
||||
#endif
|
||||
#if defined(SUPPORT_MODULE_RTEXT)
|
||||
#if SUPPORT_MODULE_RTEXT
|
||||
TRACELOG(LOG_INFO, " > rtext:..... loaded (optional)");
|
||||
#else
|
||||
TRACELOG(LOG_INFO, " > rtext:..... not loaded (optional)");
|
||||
#endif
|
||||
#if defined(SUPPORT_MODULE_RMODELS)
|
||||
#if SUPPORT_MODULE_RMODELS
|
||||
TRACELOG(LOG_INFO, " > rmodels:... loaded (optional)");
|
||||
#else
|
||||
TRACELOG(LOG_INFO, " > rmodels:... not loaded (optional)");
|
||||
#endif
|
||||
#if defined(SUPPORT_MODULE_RAUDIO)
|
||||
#if SUPPORT_MODULE_RAUDIO
|
||||
TRACELOG(LOG_INFO, " > raudio:.... loaded (optional)");
|
||||
#else
|
||||
TRACELOG(LOG_INFO, " > raudio:.... not loaded (optional)");
|
||||
@@ -712,29 +707,27 @@ void InitWindow(int width, int height, const char *title)
|
||||
// Setup default viewport
|
||||
SetupViewport(CORE.Window.render.width, CORE.Window.render.height);
|
||||
|
||||
#if defined(SUPPORT_MODULE_RTEXT)
|
||||
#if defined(SUPPORT_DEFAULT_FONT)
|
||||
// Load default font
|
||||
// WARNING: External function: Module required: rtext
|
||||
LoadFontDefault();
|
||||
#if defined(SUPPORT_MODULE_RSHAPES)
|
||||
// Set font white rectangle for shapes drawing, so shapes and text can be batched together
|
||||
// WARNING: rshapes module is required, if not available, default internal white rectangle is used
|
||||
Rectangle rec = GetFontDefault().recs[95];
|
||||
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
|
||||
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 });
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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 });
|
||||
}
|
||||
#endif
|
||||
#if SUPPORT_MODULE_RTEXT
|
||||
// Load default font
|
||||
// WARNING: External function: Module required: rtext
|
||||
LoadFontDefault();
|
||||
#if SUPPORT_MODULE_RSHAPES
|
||||
// Set font white rectangle for shapes drawing, so shapes and text can be batched together
|
||||
// WARNING: rshapes module is required, if not available, default internal white rectangle is used
|
||||
Rectangle rec = GetFontDefault().recs[95];
|
||||
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
|
||||
SetShapesTexture(GetFontDefault().texture, (Rectangle){ rec.x + 2, rec.y + 2, 1, 1 });
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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 });
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#if defined(SUPPORT_MODULE_RSHAPES)
|
||||
#if SUPPORT_MODULE_RSHAPES
|
||||
// Set default texture and rectangle to be used for shapes drawing
|
||||
// NOTE: rlgl default texture is a 1x1 pixel UNCOMPRESSED_R8G8B8A8
|
||||
Texture2D texture = { rlGetTextureIdDefault(), 1, 1, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
|
||||
@@ -754,7 +747,7 @@ void InitWindow(int width, int height, const char *title)
|
||||
// Close window and unload OpenGL context
|
||||
void CloseWindow(void)
|
||||
{
|
||||
#if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_DEFAULT_FONT)
|
||||
#if SUPPORT_MODULE_RTEXT
|
||||
UnloadFontDefault(); // WARNING: Module required: rtext
|
||||
#endif
|
||||
|
||||
@@ -908,11 +901,11 @@ void EndDrawing(void)
|
||||
{
|
||||
rlDrawRenderBatchActive(); // Update and draw internal render batch
|
||||
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
if (automationEventRecording) RecordAutomationEvent(); // Event recording
|
||||
#endif
|
||||
|
||||
#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL)
|
||||
#if !SUPPORT_CUSTOM_FRAME_CONTROL
|
||||
SwapScreenBuffer(); // Copy back buffer to front buffer (screen)
|
||||
|
||||
// Frame time control system
|
||||
@@ -937,13 +930,13 @@ void EndDrawing(void)
|
||||
PollInputEvents(); // Poll user events (before next frame update)
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_SCREEN_CAPTURE)
|
||||
#if SUPPORT_SCREEN_CAPTURE
|
||||
if (IsKeyPressed(KEY_F12))
|
||||
{
|
||||
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
|
||||
screenshotCounter++;
|
||||
}
|
||||
#endif // SUPPORT_SCREEN_CAPTURE
|
||||
#endif
|
||||
|
||||
CORE.Time.frameCounter++;
|
||||
}
|
||||
@@ -1674,14 +1667,14 @@ void WaitTime(double seconds)
|
||||
{
|
||||
if (seconds < 0) return; // Security check
|
||||
|
||||
#if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
|
||||
#if SUPPORT_BUSY_WAIT_LOOP || SUPPORT_PARTIALBUSY_WAIT_LOOP
|
||||
double destinationTime = GetTime() + seconds;
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
#if SUPPORT_BUSY_WAIT_LOOP
|
||||
while (GetTime() < destinationTime) { }
|
||||
#else
|
||||
#if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
|
||||
#if SUPPORT_PARTIALBUSY_WAIT_LOOP
|
||||
double sleepSeconds = seconds - seconds*0.05; // NOTE: We reserve a percentage of the time for busy waiting
|
||||
#else
|
||||
double sleepSeconds = seconds;
|
||||
@@ -1705,7 +1698,7 @@ void WaitTime(double seconds)
|
||||
usleep(sleepSeconds*1000000.0);
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
|
||||
#if SUPPORT_PARTIALBUSY_WAIT_LOOP
|
||||
while (GetTime() < destinationTime) { }
|
||||
#endif
|
||||
#endif
|
||||
@@ -1721,7 +1714,7 @@ void WaitTime(double seconds)
|
||||
// Set the seed for the random number generator
|
||||
void SetRandomSeed(unsigned int seed)
|
||||
{
|
||||
#if defined(SUPPORT_RPRAND_GENERATOR)
|
||||
#if SUPPORT_RPRAND_GENERATOR
|
||||
rprand_set_seed(seed);
|
||||
#else
|
||||
srand(seed);
|
||||
@@ -1740,7 +1733,7 @@ int GetRandomValue(int min, int max)
|
||||
min = tmp;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_RPRAND_GENERATOR)
|
||||
#if SUPPORT_RPRAND_GENERATOR
|
||||
value = rprand_get_value(min, max);
|
||||
#else
|
||||
// WARNING: Ranges higher than RAND_MAX will return invalid results
|
||||
@@ -1779,6 +1772,7 @@ int GetRandomValue(int min, int max)
|
||||
value = min + (int)(r%m);
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1787,7 +1781,7 @@ int *LoadRandomSequence(unsigned int count, int min, int max)
|
||||
{
|
||||
int *values = NULL;
|
||||
|
||||
#if defined(SUPPORT_RPRAND_GENERATOR)
|
||||
#if SUPPORT_RPRAND_GENERATOR
|
||||
values = rprand_load_sequence(count, min, max);
|
||||
#else
|
||||
if (count > ((unsigned int)abs(max - min) + 1)) return values; // Security check
|
||||
@@ -1818,13 +1812,14 @@ int *LoadRandomSequence(unsigned int count, int min, int max)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
// Unload random values sequence
|
||||
void UnloadRandomSequence(int *sequence)
|
||||
{
|
||||
#if defined(SUPPORT_RPRAND_GENERATOR)
|
||||
#if SUPPORT_RPRAND_GENERATOR
|
||||
rprand_unload_sequence(sequence);
|
||||
#else
|
||||
RL_FREE(sequence);
|
||||
@@ -1835,7 +1830,7 @@ void UnloadRandomSequence(int *sequence)
|
||||
// NOTE: Provided fileName should not contain paths, saving to working directory
|
||||
void TakeScreenshot(const char *fileName)
|
||||
{
|
||||
#if defined(SUPPORT_MODULE_RTEXTURES)
|
||||
#if SUPPORT_MODULE_RTEXTURES
|
||||
// Security check to (partially) avoid malicious code
|
||||
if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; }
|
||||
|
||||
@@ -1883,7 +1878,7 @@ void SetTraceLogLevel(int logType) { logTypeLevel = logType; }
|
||||
// Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
|
||||
void TraceLog(int logType, const char *text, ...)
|
||||
{
|
||||
#if defined(SUPPORT_TRACELOG)
|
||||
#if SUPPORT_TRACELOG
|
||||
// Message has level below current threshold, don't emit
|
||||
if ((logType < logTypeLevel) || (text == NULL)) return;
|
||||
|
||||
@@ -1932,8 +1927,7 @@ void TraceLog(int logType, const char *text, ...)
|
||||
va_end(args);
|
||||
|
||||
if (logType == LOG_FATAL) exit(EXIT_FAILURE); // If fatal logging, exit program
|
||||
|
||||
#endif // SUPPORT_TRACELOG
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set custom trace log
|
||||
@@ -1977,12 +1971,8 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize)
|
||||
|
||||
if (fileName != NULL)
|
||||
{
|
||||
if (loadFileData)
|
||||
{
|
||||
data = loadFileData(fileName, dataSize);
|
||||
return data;
|
||||
}
|
||||
#if defined(SUPPORT_STANDARD_FILEIO)
|
||||
if (loadFileData) return loadFileData(fileName, dataSize);
|
||||
|
||||
FILE *file = fopen(fileName, "rb");
|
||||
|
||||
if (file != NULL)
|
||||
@@ -2026,9 +2016,6 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize)
|
||||
fclose(file);
|
||||
}
|
||||
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");
|
||||
|
||||
@@ -2048,11 +2035,8 @@ bool SaveFileData(const char *fileName, void *data, int dataSize)
|
||||
|
||||
if (fileName != NULL)
|
||||
{
|
||||
if (saveFileData)
|
||||
{
|
||||
return saveFileData(fileName, data, dataSize);
|
||||
}
|
||||
#if defined(SUPPORT_STANDARD_FILEIO)
|
||||
if (saveFileData) return saveFileData(fileName, data, dataSize);
|
||||
|
||||
FILE *file = fopen(fileName, "wb");
|
||||
|
||||
if (file != NULL)
|
||||
@@ -2069,9 +2053,6 @@ bool SaveFileData(const char *fileName, void *data, int dataSize)
|
||||
if (result == 0) success = true;
|
||||
}
|
||||
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");
|
||||
|
||||
@@ -2139,12 +2120,8 @@ char *LoadFileText(const char *fileName)
|
||||
|
||||
if (fileName != NULL)
|
||||
{
|
||||
if (loadFileText)
|
||||
{
|
||||
text = loadFileText(fileName);
|
||||
return text;
|
||||
}
|
||||
#if defined(SUPPORT_STANDARD_FILEIO)
|
||||
if (loadFileText) return loadFileText(fileName);
|
||||
|
||||
FILE *file = fopen(fileName, "rt");
|
||||
|
||||
if (file != NULL)
|
||||
@@ -2180,9 +2157,6 @@ char *LoadFileText(const char *fileName)
|
||||
fclose(file);
|
||||
}
|
||||
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");
|
||||
|
||||
@@ -2202,11 +2176,8 @@ bool SaveFileText(const char *fileName, const char *text)
|
||||
|
||||
if (fileName != NULL)
|
||||
{
|
||||
if (saveFileText)
|
||||
{
|
||||
return saveFileText(fileName, text);
|
||||
}
|
||||
#if defined(SUPPORT_STANDARD_FILEIO)
|
||||
if (saveFileText) return saveFileText(fileName, text);
|
||||
|
||||
FILE *file = fopen(fileName, "wt");
|
||||
|
||||
if (file != NULL)
|
||||
@@ -2220,9 +2191,6 @@ bool SaveFileText(const char *fileName, const char *text)
|
||||
if (result == 0) success = true;
|
||||
}
|
||||
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");
|
||||
|
||||
@@ -2332,7 +2300,7 @@ int FileTextReplace(const char *fileName, const char *search, const char *replac
|
||||
char *fileText = NULL;
|
||||
char *fileTextUpdated = { 0 };
|
||||
|
||||
#if defined(SUPPORT_MODULE_RTEXT)
|
||||
#if SUPPORT_MODULE_RTEXT
|
||||
if (FileExists(fileName))
|
||||
{
|
||||
fileText = LoadFileText(fileName);
|
||||
@@ -3025,7 +2993,7 @@ unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDa
|
||||
|
||||
unsigned char *compData = NULL;
|
||||
|
||||
#if defined(SUPPORT_COMPRESSION_API)
|
||||
#if SUPPORT_COMPRESSION_API
|
||||
// Compress data and generate a valid DEFLATE stream
|
||||
struct sdefl *sdefl = (struct sdefl *)RL_CALLOC(1, sizeof(struct sdefl)); // WARNING: Possible stack overflow, struct sdefl is almost 1MB
|
||||
int bounds = sdefl_bound(dataSize);
|
||||
@@ -3045,7 +3013,7 @@ unsigned char *DecompressData(const unsigned char *compData, int compDataSize, i
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
|
||||
#if defined(SUPPORT_COMPRESSION_API)
|
||||
#if SUPPORT_COMPRESSION_API
|
||||
// Decompress data from a valid DEFLATE stream
|
||||
unsigned char *data0 = (unsigned char *)RL_CALLOC(MAX_DECOMPRESSION_SIZE*1024*1024, 1);
|
||||
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.capacity = MAX_AUTOMATION_EVENTS;
|
||||
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
if (fileName == NULL) TRACELOG(LOG_INFO, "AUTOMATION: New empty events list loaded successfully");
|
||||
else
|
||||
{
|
||||
@@ -3658,7 +3626,7 @@ AutomationEventList LoadAutomationEventList(const char *fileName)
|
||||
// Unload automation events list from file
|
||||
void UnloadAutomationEventList(AutomationEventList list)
|
||||
{
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
RL_FREE(list.events);
|
||||
#endif
|
||||
}
|
||||
@@ -3668,7 +3636,7 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
// Export events as binary file
|
||||
// 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
|
||||
void SetAutomationEventList(AutomationEventList *list)
|
||||
{
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
currentEventList = list;
|
||||
#endif
|
||||
}
|
||||
@@ -3740,7 +3708,7 @@ void SetAutomationEventBaseFrame(int frame)
|
||||
// Start recording automation events (AutomationEventList must be set)
|
||||
void StartAutomationEventRecording(void)
|
||||
{
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
automationEventRecording = true;
|
||||
#endif
|
||||
}
|
||||
@@ -3748,7 +3716,7 @@ void StartAutomationEventRecording(void)
|
||||
// Stop recording automation events
|
||||
void StopAutomationEventRecording(void)
|
||||
{
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
automationEventRecording = false;
|
||||
#endif
|
||||
}
|
||||
@@ -3756,7 +3724,7 @@ void StopAutomationEventRecording(void)
|
||||
// Play a recorded automation event
|
||||
void PlayAutomationEvent(AutomationEvent event)
|
||||
{
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
// WARNING: When should event be played? After/before/replace PollInputEvents()? -> Up to the user!
|
||||
|
||||
if (!automationEventRecording)
|
||||
@@ -3805,7 +3773,7 @@ void PlayAutomationEvent(AutomationEvent event)
|
||||
{
|
||||
CORE.Input.Gamepad.axisState[event.params[0]][event.params[1]] = ((float)event.params[2]/32768.0f);
|
||||
} break;
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
#if SUPPORT_GESTURES_SYSTEM
|
||||
case INPUT_GESTURE: GESTURES.current = event.params[0]; break; // param[0]: gesture (enum Gesture) -> rgestures.h: GESTURES.current
|
||||
#endif
|
||||
// Window event
|
||||
@@ -3813,9 +3781,8 @@ void PlayAutomationEvent(AutomationEvent event)
|
||||
case WINDOW_MAXIMIZE: MaximizeWindow(); break;
|
||||
case WINDOW_MINIMIZE: MinimizeWindow(); break;
|
||||
case WINDOW_RESIZE: SetWindowSize(event.params[0], event.params[1]); break;
|
||||
|
||||
// Custom event
|
||||
#if defined(SUPPORT_SCREEN_CAPTURE)
|
||||
#if SUPPORT_SCREEN_CAPTURE
|
||||
case ACTION_TAKE_SCREENSHOT:
|
||||
{
|
||||
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
|
||||
@@ -4259,7 +4226,7 @@ void InitTimer(void)
|
||||
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often
|
||||
// High resolutions can also prevent the CPU power management system from entering power-saving modes
|
||||
// Setting a higher resolution does not improve the accuracy of the high-resolution performance counter
|
||||
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_DESKTOP_SDL)
|
||||
#if defined(_WIN32) && SUPPORT_WINMM_HIGHRES_TIMER && !SUPPORT_BUSY_WAIT_LOOP && !defined(PLATFORM_DESKTOP_SDL)
|
||||
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
|
||||
#endif
|
||||
|
||||
@@ -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...
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_AUTOMATION_EVENTS)
|
||||
#if SUPPORT_AUTOMATION_EVENTS
|
||||
// Automation event recording
|
||||
// Checking events in current frame and save them into currentEventList
|
||||
// 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
|
||||
//-------------------------------------------------------------------------------------
|
||||
if (GESTURES.current != GESTURE_NONE)
|
||||
@@ -4655,5 +4622,4 @@ const char *TextFormat(const char *text, ...)
|
||||
|
||||
return currentBuffer;
|
||||
}
|
||||
|
||||
#endif // !SUPPORT_MODULE_RTEXT
|
||||
#endif
|
||||
|
||||
47
src/rlgl.h
47
src/rlgl.h
@@ -1134,7 +1134,7 @@ typedef struct rlglData {
|
||||
} ExtSupported; // Extensions supported flags
|
||||
} rlglData;
|
||||
|
||||
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// 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)
|
||||
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;
|
||||
|
||||
#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)
|
||||
static void rlLoadShaderDefault(void); // Load 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
|
||||
#endif // RLGL_SHOW_GL_DETAILS_INFO
|
||||
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
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
|
||||
//----------------------------------------------------------------------------------
|
||||
#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)
|
||||
{
|
||||
// Ignore non-significant error/warning codes (NVidia drivers)
|
||||
@@ -2276,8 +2276,8 @@ void rlglInit(int width, int height)
|
||||
{
|
||||
isGpuReady = true;
|
||||
|
||||
// Enable OpenGL debug context if required
|
||||
#if defined(RLGL_ENABLE_OPENGL_DEBUG_CONTEXT) && defined(GRAPHICS_API_OPENGL_43)
|
||||
// Enable OpenGL debug context if requested (and supported)
|
||||
#if defined(GRAPHICS_API_OPENGL_43) && RLGL_ENABLE_OPENGL_DEBUG_CONTEXT
|
||||
if ((glDebugMessageCallback != NULL) && (glDebugMessageControl != NULL))
|
||||
{
|
||||
glDebugMessageCallback(rlDebugMessageCallback, 0);
|
||||
@@ -2321,7 +2321,7 @@ void rlglInit(int width, int height)
|
||||
RLGL.State.projection = rlMatrixIdentity();
|
||||
RLGL.State.modelview = rlMatrixIdentity();
|
||||
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)
|
||||
// Initialize software renderer backend
|
||||
@@ -2405,7 +2405,7 @@ void rlLoadExtensions(void *loader)
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &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
|
||||
// WARNING: glGetStringi() not available on OpenGL 2.1
|
||||
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;
|
||||
#endif
|
||||
|
||||
#endif // GRAPHICS_API_OPENGL_33
|
||||
#endif // GRAPHICS_API_OPENGL_33
|
||||
|
||||
#if defined(GRAPHICS_API_OPENGL_ES3)
|
||||
// Register supported extensions flags
|
||||
@@ -2503,7 +2503,7 @@ void rlLoadExtensions(void *loader)
|
||||
|
||||
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:");
|
||||
for (int i = 0; i < numExt; i++) TRACELOG(RL_LOG_INFO, " %s", extList[i]);
|
||||
#endif
|
||||
@@ -2613,7 +2613,7 @@ void rlLoadExtensions(void *loader)
|
||||
// Free extensions pointers
|
||||
RL_FREE(extList);
|
||||
RL_FREE(extensionsDup); // Duplicated string must be deallocated
|
||||
#endif // GRAPHICS_API_OPENGL_ES2
|
||||
#endif // GRAPHICS_API_OPENGL_ES2
|
||||
|
||||
// Check OpenGL information and capabilities
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -2633,7 +2633,7 @@ void rlLoadExtensions(void *loader)
|
||||
#endif
|
||||
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
|
||||
TRACELOG(RL_LOG_INFO, "GL: OpenGL capabilities:");
|
||||
GLint capability = 0;
|
||||
@@ -2664,8 +2664,9 @@ void rlLoadExtensions(void *loader)
|
||||
TRACELOG(RL_LOG_INFO, " GL_MAX_VERTEX_ATTRIB_BINDINGS: %i", capability);
|
||||
glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &capability);
|
||||
TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_LOCATIONS: %i", capability);
|
||||
#endif // GRAPHICS_API_OPENGL_43
|
||||
#else // RLGL_SHOW_GL_DETAILS_INFO
|
||||
#endif
|
||||
|
||||
#else // !RLGL_SHOW_GL_DETAILS_INFO
|
||||
|
||||
// Show some basic info about GL supported features
|
||||
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.computeShader) TRACELOG(RL_LOG_INFO, "GL: Compute shaders 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
|
||||
@@ -3291,7 +3292,7 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
|
||||
return id;
|
||||
}
|
||||
#endif
|
||||
#endif // GRAPHICS_API_OPENGL_11
|
||||
#endif // GRAPHICS_API_OPENGL_11
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#if defined(RLGL_SHOW_GL_DETAILS_INFO)
|
||||
#if RLGL_SHOW_GL_DETAILS_INFO
|
||||
// Get compressed format official GL identifier name
|
||||
static const char *rlGetCompressedFormatName(int format)
|
||||
{
|
||||
@@ -5183,9 +5184,9 @@ static const char *rlGetCompressedFormatName(int format)
|
||||
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)
|
||||
// NOTE: Size depends on pixel format
|
||||
@@ -5388,4 +5389,4 @@ static Matrix rlMatrixInvert(Matrix mat)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RLGL_IMPLEMENTATION
|
||||
#endif // RLGL_IMPLEMENTATION
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
#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 "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality
|
||||
@@ -54,7 +54,7 @@
|
||||
#include <string.h> // Required for: memcmp(), strlen(), strncpy()
|
||||
#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_CALLOC RL_CALLOC
|
||||
#define TINYOBJ_REALLOC RL_REALLOC
|
||||
@@ -64,7 +64,7 @@
|
||||
#include "external/tinyobj_loader_c.h" // OBJ/MTL file formats loading
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
#if SUPPORT_FILEFORMAT_GLTF
|
||||
#define CGLTF_MALLOC RL_MALLOC
|
||||
#define CGLTF_FREE RL_FREE
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
#include "external/cgltf.h" // glTF file format loading
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_VOX)
|
||||
#if SUPPORT_FILEFORMAT_VOX
|
||||
#define VOX_MALLOC RL_MALLOC
|
||||
#define VOX_CALLOC RL_CALLOC
|
||||
#define VOX_REALLOC RL_REALLOC
|
||||
@@ -82,7 +82,7 @@
|
||||
#include "external/vox_loader.h" // VOX file format loading (MagikaVoxel)
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_M3D)
|
||||
#if SUPPORT_FILEFORMAT_M3D
|
||||
#define M3D_MALLOC RL_MALLOC
|
||||
#define M3D_REALLOC RL_REALLOC
|
||||
#define M3D_FREE RL_FREE
|
||||
@@ -91,7 +91,7 @@
|
||||
#include "external/m3d.h" // Model3D file format loading
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_MESH_GENERATION)
|
||||
#if SUPPORT_MESH_GENERATION
|
||||
#define PAR_MALLOC(T, N) ((T *)RL_MALLOC(N*sizeof(T)))
|
||||
#define PAR_CALLOC(T, N) ((T *)RL_CALLOC(N*sizeof(T), 1))
|
||||
#define PAR_REALLOC(T, BUF, N) ((T *)RL_REALLOC(BUF, sizeof(T)*(N)))
|
||||
@@ -126,7 +126,13 @@
|
||||
#define MAX_MATERIAL_MAPS 12 // Maximum number of maps supported
|
||||
#endif
|
||||
#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
|
||||
#else
|
||||
#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh
|
||||
#endif
|
||||
#endif
|
||||
#ifndef MAX_FILEPATH_LENGTH
|
||||
#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value)
|
||||
@@ -145,25 +151,25 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(SUPPORT_FILEFORMAT_OBJ)
|
||||
#if SUPPORT_FILEFORMAT_OBJ
|
||||
static Model LoadOBJ(const char *fileName); // Load OBJ mesh data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_IQM)
|
||||
#if SUPPORT_FILEFORMAT_IQM
|
||||
static Model LoadIQM(const char *fileName); // Load IQM mesh data
|
||||
static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCount); // Load IQM animation data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
#if SUPPORT_FILEFORMAT_GLTF
|
||||
static Model LoadGLTF(const char *fileName); // Load GLTF mesh data
|
||||
static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCount); // Load GLTF animation data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_VOX)
|
||||
#if SUPPORT_FILEFORMAT_VOX
|
||||
static Model LoadVOX(const char *filename); // Load VOX mesh data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_M3D)
|
||||
#if SUPPORT_FILEFORMAT_M3D
|
||||
static Model LoadM3D(const char *filename); // Load M3D mesh data
|
||||
static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCount); // Load M3D animation data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL)
|
||||
#if SUPPORT_FILEFORMAT_OBJ || SUPPORT_FILEFORMAT_MTL
|
||||
static void ProcessMaterialsOBJ(Material *rayMaterials, tinyobj_material_t *materials, int materialCount); // Process obj materials
|
||||
#endif
|
||||
|
||||
@@ -1099,19 +1105,19 @@ Model LoadModel(const char *fileName)
|
||||
{
|
||||
Model model = { 0 };
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_OBJ)
|
||||
#if SUPPORT_FILEFORMAT_OBJ
|
||||
if (IsFileExtension(fileName, ".obj")) model = LoadOBJ(fileName);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_IQM)
|
||||
#if SUPPORT_FILEFORMAT_IQM
|
||||
if (IsFileExtension(fileName, ".iqm")) model = LoadIQM(fileName);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
#if SUPPORT_FILEFORMAT_GLTF
|
||||
if (IsFileExtension(fileName, ".gltf") || IsFileExtension(fileName, ".glb")) model = LoadGLTF(fileName);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_VOX)
|
||||
#if SUPPORT_FILEFORMAT_VOX
|
||||
if (IsFileExtension(fileName, ".vox")) model = LoadVOX(fileName);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_M3D)
|
||||
#if SUPPORT_FILEFORMAT_M3D
|
||||
if (IsFileExtension(fileName, ".m3d")) model = LoadM3D(fileName);
|
||||
#endif
|
||||
|
||||
@@ -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_TEXCOORD2] = 0; // Vertex buffer: texcoords2
|
||||
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_BONEWEIGHTS] = 0; // Vertex buffer: boneWeights
|
||||
#endif
|
||||
@@ -1377,7 +1383,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
|
||||
rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GPU_SKINNING
|
||||
#if SUPPORT_GPU_SKINNING
|
||||
if (mesh->boneIndices != NULL)
|
||||
{
|
||||
// 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]);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GPU_SKINNING
|
||||
#if SUPPORT_GPU_SKINNING
|
||||
// Bind mesh VBO data: vertex bone ids (shader-location = 6, if available)
|
||||
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]);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GPU_SKINNING
|
||||
#if SUPPORT_GPU_SKINNING
|
||||
// Bind mesh VBO data: vertex bone ids (shader-location = 6, if available)
|
||||
if (material.shader.locs[SHADER_LOC_VERTEX_BONEIDS] != -1)
|
||||
{
|
||||
@@ -2125,7 +2131,7 @@ bool ExportMeshAsCode(Mesh mesh, const char *fileName)
|
||||
return success;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL)
|
||||
#if SUPPORT_FILEFORMAT_OBJ || SUPPORT_FILEFORMAT_MTL
|
||||
// Process obj materials
|
||||
static void ProcessMaterialsOBJ(Material *materials, tinyobj_material_t *mats, int materialCount)
|
||||
{
|
||||
@@ -2169,7 +2175,7 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
|
||||
|
||||
// TODO: Support IQM and GLTF for materials parsing
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_MTL)
|
||||
#if SUPPORT_FILEFORMAT_MTL
|
||||
if (IsFileExtension(fileName, ".mtl"))
|
||||
{
|
||||
tinyobj_material_t *mats = NULL;
|
||||
@@ -2263,13 +2269,13 @@ ModelAnimation *LoadModelAnimations(const char *fileName, int *animCount)
|
||||
{
|
||||
ModelAnimation *animations = NULL;
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_IQM)
|
||||
#if SUPPORT_FILEFORMAT_IQM
|
||||
if (IsFileExtension(fileName, ".iqm")) animations = LoadModelAnimationsIQM(fileName, animCount);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_M3D)
|
||||
#if SUPPORT_FILEFORMAT_M3D
|
||||
if (IsFileExtension(fileName, ".m3d")) animations = LoadModelAnimationsM3D(fileName, animCount);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
#if SUPPORT_FILEFORMAT_GLTF
|
||||
if (IsFileExtension(fileName, ".gltf;.glb")) animations = LoadModelAnimationsGLTF(fileName, animCount);
|
||||
#endif
|
||||
|
||||
@@ -2548,7 +2554,7 @@ bool IsModelAnimationValid(Model model, ModelAnimation anim)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_MESH_GENERATION)
|
||||
#if SUPPORT_MESH_GENERATION
|
||||
// Generate polygonal mesh
|
||||
Mesh GenMeshPoly(int sides, float radius)
|
||||
{
|
||||
@@ -3691,7 +3697,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
|
||||
|
||||
return mesh;
|
||||
}
|
||||
#endif // SUPPORT_MESH_GENERATION
|
||||
#endif // SUPPORT_MESH_GENERATION
|
||||
|
||||
// Compute mesh bounding box limits
|
||||
// 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
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(SUPPORT_FILEFORMAT_IQM) || defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
#if SUPPORT_FILEFORMAT_IQM || SUPPORT_FILEFORMAT_GLTF
|
||||
// Build pose from parent joints
|
||||
// NOTE: Required for animations loading (required by IQM and GLTF)
|
||||
static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform *transforms)
|
||||
@@ -4402,7 +4408,7 @@ static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_OBJ)
|
||||
#if SUPPORT_FILEFORMAT_OBJ
|
||||
// Load OBJ mesh data
|
||||
// Notes to keep in mind:
|
||||
// - A mesh is created for every material present in the obj file
|
||||
@@ -4653,7 +4659,7 @@ static Model LoadOBJ(const char *fileName)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_IQM)
|
||||
#if SUPPORT_FILEFORMAT_IQM
|
||||
// Load IQM mesh data
|
||||
static Model LoadIQM(const char *fileName)
|
||||
{
|
||||
@@ -4834,7 +4840,7 @@ static Model LoadIQM(const char *fileName)
|
||||
model.meshes[i].triangleCount = imesh[i].num_triangles;
|
||||
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
|
||||
// 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));
|
||||
@@ -5276,7 +5282,7 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCou
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_GLTF)
|
||||
#if SUPPORT_FILEFORMAT_GLTF
|
||||
// Load file data callback for cgltf
|
||||
static cgltf_result LoadFileGLTFCallback(const struct cgltf_memory_options *memoryOptions, const struct cgltf_file_options *fileOptions, const char *path, cgltf_size *size, void **data)
|
||||
{
|
||||
@@ -6317,7 +6323,7 @@ static Model LoadGLTF(const char *fileName)
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(SUPPORT_GPU_SKINNING)
|
||||
#if !SUPPORT_GPU_SKINNING
|
||||
// Animated vertex data (CPU skinning)
|
||||
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));
|
||||
@@ -6676,7 +6682,7 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_VOX)
|
||||
#if SUPPORT_FILEFORMAT_VOX
|
||||
// Load VOX (MagicaVoxel) mesh data
|
||||
static Model LoadVOX(const char *fileName)
|
||||
{
|
||||
@@ -6786,7 +6792,7 @@ static Model LoadVOX(const char *fileName)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_M3D)
|
||||
#if SUPPORT_FILEFORMAT_M3D
|
||||
// Hook LoadFileData()/UnloadFileData() calls to M3D loaders
|
||||
unsigned char *m3d_loaderhook(char *fn, unsigned int *len) { return LoadFileData((const char *)fn, (int *)len); }
|
||||
void m3d_freehook(void *data) { UnloadFileData((unsigned char *)data); }
|
||||
@@ -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].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].animNormals = (float *)RL_CALLOC(model.meshes[k].vertexCount*3, sizeof(float));
|
||||
#endif
|
||||
@@ -7131,7 +7137,7 @@ static Model LoadM3D(const char *fileName)
|
||||
{
|
||||
model.meshes[i].boneCount = model.skeleton.boneCount;
|
||||
|
||||
#if !defined(SUPPORT_GPU_SKINNING)
|
||||
#if !SUPPORT_GPU_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].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 // SUPPORT_MODULE_RMODELS
|
||||
#endif // SUPPORT_MODULE_RMODELS
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
#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
|
||||
|
||||
@@ -128,7 +128,7 @@ void DrawPixel(int posX, int posY, Color color)
|
||||
// Draw a pixel (Vector version)
|
||||
void DrawPixelV(Vector2 position, Color color)
|
||||
{
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
@@ -353,7 +353,7 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
|
||||
float stepLength = (endAngle - startAngle)/(float)segments;
|
||||
float angle = startAngle;
|
||||
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
@@ -594,7 +594,7 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
|
||||
float stepLength = (endAngle - startAngle)/(float)segments;
|
||||
float angle = startAngle;
|
||||
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
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...
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
DrawRectangle(posX, posY, width, 1, color);
|
||||
DrawRectangle(posX + width - 1, posY + 1, 1, height - 2, color);
|
||||
DrawRectangle(posX, posY + height - 1, width, 1, color);
|
||||
@@ -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 float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f };
|
||||
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
@@ -1248,7 +1248,7 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
|
||||
|
||||
if (lineThick > 1)
|
||||
{
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
@@ -1422,7 +1422,7 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f
|
||||
// NOTE: Vertex must be provided in counter-clockwise order
|
||||
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
|
||||
{
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
@@ -1538,7 +1538,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
|
||||
float centralAngle = rotation*DEG2RAD;
|
||||
float angleStep = 360.0f/(float)sides*DEG2RAD;
|
||||
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
@@ -1607,7 +1607,7 @@ void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, fl
|
||||
float exteriorAngle = 360.0f/(float)sides*DEG2RAD;
|
||||
float innerRadius = radius - (lineThick*cosf(DEG2RAD*exteriorAngle/2.0f));
|
||||
|
||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||
#if SUPPORT_QUADS_DRAW_MODE
|
||||
rlSetTexture(GetShapesTexture().id);
|
||||
Rectangle shapeRect = GetShapesTextureRectangle();
|
||||
|
||||
@@ -1663,7 +1663,7 @@ void DrawSplineLinear(const Vector2 *points, int pointCount, float thick, Color
|
||||
{
|
||||
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)};
|
||||
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
|
||||
|
||||
#if defined(SUPPORT_SPLINE_SEGMENT_CAPS)
|
||||
// TODO: Add spline segment rounded caps at the begin/end of the spline
|
||||
#if SUPPORT_SPLINE_SEGMENT_CAPS
|
||||
// TODO: Add spline segment rounded caps at the begin/end of the spline?
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2484,4 +2484,4 @@ static float EaseCubicInOut(float t, float b, float c, float d)
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // SUPPORT_MODULE_RSHAPES
|
||||
#endif // SUPPORT_MODULE_RSHAPES
|
||||
|
||||
85
src/rtext.c
85
src/rtext.c
@@ -6,27 +6,23 @@
|
||||
* #define SUPPORT_MODULE_RTEXT
|
||||
* 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_TTF
|
||||
* #define SUPPORT_FILEFORMAT_BDF
|
||||
* 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
|
||||
*
|
||||
* #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
|
||||
* TextSplit() function static buffer max size
|
||||
*
|
||||
* #define MAX_TEXTSPLIT_COUNT
|
||||
* 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:
|
||||
* stb_truetype - Load TTF file and rasterize characters data
|
||||
* stb_rect_pack - Rectangles packing algorithms, required for font atlas generation
|
||||
@@ -57,7 +53,7 @@
|
||||
|
||||
#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()
|
||||
|
||||
@@ -67,7 +63,7 @@
|
||||
#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()]
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF)
|
||||
#if SUPPORT_FILEFORMAT_TTF || SUPPORT_FILEFORMAT_BDF
|
||||
#if defined(__GNUC__) // GCC and Clang
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
@@ -83,7 +79,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||
#if SUPPORT_FILEFORMAT_TTF
|
||||
#if defined(__GNUC__) // GCC and Clang
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
@@ -105,14 +101,18 @@
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
#ifndef MAX_TEXT_BUFFER_LENGTH
|
||||
#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
|
||||
// TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit()
|
||||
#endif
|
||||
#ifndef MAX_TEXT_UNICODE_CHARS
|
||||
#define MAX_TEXT_UNICODE_CHARS 512 // Maximum number of unicode codepoints: GetCodepoints()
|
||||
#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
|
||||
// TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit()
|
||||
#endif
|
||||
#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
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@@ -123,12 +123,12 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global variables
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(SUPPORT_DEFAULT_FONT)
|
||||
// Default font provided by raylib
|
||||
// NOTE: Default font is loaded on InitWindow() and disposed on CloseWindow() [module: core]
|
||||
static Font defaultFont = { 0 };
|
||||
#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)
|
||||
@@ -138,22 +138,19 @@ static int textLineSpacing = 2; // Text vertical line spacing in pixels (between
|
||||
//----------------------------------------------------------------------------------
|
||||
// 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)
|
||||
#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);
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_DEFAULT_FONT)
|
||||
extern void LoadFontDefault(void);
|
||||
extern void UnloadFontDefault(void);
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
#if defined(SUPPORT_DEFAULT_FONT)
|
||||
// Load raylib default font
|
||||
extern void LoadFontDefault(void)
|
||||
{
|
||||
@@ -329,17 +326,11 @@ extern void UnloadFontDefault(void)
|
||||
defaultFont.glyphs = NULL;
|
||||
defaultFont.recs = NULL;
|
||||
}
|
||||
#endif // SUPPORT_DEFAULT_FONT
|
||||
|
||||
// Get the default font, useful to be used with extended parameters
|
||||
Font GetFontDefault()
|
||||
{
|
||||
#if defined(SUPPORT_DEFAULT_FONT)
|
||||
return defaultFont;
|
||||
#else
|
||||
Font font = { 0 };
|
||||
return font;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Load Font from file into GPU memory (VRAM)
|
||||
@@ -361,15 +352,15 @@ Font LoadFont(const char *fileName)
|
||||
|
||||
Font font = { 0 };
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||
#if SUPPORT_FILEFORMAT_TTF
|
||||
if (IsFileExtension(fileName, ".ttf") || IsFileExtension(fileName, ".otf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS);
|
||||
else
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_FNT)
|
||||
#if SUPPORT_FILEFORMAT_FNT
|
||||
if (IsFileExtension(fileName, ".fnt")) font = LoadBMFont(fileName);
|
||||
else
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_BDF)
|
||||
#if SUPPORT_FILEFORMAT_BDF
|
||||
if (IsFileExtension(fileName, ".bdf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS);
|
||||
else
|
||||
#endif
|
||||
@@ -548,7 +539,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||
font.baseSize = fontSize;
|
||||
font.glyphPadding = 0;
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||
#if SUPPORT_FILEFORMAT_TTF
|
||||
if (TextIsEqual(fileExtLower, ".ttf") ||
|
||||
TextIsEqual(fileExtLower, ".otf"))
|
||||
{
|
||||
@@ -556,7 +547,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_BDF)
|
||||
#if SUPPORT_FILEFORMAT_BDF
|
||||
if (TextIsEqual(fileExtLower, ".bdf"))
|
||||
{
|
||||
font.glyphs = LoadFontDataBDF(fileData, dataSize, codepoints, (codepointCount > 0)? codepointCount : 95, &font.baseSize);
|
||||
@@ -568,7 +559,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
|
||||
font.glyphs = NULL;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF)
|
||||
#if SUPPORT_FILEFORMAT_TTF || SUPPORT_FILEFORMAT_BDF
|
||||
if (font.glyphs != NULL)
|
||||
{
|
||||
font.glyphPadding = FONT_TTF_DEFAULT_CHARS_PADDING;
|
||||
@@ -629,7 +620,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
|
||||
GlyphInfo *glyphs = NULL;
|
||||
int glyphCounter = 0;
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||
#if SUPPORT_FILEFORMAT_TTF
|
||||
// Load font data (including pixel data) from TTF memory file
|
||||
// NOTE: Loaded information should be enough to generate font image atlas, using any packaging method
|
||||
if (fileData != NULL)
|
||||
@@ -789,7 +780,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
|
||||
|
||||
// Generate image font atlas using chars info
|
||||
// NOTE: Packing method: 0-Default, 1-Skyline
|
||||
#if defined(SUPPORT_FILEFORMAT_TTF) || defined(SUPPORT_FILEFORMAT_BDF)
|
||||
#if SUPPORT_FILEFORMAT_TTF || SUPPORT_FILEFORMAT_BDF
|
||||
Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod)
|
||||
{
|
||||
Image atlas = { 0 };
|
||||
@@ -961,13 +952,12 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp
|
||||
RL_FREE(context);
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_FONT_ATLAS_WHITE_REC)
|
||||
// Add a 3x3 white rectangle at the bottom-right corner of the generated atlas,
|
||||
// useful to use as the white texture to draw shapes with raylib
|
||||
// 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 - 1] = 255;
|
||||
@@ -975,7 +965,6 @@ Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyp
|
||||
k -= atlas.width;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// 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
|
||||
@@ -1601,7 +1590,6 @@ float TextToFloat(const char *text)
|
||||
return value*sign;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_TEXT_MANIPULATION)
|
||||
// Copy one string to another, returns bytes copied
|
||||
// NOTE: Alternative implementation to strcpy(dst, src) from C standard library
|
||||
int TextCopy(char *dst, const char *src)
|
||||
@@ -2195,7 +2183,6 @@ const char *CodepointToUTF8(int codepoint, int *utf8Size)
|
||||
|
||||
return utf8;
|
||||
}
|
||||
#endif // SUPPORT_TEXT_MANIPULATION
|
||||
|
||||
// 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
|
||||
@@ -2370,7 +2357,7 @@ int GetCodepointPrevious(const char *text, int *codepointSize)
|
||||
//----------------------------------------------------------------------------------
|
||||
// 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
|
||||
// REQUIRES: memcpy()
|
||||
// NOTE: Returns the number of bytes read
|
||||
@@ -2384,7 +2371,7 @@ static int GetLine(const char *origin, char *buffer, int maxLength)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_FNT)
|
||||
#if SUPPORT_FILEFORMAT_FNT
|
||||
// Load a BMFont file (AngelCode font file)
|
||||
// REQUIRES: strstr(), sscanf(), strrchr(), memcpy()
|
||||
static Font LoadBMFont(const char *fileName)
|
||||
@@ -2561,7 +2548,7 @@ static Font LoadBMFont(const char *fileName)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_BDF)
|
||||
#if SUPPORT_FILEFORMAT_BDF
|
||||
// Convert hexadecimal to decimal (single digit)
|
||||
static unsigned char HexToInt(char hex)
|
||||
{
|
||||
|
||||
137
src/rtextures.c
137
src/rtextures.c
@@ -27,10 +27,6 @@
|
||||
* #define SUPPORT_IMAGE_EXPORT
|
||||
* 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
|
||||
* Support procedural image generation functionality (gradient, spot, perlin-noise, cellular)
|
||||
*
|
||||
@@ -65,7 +61,7 @@
|
||||
|
||||
#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
|
||||
|
||||
@@ -103,32 +99,32 @@
|
||||
#define STBI_NO_PNM
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_DDS)
|
||||
#if SUPPORT_FILEFORMAT_DDS
|
||||
#define RL_GPUTEX_SUPPORT_DDS
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_PKM)
|
||||
#if SUPPORT_FILEFORMAT_PKM
|
||||
#define RL_GPUTEX_SUPPORT_PKM
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_KTX)
|
||||
#if SUPPORT_FILEFORMAT_KTX
|
||||
#define RL_GPUTEX_SUPPORT_KTX
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_PVR)
|
||||
#if SUPPORT_FILEFORMAT_PVR
|
||||
#define RL_GPUTEX_SUPPORT_PVR
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_ASTC)
|
||||
#if SUPPORT_FILEFORMAT_ASTC
|
||||
#define RL_GPUTEX_SUPPORT_ASTC
|
||||
#endif
|
||||
|
||||
// Image fileformats not supported by default
|
||||
#if (defined(SUPPORT_FILEFORMAT_BMP) || \
|
||||
defined(SUPPORT_FILEFORMAT_PNG) || \
|
||||
defined(SUPPORT_FILEFORMAT_TGA) || \
|
||||
defined(SUPPORT_FILEFORMAT_JPG) || \
|
||||
defined(SUPPORT_FILEFORMAT_PSD) || \
|
||||
defined(SUPPORT_FILEFORMAT_GIF) || \
|
||||
defined(SUPPORT_FILEFORMAT_HDR) || \
|
||||
defined(SUPPORT_FILEFORMAT_PIC) || \
|
||||
defined(SUPPORT_FILEFORMAT_PNM))
|
||||
#if (SUPPORT_FILEFORMAT_BMP || \
|
||||
SUPPORT_FILEFORMAT_PNG || \
|
||||
SUPPORT_FILEFORMAT_TGA || \
|
||||
SUPPORT_FILEFORMAT_JPG || \
|
||||
SUPPORT_FILEFORMAT_PSD || \
|
||||
SUPPORT_FILEFORMAT_GIF || \
|
||||
SUPPORT_FILEFORMAT_HDR || \
|
||||
SUPPORT_FILEFORMAT_PIC || \
|
||||
SUPPORT_FILEFORMAT_PNM)
|
||||
|
||||
#if defined(__GNUC__) // GCC and Clang
|
||||
#pragma GCC diagnostic push
|
||||
@@ -177,7 +173,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_QOI)
|
||||
#if SUPPORT_FILEFORMAT_QOI
|
||||
#define QOI_MALLOC RL_MALLOC
|
||||
#define QOI_FREE RL_FREE
|
||||
|
||||
@@ -195,7 +191,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_IMAGE_EXPORT)
|
||||
#if SUPPORT_IMAGE_EXPORT
|
||||
#define STBIW_MALLOC RL_MALLOC
|
||||
#define STBIW_FREE RL_FREE
|
||||
#define STBIW_REALLOC RL_REALLOC
|
||||
@@ -204,7 +200,7 @@
|
||||
#include "external/stb_image_write.h" // Required for: stbi_write_*()
|
||||
#endif
|
||||
|
||||
#if defined(SUPPORT_IMAGE_GENERATION)
|
||||
#if SUPPORT_IMAGE_GENERATION
|
||||
#define STB_PERLIN_IMPLEMENTATION
|
||||
#include "external/stb_perlin.h" // Required for: stb_perlin_fbm_noise3
|
||||
#endif
|
||||
@@ -268,15 +264,15 @@ Image LoadImage(const char *fileName)
|
||||
{
|
||||
Image image = { 0 };
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_PNG) || \
|
||||
defined(SUPPORT_FILEFORMAT_BMP) || \
|
||||
defined(SUPPORT_FILEFORMAT_TGA) || \
|
||||
defined(SUPPORT_FILEFORMAT_JPG) || \
|
||||
defined(SUPPORT_FILEFORMAT_GIF) || \
|
||||
defined(SUPPORT_FILEFORMAT_PIC) || \
|
||||
defined(SUPPORT_FILEFORMAT_HDR) || \
|
||||
defined(SUPPORT_FILEFORMAT_PNM) || \
|
||||
defined(SUPPORT_FILEFORMAT_PSD)
|
||||
#if SUPPORT_FILEFORMAT_PNG || \
|
||||
SUPPORT_FILEFORMAT_BMP || \
|
||||
SUPPORT_FILEFORMAT_TGA || \
|
||||
SUPPORT_FILEFORMAT_JPG || \
|
||||
SUPPORT_FILEFORMAT_GIF || \
|
||||
SUPPORT_FILEFORMAT_PIC || \
|
||||
SUPPORT_FILEFORMAT_HDR || \
|
||||
SUPPORT_FILEFORMAT_PNM || \
|
||||
SUPPORT_FILEFORMAT_PSD
|
||||
|
||||
#define STBI_REQUIRED
|
||||
#endif
|
||||
@@ -338,7 +334,7 @@ Image LoadImageAnim(const char *fileName, int *frames)
|
||||
Image image = { 0 };
|
||||
int frameCount = 0;
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_GIF)
|
||||
#if SUPPORT_FILEFORMAT_GIF
|
||||
if (IsFileExtension(fileName, ".gif"))
|
||||
{
|
||||
int dataSize = 0;
|
||||
@@ -383,7 +379,7 @@ Image LoadImageAnimFromMemory(const char *fileType, const unsigned char *fileDat
|
||||
// Security check for input data
|
||||
if ((fileType == NULL) || (fileData == NULL) || (dataSize == 0)) return image;
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_GIF)
|
||||
#if SUPPORT_FILEFORMAT_GIF
|
||||
if ((strcmp(fileType, ".gif") == 0) || (strcmp(fileType, ".GIF") == 0))
|
||||
{
|
||||
if (fileData != NULL)
|
||||
@@ -430,30 +426,30 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
|
||||
}
|
||||
|
||||
if ((false)
|
||||
#if defined(SUPPORT_FILEFORMAT_PNG)
|
||||
#if SUPPORT_FILEFORMAT_PNG
|
||||
|| (strcmp(fileType, ".png") == 0) || (strcmp(fileType, ".PNG") == 0)
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_BMP)
|
||||
#if SUPPORT_FILEFORMAT_BMP
|
||||
|| (strcmp(fileType, ".bmp") == 0) || (strcmp(fileType, ".BMP") == 0)
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_TGA)
|
||||
#if SUPPORT_FILEFORMAT_TGA
|
||||
|| (strcmp(fileType, ".tga") == 0) || (strcmp(fileType, ".TGA") == 0)
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_JPG)
|
||||
#if SUPPORT_FILEFORMAT_JPG
|
||||
|| (strcmp(fileType, ".jpg") == 0) || (strcmp(fileType, ".jpeg") == 0)
|
||||
|| (strcmp(fileType, ".JPG") == 0) || (strcmp(fileType, ".JPEG") == 0)
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_GIF)
|
||||
#if SUPPORT_FILEFORMAT_GIF
|
||||
|| (strcmp(fileType, ".gif") == 0) || (strcmp(fileType, ".GIF") == 0)
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_PIC)
|
||||
#if SUPPORT_FILEFORMAT_PIC
|
||||
|| (strcmp(fileType, ".pic") == 0) || (strcmp(fileType, ".PIC") == 0)
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_PNM)
|
||||
#if SUPPORT_FILEFORMAT_PNM
|
||||
|| (strcmp(fileType, ".ppm") == 0) || (strcmp(fileType, ".pgm") == 0)
|
||||
|| (strcmp(fileType, ".PPM") == 0) || (strcmp(fileType, ".PGM") == 0)
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_PSD)
|
||||
#if SUPPORT_FILEFORMAT_PSD
|
||||
|| (strcmp(fileType, ".psd") == 0) || (strcmp(fileType, ".PSD") == 0)
|
||||
#endif
|
||||
)
|
||||
@@ -478,7 +474,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if defined(SUPPORT_FILEFORMAT_HDR)
|
||||
#if SUPPORT_FILEFORMAT_HDR
|
||||
else if ((strcmp(fileType, ".hdr") == 0) || (strcmp(fileType, ".HDR") == 0))
|
||||
{
|
||||
#if defined(STBI_REQUIRED)
|
||||
@@ -501,7 +497,7 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOI)
|
||||
#if SUPPORT_FILEFORMAT_QOI
|
||||
else if ((strcmp(fileType, ".qoi") == 0) || (strcmp(fileType, ".QOI") == 0))
|
||||
{
|
||||
if (fileData != NULL)
|
||||
@@ -515,31 +511,31 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_DDS)
|
||||
#if SUPPORT_FILEFORMAT_DDS
|
||||
else if ((strcmp(fileType, ".dds") == 0) || (strcmp(fileType, ".DDS") == 0))
|
||||
{
|
||||
image.data = rl_load_dds_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_PKM)
|
||||
#if SUPPORT_FILEFORMAT_PKM
|
||||
else if ((strcmp(fileType, ".pkm") == 0) || (strcmp(fileType, ".PKM") == 0))
|
||||
{
|
||||
image.data = rl_load_pkm_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_KTX)
|
||||
#if SUPPORT_FILEFORMAT_KTX
|
||||
else if ((strcmp(fileType, ".ktx") == 0) || (strcmp(fileType, ".KTX") == 0))
|
||||
{
|
||||
image.data = rl_load_ktx_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_PVR)
|
||||
#if SUPPORT_FILEFORMAT_PVR
|
||||
else if ((strcmp(fileType, ".pvr") == 0) || (strcmp(fileType, ".PVR") == 0))
|
||||
{
|
||||
image.data = rl_load_pvr_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_ASTC)
|
||||
#if SUPPORT_FILEFORMAT_ASTC
|
||||
else if ((strcmp(fileType, ".astc") == 0) || (strcmp(fileType, ".ASTC") == 0))
|
||||
{
|
||||
image.data = rl_load_astc_from_memory(fileData, dataSize, &image.width, &image.height, &image.format, &image.mipmaps);
|
||||
@@ -628,7 +624,7 @@ bool ExportImage(Image image, const char *fileName)
|
||||
// Security check for input data
|
||||
if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return result;
|
||||
|
||||
#if defined(SUPPORT_IMAGE_EXPORT)
|
||||
#if SUPPORT_IMAGE_EXPORT
|
||||
int channels = 4;
|
||||
bool allocatedData = false;
|
||||
unsigned char *imgData = (unsigned char *)image.data;
|
||||
@@ -645,7 +641,7 @@ bool ExportImage(Image image, const char *fileName)
|
||||
}
|
||||
|
||||
if (false) { } // Required to attach following 'else' cases
|
||||
#if defined(SUPPORT_FILEFORMAT_PNG)
|
||||
#if SUPPORT_FILEFORMAT_PNG
|
||||
else if (IsFileExtension(fileName, ".png"))
|
||||
{
|
||||
int dataSize = 0;
|
||||
@@ -654,17 +650,17 @@ bool ExportImage(Image image, const char *fileName)
|
||||
RL_FREE(fileData);
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_BMP)
|
||||
#if SUPPORT_FILEFORMAT_BMP
|
||||
else if (IsFileExtension(fileName, ".bmp")) result = stbi_write_bmp(fileName, image.width, image.height, channels, imgData);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_TGA)
|
||||
#if SUPPORT_FILEFORMAT_TGA
|
||||
else if (IsFileExtension(fileName, ".tga")) result = stbi_write_tga(fileName, image.width, image.height, channels, imgData);
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_JPG)
|
||||
#if SUPPORT_FILEFORMAT_JPG
|
||||
else if (IsFileExtension(fileName, ".jpg") ||
|
||||
IsFileExtension(fileName, ".jpeg")) result = stbi_write_jpg(fileName, image.width, image.height, channels, imgData, 90); // JPG quality: between 1 and 100
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_QOI)
|
||||
#if SUPPORT_FILEFORMAT_QOI
|
||||
else if (IsFileExtension(fileName, ".qoi"))
|
||||
{
|
||||
channels = 0;
|
||||
@@ -684,7 +680,7 @@ bool ExportImage(Image image, const char *fileName)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_KTX)
|
||||
#if SUPPORT_FILEFORMAT_KTX
|
||||
else if (IsFileExtension(fileName, ".ktx"))
|
||||
{
|
||||
result = rl_save_ktx(fileName, image.data, image.width, image.height, image.format, image.mipmaps);
|
||||
@@ -699,7 +695,7 @@ bool ExportImage(Image image, const char *fileName)
|
||||
else TRACELOG(LOG_WARNING, "IMAGE: Export image format requested not supported");
|
||||
|
||||
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);
|
||||
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
|
||||
if ((image.width == 0) || (image.height == 0) || (image.data == NULL)) return NULL;
|
||||
|
||||
#if defined(SUPPORT_IMAGE_EXPORT)
|
||||
int channels = 4;
|
||||
|
||||
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_R8G8B8A8) channels = 4;
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_PNG)
|
||||
#if SUPPORT_IMAGE_EXPORT
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
TRACELOG(LOG_WARNING, "IMAGE: To export image, enable flag SUPPORT_IMAGE_EXPORT");
|
||||
#endif
|
||||
|
||||
return fileData;
|
||||
@@ -741,8 +736,6 @@ bool ExportImageAsCode(Image image, const char *fileName)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
#if defined(SUPPORT_IMAGE_EXPORT)
|
||||
|
||||
#ifndef TEXT_BYTES_PER_LINE
|
||||
#define TEXT_BYTES_PER_LINE 20
|
||||
#endif
|
||||
@@ -785,8 +778,6 @@ bool ExportImageAsCode(Image image, const char *fileName)
|
||||
|
||||
RL_FREE(txtData);
|
||||
|
||||
#endif // SUPPORT_IMAGE_EXPORT
|
||||
|
||||
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);
|
||||
|
||||
@@ -814,7 +805,7 @@ Image GenImageColor(int width, int height, Color color)
|
||||
return image;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_IMAGE_GENERATION)
|
||||
#if SUPPORT_IMAGE_GENERATION
|
||||
// Generate image: linear gradient
|
||||
// The direction value specifies the direction of the gradient (in degrees)
|
||||
// with 0 being vertical (from top to bottom), 90 being horizontal (from left to right)
|
||||
@@ -1137,7 +1128,7 @@ Image GenImageText(int width, int height, const char *text)
|
||||
|
||||
return image;
|
||||
}
|
||||
#endif // SUPPORT_IMAGE_GENERATION
|
||||
#endif // SUPPORT_IMAGE_GENERATION
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Image manipulation functions
|
||||
@@ -1451,9 +1442,7 @@ void ImageFormat(Image *image, int newFormat)
|
||||
if (image->mipmaps > 1)
|
||||
{
|
||||
image->mipmaps = 1;
|
||||
#if defined(SUPPORT_IMAGE_MANIPULATION)
|
||||
if (image->data != NULL) ImageMipmaps(image);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
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 imText = { 0 };
|
||||
#if defined(SUPPORT_MODULE_RTEXT)
|
||||
#if SUPPORT_MODULE_RTEXT
|
||||
int defaultFontSize = 10; // Default Font chars height in pixel
|
||||
if (fontSize < defaultFontSize) fontSize = defaultFontSize;
|
||||
int spacing = fontSize/defaultFontSize;
|
||||
@@ -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 imText = { 0 };
|
||||
#if defined(SUPPORT_MODULE_RTEXT)
|
||||
#if SUPPORT_MODULE_RTEXT
|
||||
if (text == NULL) return imText;
|
||||
|
||||
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)
|
||||
// NOTE: It could be useful on OpenGL ES 2.0 (RPI, HTML5)
|
||||
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_PVRT_RGB)) ImageFormat(image, format);
|
||||
}
|
||||
#endif // SUPPORT_IMAGE_MANIPULATION
|
||||
|
||||
// Load color data from image as a Color array (RGBA - 32bit)
|
||||
// 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)
|
||||
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
|
||||
if (GetFontDefault().texture.id == 0) LoadFontDefault();
|
||||
|
||||
@@ -4234,13 +4221,11 @@ TextureCubemap LoadTextureCubemap(Image image, int layout)
|
||||
ImageFormat(&faces, image.format);
|
||||
|
||||
Image mipmapped = ImageCopy(image);
|
||||
#if defined(SUPPORT_IMAGE_MANIPULATION)
|
||||
if (image.mipmaps > 1)
|
||||
{
|
||||
ImageMipmaps(&mipmapped);
|
||||
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);
|
||||
|
||||
@@ -5599,4 +5584,4 @@ static Vector4 *LoadImageDataNormalized(Image image)
|
||||
return pixels;
|
||||
}
|
||||
|
||||
#endif // SUPPORT_MODULE_RTEXTURES
|
||||
#endif // SUPPORT_MODULE_RTEXTURES
|
||||
|
||||
Reference in New Issue
Block a user