Code cleanup. Grammar and typos fixed.

This commit is contained in:
stickm4n 2023-01-31 03:41:39 -05:00
parent df5a736c00
commit cc55e53afd
14 changed files with 257 additions and 256 deletions

View File

@ -65,7 +65,7 @@
// Support automatic generated events, loading and recording of those events when required // Support automatic generated events, loading and recording of those events when required
//#define SUPPORT_EVENTS_AUTOMATION 1 //#define SUPPORT_EVENTS_AUTOMATION 1
// Support custom frame control, only for advance users // Support custom frame control, only for advance users
// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents() // 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 // Enabling this flag allows manual control of the frame processes, use at your own risk
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1 //#define SUPPORT_CUSTOM_FRAME_CONTROL 1
@ -110,12 +110,12 @@
// Default shader vertex attribute names to set location points // Default shader vertex attribute names to set location points
// NOTE: When a new shader is loaded, the following locations are tried to be set for convenience // NOTE: When a new shader is loaded, the following locations are tried to be set for convenience
#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Binded by default to shader location: 0 #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0
#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Binded by default to shader location: 1 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1
#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Binded by default to shader location: 2 #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2
#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Binded by default to shader location: 3 #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3
#define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Binded by default to shader location: 4 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4
#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Binded by default to shader location: 5 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: 5
#define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix
#define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix
@ -139,7 +139,7 @@
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Module: rtextures - Configuration Flags // Module: rtextures - Configuration Flags
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Selecte desired fileformats to be supported for image data loading // Select desired file formats to be supported for image data loading
#define SUPPORT_FILEFORMAT_PNG 1 #define SUPPORT_FILEFORMAT_PNG 1
//#define SUPPORT_FILEFORMAT_BMP 1 //#define SUPPORT_FILEFORMAT_BMP 1
//#define SUPPORT_FILEFORMAT_TGA 1 //#define SUPPORT_FILEFORMAT_TGA 1

View File

@ -1130,7 +1130,7 @@ static bool jar_mod_load( jar_mod_context_t * modctx, void * mod_data, int mod_d
{ {
if( modctx ) if( modctx )
{ {
memcopy(&(modctx->song.title),modmemory,1084); memcopy(&(modctx->song.title),modmemory,20);
i = 0; i = 0;
modctx->number_of_channels = 0; modctx->number_of_channels = 0;

View File

@ -306,7 +306,7 @@ typedef enum {
#endif #endif
// NOTE: Different logic is used when feeding data to the playback device // NOTE: Different logic is used when feeding data to the playback device
// depending on whether or not data is streamed (Music vs Sound) // depending on whether data is streamed or not (Music vs Sound)
typedef enum { typedef enum {
AUDIO_BUFFER_USAGE_STATIC = 0, AUDIO_BUFFER_USAGE_STATIC = 0,
AUDIO_BUFFER_USAGE_STREAM AUDIO_BUFFER_USAGE_STREAM
@ -466,7 +466,7 @@ void InitAudioDevice(void)
return; return;
} }
// Mixing happens on a seperate thread which means we need to synchronize. I'm using a mutex here to make things simple, but may // Mixing happens on a seperated thread which means we need to synchronize. I'm using a mutex here to make things simple, but may
// want to look at something a bit smarter later on to keep everything real-time, if that's necessary. // want to look at something a bit smarter later on to keep everything real-time, if that's necessary.
if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS) if (ma_mutex_init(&AUDIO.System.lock) != MA_SUCCESS)
{ {
@ -707,7 +707,7 @@ void TrackAudioBuffer(AudioBuffer *buffer)
ma_mutex_unlock(&AUDIO.System.lock); ma_mutex_unlock(&AUDIO.System.lock);
} }
// Untrack audio buffer from linked list // Un-track audio buffer from linked list
void UntrackAudioBuffer(AudioBuffer *buffer) void UntrackAudioBuffer(AudioBuffer *buffer)
{ {
ma_mutex_lock(&AUDIO.System.lock); ma_mutex_lock(&AUDIO.System.lock);
@ -882,7 +882,7 @@ Sound LoadSoundFromWave(Wave wave)
if (audioBuffer == NULL) if (audioBuffer == NULL)
{ {
TRACELOG(LOG_WARNING, "SOUND: Failed to create buffer"); TRACELOG(LOG_WARNING, "SOUND: Failed to create buffer");
return sound; // early return to avoid dereferencing the audioBuffer null pointer return sound; // early return to avoid de-referencing the audioBuffer null pointer
} }
frameCount = (ma_uint32)ma_convert_frames(audioBuffer->data, frameCount, AUDIO_DEVICE_FORMAT, AUDIO_DEVICE_CHANNELS, AUDIO.System.device.sampleRate, wave.data, frameCountIn, formatIn, wave.channels, wave.sampleRate); frameCount = (ma_uint32)ma_convert_frames(audioBuffer->data, frameCount, AUDIO_DEVICE_FORMAT, AUDIO_DEVICE_CHANNELS, AUDIO.System.device.sampleRate, wave.data, frameCountIn, formatIn, wave.channels, wave.sampleRate);
@ -1050,7 +1050,7 @@ void PlaySoundMulti(Sound sound)
unsigned int oldAge = 0; unsigned int oldAge = 0;
int oldIndex = -1; int oldIndex = -1;
// find the first non playing pool entry // find the first non-playing pool entry
for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++) for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++)
{ {
if (AUDIO.MultiChannel.channels[i] > oldAge) if (AUDIO.MultiChannel.channels[i] > oldAge)
@ -1066,7 +1066,7 @@ void PlaySoundMulti(Sound sound)
} }
} }
// If no none playing pool members can be index choose the oldest // If no non-playing pool members can be indexed, choose the oldest
if (index == -1) if (index == -1)
{ {
TRACELOG(LOG_WARNING, "SOUND: Buffer pool is already full, count: %i", AUDIO.MultiChannel.poolCounter); TRACELOG(LOG_WARNING, "SOUND: Buffer pool is already full, count: %i", AUDIO.MultiChannel.poolCounter);
@ -2000,8 +2000,8 @@ void UnloadAudioStream(AudioStream stream)
} }
// Update audio stream buffers with data // Update audio stream buffers with data
// NOTE 1: Only updates one buffer of the stream source: unqueue -> update -> queue // NOTE 1: Only updates one buffer of the stream source: un-queue -> update -> queue
// NOTE 2: To unqueue a buffer it needs to be processed: IsAudioStreamProcessed() // NOTE 2: To un-queue a buffer it needs to be processed: IsAudioStreamProcessed()
void UpdateAudioStream(AudioStream stream, const void *data, int frameCount) void UpdateAudioStream(AudioStream stream, const void *data, int frameCount)
{ {
if (stream.buffer != NULL) if (stream.buffer != NULL)
@ -2198,7 +2198,7 @@ static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer,
if (currentSubBufferIndex > 1) return 0; if (currentSubBufferIndex > 1) return 0;
// Another thread can update the processed state of buffers so // Another thread can update the processed state of buffers so if
// we just take a copy here to try and avoid potential synchronization problems // we just take a copy here to try and avoid potential synchronization problems
bool isSubBufferProcessed[2] = { 0 }; bool isSubBufferProcessed[2] = { 0 };
isSubBufferProcessed[0] = audioBuffer->isSubBufferProcessed[0]; isSubBufferProcessed[0] = audioBuffer->isSubBufferProcessed[0];
@ -2212,7 +2212,7 @@ static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer,
{ {
// We break from this loop differently depending on the buffer's usage // We break from this loop differently depending on the buffer's usage
// - For static buffers, we simply fill as much data as we can // - For static buffers, we simply fill as much data as we can
// - For streaming buffers we only fill the halves of the buffer that are processed // - For streaming buffers we only fill halves of the buffer that are processed
// Unprocessed halves must keep their audio data in-tact // Unprocessed halves must keep their audio data in-tact
if (audioBuffer->usage == AUDIO_BUFFER_USAGE_STATIC) if (audioBuffer->usage == AUDIO_BUFFER_USAGE_STATIC)
{ {
@ -2269,7 +2269,7 @@ static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer,
// For static buffers we can fill the remaining frames with silence for safety, but we don't want // For static buffers we can fill the remaining frames with silence for safety, but we don't want
// to report those frames as "read". The reason for this is that the caller uses the return value // to report those frames as "read". The reason for this is that the caller uses the return value
// to know whether or not a non-looping sound has finished playback. // to know whether a non-looping sound has finished playback or not.
if (audioBuffer->usage != AUDIO_BUFFER_USAGE_STATIC) framesRead += totalFramesRemaining; if (audioBuffer->usage != AUDIO_BUFFER_USAGE_STATIC) framesRead += totalFramesRemaining;
} }

View File

@ -216,7 +216,7 @@ typedef struct Vector4 {
// Quaternion, 4 components (Vector4 alias) // Quaternion, 4 components (Vector4 alias)
typedef Vector4 Quaternion; typedef Vector4 Quaternion;
// Matrix, 4x4 components, column major, OpenGL style, right handed // Matrix, 4x4 components, column major, OpenGL style, right-handed
typedef struct Matrix { typedef struct Matrix {
float m0, m4, m8, m12; // Matrix first row (4 components) float m0, m4, m8, m12; // Matrix first row (4 components)
float m1, m5, m9, m13; // Matrix second row (4 components) float m1, m5, m9, m13; // Matrix second row (4 components)
@ -413,8 +413,8 @@ typedef struct Ray {
// RayCollision, ray hit information // RayCollision, ray hit information
typedef struct RayCollision { typedef struct RayCollision {
bool hit; // Did the ray hit something? bool hit; // Did the ray hit something?
float distance; // Distance to nearest hit float distance; // Distance to the nearest hit
Vector3 point; // Point of nearest hit Vector3 point; // Point of the nearest hit
Vector3 normal; // Surface normal of hit Vector3 normal; // Surface normal of hit
} RayCollision; } RayCollision;
@ -428,7 +428,7 @@ typedef struct BoundingBox {
typedef struct Wave { typedef struct Wave {
unsigned int frameCount; // Total number of frames (considering channels) unsigned int frameCount; // Total number of frames (considering channels)
unsigned int sampleRate; // Frequency (samples per second) unsigned int sampleRate; // Frequency (samples per second)
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) unsigned int sampleSize; // The bit depth (bits per sample): 8, 16, 32 (24 not supported)
unsigned int channels; // Number of channels (1-mono, 2-stereo, ...) unsigned int channels; // Number of channels (1-mono, 2-stereo, ...)
void *data; // Buffer data pointer void *data; // Buffer data pointer
} Wave; } Wave;
@ -444,7 +444,7 @@ typedef struct AudioStream {
rAudioProcessor *processor; // Pointer to internal data processor, useful for audio effects rAudioProcessor *processor; // Pointer to internal data processor, useful for audio effects
unsigned int sampleRate; // Frequency (samples per second) unsigned int sampleRate; // Frequency (samples per second)
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) unsigned int sampleSize; // The bit depth (bits per sample): 8, 16, 32 (24 not supported)
unsigned int channels; // Number of channels (1-mono, 2-stereo, ...) unsigned int channels; // Number of channels (1-mono, 2-stereo, ...)
} AudioStream; } AudioStream;
@ -492,9 +492,9 @@ typedef struct VrStereoConfig {
// File path list // File path list
typedef struct FilePathList { typedef struct FilePathList {
unsigned int capacity; // Filepaths max entries unsigned int capacity; // Filepath max entries
unsigned int count; // Filepaths entries count unsigned int count; // Filepath entries count
char **paths; // Filepaths entries char **paths; // Filepath entries
} FilePathList; } FilePathList;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -681,7 +681,7 @@ typedef enum {
MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape MOUSE_CURSOR_RESIZE_NS = 6, // Vertical resize/move arrow shape
MOUSE_CURSOR_RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape MOUSE_CURSOR_RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape
MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape MOUSE_CURSOR_RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape
MOUSE_CURSOR_RESIZE_ALL = 9, // The omni-directional resize/move cursor shape MOUSE_CURSOR_RESIZE_ALL = 9, // The omnidirectional resize/move cursor shape
MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape MOUSE_CURSOR_NOT_ALLOWED = 10 // The operation-not-allowed shape
} MouseCursor; } MouseCursor;
@ -839,7 +839,7 @@ typedef enum {
typedef enum { typedef enum {
CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type CUBEMAP_LAYOUT_AUTO_DETECT = 0, // Automatically detect layout type
CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces CUBEMAP_LAYOUT_LINE_VERTICAL, // Layout is defined by a vertical line with faces
CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces CUBEMAP_LAYOUT_LINE_HORIZONTAL, // Layout is defined by a horizontal line with faces
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces
CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirectangular map) CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirectangular map)
@ -903,7 +903,7 @@ typedef enum {
} NPatchLayout; } NPatchLayout;
// Callbacks to hook some internal functions // Callbacks to hook some internal functions
// WARNING: This callbacks are intended for advance users // WARNING: These callbacks are intended for advance users
typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages
typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data
typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data
@ -1179,8 +1179,8 @@ RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Colo
RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version) RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version)
RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness
RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out
RLAPI void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color); // Draw line using quadratic bezier curves with a control point RLAPI void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color); // Draw line using quadratic zier curves with a control point
RLAPI void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color); // Draw line using cubic bezier curves with 2 control points RLAPI void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color); // Draw line using cubic zier curves with 2 control points
RLAPI void DrawLineStrip(Vector2 *points, int pointCount, Color color); // Draw lines sequence RLAPI void DrawLineStrip(Vector2 *points, int pointCount, Color color); // Draw lines sequence
RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
RLAPI void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw a piece of a circle RLAPI void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); // Draw a piece of a circle
@ -1228,7 +1228,7 @@ RLAPI Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2);
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Image loading functions // Image loading functions
// NOTE: This functions do not require GPU access // NOTE: These functions do not require GPU access
RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM) RLAPI Image LoadImage(const char *fileName); // Load image from file into CPU memory (RAM)
RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data RLAPI Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image from RAW file data
RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data) RLAPI Image LoadImageAnim(const char *fileName, int *frames); // Load image sequence from file (frames appended to image.data)

View File

@ -585,12 +585,12 @@ RMAPI Vector3 Vector3Perpendicular(Vector3 v)
{ {
Vector3 result = { 0 }; Vector3 result = { 0 };
float min = (float) fabs(v.x); float min = fabsf(v.x);
Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f}; Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};
if (fabsf(v.y) < min) if (fabsf(v.y) < min)
{ {
min = (float) fabs(v.y); min = fabsf(v.y);
Vector3 tmp = {0.0f, 1.0f, 0.0f}; Vector3 tmp = {0.0f, 1.0f, 0.0f};
cardinalAxis = tmp; cardinalAxis = tmp;
} }
@ -903,7 +903,7 @@ RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
{ {
Vector3 result = { 0 }; Vector3 result = { 0 };
// Calculate unproject matrix (multiply view matrix by projection matrix) and invert it // Calculate un-project matrix (multiply view matrix by projection matrix) and invert it
Matrix matViewProj = { // MatrixMultiply(view, projection); Matrix matViewProj = { // MatrixMultiply(view, projection);
view.m0*projection.m0 + view.m1*projection.m4 + view.m2*projection.m8 + view.m3*projection.m12, view.m0*projection.m0 + view.m1*projection.m4 + view.m2*projection.m8 + view.m3*projection.m12,
view.m0*projection.m1 + view.m1*projection.m5 + view.m2*projection.m9 + view.m3*projection.m13, view.m0*projection.m1 + view.m1*projection.m5 + view.m2*projection.m9 + view.m3*projection.m13,
@ -966,7 +966,7 @@ RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
// Create quaternion from source point // Create quaternion from source point
Quaternion quat = { source.x, source.y, source.z, 1.0f }; Quaternion quat = { source.x, source.y, source.z, 1.0f };
// Multiply quat point by unproject matrix // Multiply quat point by un-project matrix
Quaternion qtransformed = { // QuaternionTransform(quat, matViewProjInv) Quaternion qtransformed = { // QuaternionTransform(quat, matViewProjInv)
matViewProjInv.m0*quat.x + matViewProjInv.m4*quat.y + matViewProjInv.m8*quat.z + matViewProjInv.m12*quat.w, matViewProjInv.m0*quat.x + matViewProjInv.m4*quat.y + matViewProjInv.m8*quat.z + matViewProjInv.m12*quat.w,
matViewProjInv.m1*quat.x + matViewProjInv.m5*quat.y + matViewProjInv.m9*quat.z + matViewProjInv.m13*quat.w, matViewProjInv.m1*quat.x + matViewProjInv.m5*quat.y + matViewProjInv.m9*quat.z + matViewProjInv.m13*quat.w,
@ -1927,6 +1927,8 @@ RMAPI Quaternion QuaternionFromMatrix(Matrix mat)
result.x = (mat.m8 + mat.m2) * mult; result.x = (mat.m8 + mat.m2) * mult;
result.y = (mat.m6 + mat.m9) * mult; result.y = (mat.m6 + mat.m9) * mult;
break; break;
default: /* Suppress warnings */
break;
} }
return result; return result;

View File

@ -150,7 +150,7 @@ void SetCameraMoveControls(int keyFront, int keyBack,
#endif #endif
// Camera mouse movement sensitivity // Camera mouse movement sensitivity
#define CAMERA_MOUSE_MOVE_SENSITIVITY 0.5f // TODO: it should be independant of framerate #define CAMERA_MOUSE_MOVE_SENSITIVITY 0.5f // TODO: it should be independent of framerate
#define CAMERA_MOUSE_SCROLL_SENSITIVITY 1.5f #define CAMERA_MOUSE_SCROLL_SENSITIVITY 1.5f
// FREE_CAMERA // FREE_CAMERA
@ -158,7 +158,7 @@ void SetCameraMoveControls(int keyFront, int keyBack,
#define CAMERA_FREE_DISTANCE_MIN_CLAMP 0.3f #define CAMERA_FREE_DISTANCE_MIN_CLAMP 0.3f
#define CAMERA_FREE_DISTANCE_MAX_CLAMP 120.0f #define CAMERA_FREE_DISTANCE_MAX_CLAMP 120.0f
#define CAMERA_FREE_MIN_CLAMP 85.0f #define CAMERA_FREE_MIN_CLAMP 85.0f
#define CAMERA_FREE_MAX_CLAMP -85.0f #define CAMERA_FREE_MAX_CLAMP (-85.0f)
#define CAMERA_FREE_SMOOTH_ZOOM_SENSITIVITY 0.05f #define CAMERA_FREE_SMOOTH_ZOOM_SENSITIVITY 0.05f
#define CAMERA_FREE_PANNING_DIVIDER 5.1f #define CAMERA_FREE_PANNING_DIVIDER 5.1f
@ -169,7 +169,7 @@ void SetCameraMoveControls(int keyFront, int keyBack,
//#define CAMERA_FIRST_PERSON_MOUSE_SENSITIVITY 0.003f //#define CAMERA_FIRST_PERSON_MOUSE_SENSITIVITY 0.003f
#define CAMERA_FIRST_PERSON_FOCUS_DISTANCE 25.0f #define CAMERA_FIRST_PERSON_FOCUS_DISTANCE 25.0f
#define CAMERA_FIRST_PERSON_MIN_CLAMP 89.0f #define CAMERA_FIRST_PERSON_MIN_CLAMP 89.0f
#define CAMERA_FIRST_PERSON_MAX_CLAMP -89.0f #define CAMERA_FIRST_PERSON_MAX_CLAMP (-89.0f)
// When walking, y-position of the player moves up-down at step frequency (swinging) but // When walking, y-position of the player moves up-down at step frequency (swinging) but
// also the body slightly tilts left-right on every step, when all the body weight is left over one foot (tilting) // also the body slightly tilts left-right on every step, when all the body weight is left over one foot (tilting)
@ -181,7 +181,7 @@ void SetCameraMoveControls(int keyFront, int keyBack,
//#define CAMERA_THIRD_PERSON_MOUSE_SENSITIVITY 0.003f //#define CAMERA_THIRD_PERSON_MOUSE_SENSITIVITY 0.003f
#define CAMERA_THIRD_PERSON_DISTANCE_CLAMP 1.2f #define CAMERA_THIRD_PERSON_DISTANCE_CLAMP 1.2f
#define CAMERA_THIRD_PERSON_MIN_CLAMP 5.0f #define CAMERA_THIRD_PERSON_MIN_CLAMP 5.0f
#define CAMERA_THIRD_PERSON_MAX_CLAMP -85.0f #define CAMERA_THIRD_PERSON_MAX_CLAMP (-85.0f)
#define CAMERA_THIRD_PERSON_OFFSET (Vector3){ 0.4f, 0.0f, 0.0f } #define CAMERA_THIRD_PERSON_OFFSET (Vector3){ 0.4f, 0.0f, 0.0f }
// PLAYER (used by camera) // PLAYER (used by camera)
@ -313,45 +313,44 @@ void UpdateCamera(Camera *camera)
} }
// Camera looking down // Camera looking down
else if ((camera->position.y > camera->target.y) && (CAMERA.targetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0)) else if ((camera->position.y > camera->target.y))
{ {
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance; if (CAMERA.targetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP && mouseWheelMove < 0 || camera->target.y >= 0)
camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
}
else if ((camera->position.y > camera->target.y) && (camera->target.y >= 0))
{ {
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance; camera->target.x +=
camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance; mouseWheelMove * (camera->target.x - camera->position.x) * CAMERA_MOUSE_SCROLL_SENSITIVITY /
camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance; CAMERA.targetDistance;
camera->target.y +=
mouseWheelMove * (camera->target.y - camera->position.y) * CAMERA_MOUSE_SCROLL_SENSITIVITY /
CAMERA.targetDistance;
camera->target.z +=
mouseWheelMove * (camera->target.z - camera->position.z) * CAMERA_MOUSE_SCROLL_SENSITIVITY /
CAMERA.targetDistance;
// if (camera->target.y < 0) camera->target.y = -0.001; // if (camera->target.y < 0) camera->target.y = -0.001;
} }
else if ((camera->position.y > camera->target.y) && (camera->target.y < 0) && (mouseWheelMove > 0)) else if ((camera->target.y < 0) && (mouseWheelMove > 0)) {
{
CAMERA.targetDistance -= (mouseWheelMove * CAMERA_MOUSE_SCROLL_SENSITIVITY); CAMERA.targetDistance -= (mouseWheelMove * CAMERA_MOUSE_SCROLL_SENSITIVITY);
if (CAMERA.targetDistance < CAMERA_FREE_DISTANCE_MIN_CLAMP) CAMERA.targetDistance = CAMERA_FREE_DISTANCE_MIN_CLAMP; if (CAMERA.targetDistance < CAMERA_FREE_DISTANCE_MIN_CLAMP)
CAMERA.targetDistance = CAMERA_FREE_DISTANCE_MIN_CLAMP;
} }
// Camera looking up
else if ((camera->position.y < camera->target.y) && (CAMERA.targetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0))
{
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
} }
else if ((camera->position.y < camera->target.y) && (camera->target.y <= 0))
{
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
// if (camera->target.y > 0) camera->target.y = 0.001; // Camera looking up
else if (camera->position.y < camera->target.y)
{
if (CAMERA.targetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP && mouseWheelMove < 0 || camera->target.y <= 0)
{
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
camera->target.y += mouseWheelMove*(camera->target.y - camera->position.y)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
camera->target.z += mouseWheelMove*(camera->target.z - camera->position.z)*CAMERA_MOUSE_SCROLL_SENSITIVITY/CAMERA.targetDistance;
} }
else if ((camera->position.y < camera->target.y) && (camera->target.y > 0) && (mouseWheelMove > 0)) else if (camera->target.y > 0 && mouseWheelMove > 0)
{ {
CAMERA.targetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY); CAMERA.targetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY);
if (CAMERA.targetDistance < CAMERA_FREE_DISTANCE_MIN_CLAMP) CAMERA.targetDistance = CAMERA_FREE_DISTANCE_MIN_CLAMP; if (CAMERA.targetDistance < CAMERA_FREE_DISTANCE_MIN_CLAMP) CAMERA.targetDistance = CAMERA_FREE_DISTANCE_MIN_CLAMP;
} }
}
// Input keys checks // Input keys checks
if (keyPan) if (keyPan)
@ -530,7 +529,7 @@ void UpdateCamera(Camera *camera)
camera->position.z = cosf(CAMERA.angle.x)*CAMERA.targetDistance*cosf(CAMERA.angle.y) + camera->target.z; camera->position.z = cosf(CAMERA.angle.x)*CAMERA.targetDistance*cosf(CAMERA.angle.y) + camera->target.z;
} break; } break;
case CAMERA_CUSTOM: break; case CAMERA_CUSTOM:
default: break; default: break;
} }
} }

View File

@ -626,8 +626,8 @@ static bool InitGraphicsDevice(int width, int height); // Initialize graphics d
static void SetupFramebuffer(int width, int height); // Setup main framebuffer static void SetupFramebuffer(int width, int height); // Setup main framebuffer
static void SetupViewport(int width, int height); // Set viewport for a provided width and height static void SetupViewport(int width, int height); // Set viewport for a provided width and height
static void ScanDirectoryFiles(const char *basePath, FilePathList *list, const char *filter); // Scan all files and directories in a base path static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const char *filter); // Scan all files and directories in a base path
static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *list, const char *filter); // Scan all files and directories recursively from a base path static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *files, const char *filter); // Scan all files and directories recursively from a base path
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error
@ -1317,7 +1317,7 @@ void MaximizeWindow(void)
void MinimizeWindow(void) void MinimizeWindow(void)
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
// NOTE: Following function launches callback that sets appropiate flag! // NOTE: Following function launches callback that sets appropriate flag!
glfwIconifyWindow(CORE.Window.handle); glfwIconifyWindow(CORE.Window.handle);
#endif #endif
} }
@ -2193,7 +2193,7 @@ void BeginMode3D(Camera3D camera)
rlDrawRenderBatchActive(); // Update and draw internal render batch rlDrawRenderBatchActive(); // Update and draw internal render batch
rlMatrixMode(RL_PROJECTION); // Switch to projection matrix rlMatrixMode(RL_PROJECTION); // Switch to projection matrix
rlPushMatrix(); // Save previous matrix, which contains the settings for the 2d ortho projection rlPushMatrix(); // Save previous matrix, which contains the settings for the 2d orthogonal projection
rlLoadIdentity(); // Reset current matrix (projection) rlLoadIdentity(); // Reset current matrix (projection)
float aspect = (float)CORE.Window.currentFbo.width/(float)CORE.Window.currentFbo.height; float aspect = (float)CORE.Window.currentFbo.width/(float)CORE.Window.currentFbo.height;
@ -2469,7 +2469,7 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
// After shader loading, we TRY to set default location names // After shader loading, we TRY to set default location names
if (shader.id > 0) if (shader.id > 0)
{ {
// Default shader attribute locations have been binded before linking: // Default shader attribute locations have been bound before linking:
// vertex position location = 0 // vertex position location = 0
// vertex texcoord location = 1 // vertex texcoord location = 1
// vertex normal location = 2 // vertex normal location = 2
@ -2484,7 +2484,7 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode)
// All locations reseted to -1 (no location) // All locations reseted to -1 (no location)
for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1; for (int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++) shader.locs[i] = -1;
// Get handles to GLSL input attibute locations // Get handles to GLSL input attribute locations
shader.locs[SHADER_LOC_VERTEX_POSITION] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION); shader.locs[SHADER_LOC_VERTEX_POSITION] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION);
shader.locs[SHADER_LOC_VERTEX_TEXCOORD01] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD); shader.locs[SHADER_LOC_VERTEX_TEXCOORD01] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD);
shader.locs[SHADER_LOC_VERTEX_TEXCOORD02] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2); shader.locs[SHADER_LOC_VERTEX_TEXCOORD02] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2);
@ -2552,7 +2552,7 @@ void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniform
{ {
rlEnableShader(shader.id); rlEnableShader(shader.id);
rlSetUniform(locIndex, value, uniformType, count); rlSetUniform(locIndex, value, uniformType, count);
//rlDisableShader(); // Avoid reseting current shader program, in case other uniforms are set //rlDisableShader(); // Avoid resetting current shader program, in case other uniforms are set
} }
} }
@ -2617,7 +2617,7 @@ Ray GetMouseRay(Vector2 mouse, Camera camera)
Vector3 farPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView); Vector3 farPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
// Unproject the mouse cursor in the near plane. // Unproject the mouse cursor in the near plane.
// We need this as the source position because orthographic projects, compared to perspect doesn't have a // We need this as the source position because orthographic projects, compared to perspective doesn't have a
// convergence point, meaning that the "eye" of the camera is more like a plane than a point. // convergence point, meaning that the "eye" of the camera is more like a plane than a point.
Vector3 cameraPlanePointerPos = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView); Vector3 cameraPlanePointerPos = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView);
@ -2754,7 +2754,7 @@ int GetFPS(void)
#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL) #if !defined(SUPPORT_CUSTOM_FRAME_CONTROL)
#define FPS_CAPTURE_FRAMES_COUNT 30 // 30 captures #define FPS_CAPTURE_FRAMES_COUNT 30 // 30 captures
#define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 millisecondes #define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 milliseconds
#define FPS_STEP (FPS_AVERAGE_TIME_SECONDS/FPS_CAPTURE_FRAMES_COUNT) #define FPS_STEP (FPS_AVERAGE_TIME_SECONDS/FPS_CAPTURE_FRAMES_COUNT)
static int index = 0; static int index = 0;
@ -2807,7 +2807,7 @@ double GetTime(void)
// Setup window configuration flags (view FLAGS) // Setup window configuration flags (view FLAGS)
// NOTE: This function is expected to be called before window creation, // NOTE: This function is expected to be called before window creation,
// because it setups some flags for the window creation process. // because it sets up some flags for the window creation process.
// To configure window states after creation, just use SetWindowState() // To configure window states after creation, just use SetWindowState()
void SetConfigFlags(unsigned int flags) void SetConfigFlags(unsigned int flags)
{ {
@ -3032,7 +3032,7 @@ const char *GetDirectoryPath(const char *filePath)
if (filePath[1] != ':' && filePath[0] != '\\' && filePath[0] != '/') if (filePath[1] != ':' && filePath[0] != '\\' && filePath[0] != '/')
{ {
// For security, we set starting path to current directory, // For security, we set starting path to current directory,
// obtained path will be concated to this // obtained path will be concat to this
dirPath[0] = '.'; dirPath[0] = '.';
dirPath[1] = '/'; dirPath[1] = '/';
} }
@ -3226,7 +3226,7 @@ FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool
} }
// Unload directory file paths // Unload directory file paths
// WARNING: files.count is not reseted to 0 after unloading // WARNING: files.count is not reset to 0 after unloading
void UnloadDirectoryFiles(FilePathList files) void UnloadDirectoryFiles(FilePathList files)
{ {
for (unsigned int i = 0; i < files.capacity; i++) RL_FREE(files.paths[i]); for (unsigned int i = 0; i < files.capacity; i++) RL_FREE(files.paths[i]);
@ -4096,11 +4096,11 @@ static bool InitGraphicsDevice(int width, int height)
if (CORE.Window.fullscreen) if (CORE.Window.fullscreen)
{ {
// remember center for switchinging from fullscreen to window // remember center for switching from fullscreen to window
if ((CORE.Window.screen.height == CORE.Window.display.height) && (CORE.Window.screen.width == CORE.Window.display.width)) if ((CORE.Window.screen.height == CORE.Window.display.height) && (CORE.Window.screen.width == CORE.Window.display.width))
{ {
// If screen width/height equal to the dislpay, we can't calclulate the window pos for toggling fullscreened/windowed. // If screen width/height equal to the display, we can't calculate the window pos for toggling full-screened/windowed.
// Toggling fullscreened/windowed with pos(0, 0) can cause problems in some platforms, such as X11. // Toggling full-screened/windowed with pos(0, 0) can cause problems in some platforms, such as X11.
CORE.Window.position.x = CORE.Window.display.width/4; CORE.Window.position.x = CORE.Window.display.width/4;
CORE.Window.position.y = CORE.Window.display.height/4; CORE.Window.position.y = CORE.Window.display.height/4;
} }
@ -4137,7 +4137,7 @@ static bool InitGraphicsDevice(int width, int height)
// framebuffer is rendered correctly but once displayed on a 16:9 monitor, it gets stretched // framebuffer is rendered correctly but once displayed on a 16:9 monitor, it gets stretched
// by the sides to fit all monitor space... // by the sides to fit all monitor space...
// Try to setup the most appropiate fullscreen framebuffer for the requested screenWidth/screenHeight // Try to setup the most appropriate fullscreen framebuffer for the requested screenWidth/screenHeight
// It considers device display resolution mode and setups a framebuffer with black bars if required (render size/offset) // It considers device display resolution mode and setups a framebuffer with black bars if required (render size/offset)
// Modified global variables: CORE.Window.screen.width/CORE.Window.screen.height - CORE.Window.render.width/CORE.Window.render.height - CORE.Window.renderOffset.x/CORE.Window.renderOffset.y - CORE.Window.screenScale // Modified global variables: CORE.Window.screen.width/CORE.Window.screen.height - CORE.Window.render.width/CORE.Window.render.height - CORE.Window.renderOffset.x/CORE.Window.renderOffset.y - CORE.Window.screenScale
// TODO: It is a quite cumbersome solution to display size vs requested size, it should be reviewed or removed... // TODO: It is a quite cumbersome solution to display size vs requested size, it should be reviewed or removed...
@ -4204,7 +4204,7 @@ static bool InitGraphicsDevice(int width, int height)
// NOTE: V-Sync can be enabled by graphic driver configuration // NOTE: V-Sync can be enabled by graphic driver configuration
if (CORE.Window.flags & FLAG_VSYNC_HINT) if (CORE.Window.flags & FLAG_VSYNC_HINT)
{ {
// WARNING: It seems to hits a critical render path in Intel HD Graphics // WARNING: It seems to hit a critical render path in Intel HD Graphics
glfwSwapInterval(1); glfwSwapInterval(1);
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable VSYNC"); TRACELOG(LOG_INFO, "DISPLAY: Trying to enable VSYNC");
} }
@ -4220,7 +4220,7 @@ static bool InitGraphicsDevice(int width, int height)
#if !defined(__APPLE__) #if !defined(__APPLE__)
glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight); glfwGetFramebufferSize(CORE.Window.handle, &fbWidth, &fbHeight);
// Screen scaling matrix is required in case desired screen area is different than display area // Screen scaling matrix is required in case desired screen area is different from display area
CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f); CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f);
// Mouse input scaling for the new screen size // Mouse input scaling for the new screen size
@ -4818,7 +4818,7 @@ static void InitTimer(void)
// NOTE: Sleep() granularity could be around 10 ms, it means, Sleep() could // NOTE: Sleep() granularity could be around 10 ms, it means, Sleep() could
// take longer than expected... for that reason we use the busy wait loop // take longer than expected... for that reason we use the busy wait loop
// Ref: http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected // Ref: http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected
// Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timming on Win32! // Ref: http://www.geisswerks.com/ryan/FAQS/timing.html --> All about timing on Win32!
void WaitTime(double seconds) void WaitTime(double seconds)
{ {
#if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP) #if defined(SUPPORT_BUSY_WAIT_LOOP) || defined(SUPPORT_PARTIALBUSY_WAIT_LOOP)
@ -4989,7 +4989,7 @@ void PollInputEvents(void)
// NOTE: There is no callback available, so we get it manually // NOTE: There is no callback available, so we get it manually
// Get remapped buttons // Get remapped buttons
GLFWgamepadstate state = { 0 }; GLFWgamepadstate state = { 0 };
glfwGetGamepadState(i, &state); // This remapps all gamepads so they have their buttons mapped like an xbox controller glfwGetGamepadState(i, &state); // This remaps all gamepads, so they have their buttons mapped like an xbox controller
const unsigned char *buttons = state.buttons; const unsigned char *buttons = state.buttons;
@ -5413,7 +5413,7 @@ static void CharCallback(GLFWwindow *window, unsigned int key)
//TRACELOG(LOG_DEBUG, "Char Callback: KEY:%i(%c)", key, key); //TRACELOG(LOG_DEBUG, "Char Callback: KEY:%i(%c)", key, key);
// NOTE: Registers any key down considering OS keyboard layout but // NOTE: Registers any key down considering OS keyboard layout but
// do not detects action events, those should be managed by user... // do not detect action events, those should be managed by user...
// Ref: https://github.com/glfw/glfw/issues/668#issuecomment-166794907 // Ref: https://github.com/glfw/glfw/issues/668#issuecomment-166794907
// Ref: https://www.glfw.org/docs/latest/input_guide.html#input_char // Ref: https://www.glfw.org/docs/latest/input_guide.html#input_char
@ -5456,7 +5456,7 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
gestureEvent.position[0].x /= (float)GetScreenWidth(); gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight(); gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures system for processing // Gesture data is sent to gesture system for processing
ProcessGestureEvent(gestureEvent); ProcessGestureEvent(gestureEvent);
#endif #endif
} }
@ -5487,7 +5487,7 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y)
gestureEvent.position[0].x /= (float)GetScreenWidth(); gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight(); gestureEvent.position[0].y /= (float)GetScreenHeight();
// Gesture data is sent to gestures system for processing // Gesture data is sent to gesture system for processing
ProcessGestureEvent(gestureEvent); ProcessGestureEvent(gestureEvent);
#endif #endif
} }

View File

@ -241,7 +241,7 @@ static GesturesData GESTURES = {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module specific Functions Declaration // Module specific Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static float rgVector2Angle(Vector2 initialPosition, Vector2 finalPosition); static float rgVector2Angle(Vector2 v1, Vector2 v2);
static float rgVector2Distance(Vector2 v1, Vector2 v2); static float rgVector2Distance(Vector2 v1, Vector2 v2);
static double rgGetCurrentTime(void); static double rgGetCurrentTime(void);
@ -249,7 +249,7 @@ static double rgGetCurrentTime(void);
// Module Functions Definition // Module Functions Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Enable only desired getures to be detected // Enable only desired gestures to be detected
void SetGesturesEnabled(unsigned int flags) void SetGesturesEnabled(unsigned int flags)
{ {
GESTURES.enabledFlags = flags; GESTURES.enabledFlags = flags;
@ -300,7 +300,7 @@ void ProcessGestureEvent(GestureEvent event)
{ {
if (GESTURES.current == GESTURE_DRAG) GESTURES.Touch.upPosition = event.position[0]; if (GESTURES.current == GESTURE_DRAG) GESTURES.Touch.upPosition = event.position[0];
// NOTE: GESTURES.Drag.intensity dependend on the resolution of the screen // NOTE: GESTURES.Drag.intensity dependent on the resolution of the screen
GESTURES.Drag.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition); GESTURES.Drag.distance = rgVector2Distance(GESTURES.Touch.downPositionA, GESTURES.Touch.upPosition);
GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((rgGetCurrentTime() - GESTURES.Swipe.timeDuration)); GESTURES.Drag.intensity = GESTURES.Drag.distance/(float)((rgGetCurrentTime() - GESTURES.Swipe.timeDuration));
@ -488,7 +488,7 @@ Vector2 GetGesturePinchVector(void)
return GESTURES.Pinch.vector; return GESTURES.Pinch.vector;
} }
// Get angle beween two pinch points // Get angle between two pinch points
// NOTE: Angle in degrees, horizontal-right is 0, counter clock-wise // NOTE: Angle in degrees, horizontal-right is 0, counter clock-wise
float GetGesturePinchAngle(void) float GetGesturePinchAngle(void)
{ {
@ -518,7 +518,7 @@ static float rgVector2Distance(Vector2 v1, Vector2 v2)
float dx = v2.x - v1.x; float dx = v2.x - v1.x;
float dy = v2.y - v1.y; float dy = v2.y - v1.y;
result = (float)sqrt(dx*dx + dy*dy); result = sqrtf(dx*dx + dy*dy);
return result; return result;
} }

View File

@ -502,7 +502,7 @@ typedef enum {
} rlShaderAttributeDataType; } rlShaderAttributeDataType;
// Framebuffer attachment type // Framebuffer attachment type
// NOTE: By default up to 8 color channels defined but it can be more // NOTE: By default up to 8 color channels defined, but it can be more
typedef enum { typedef enum {
RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0 RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0
RL_ATTACHMENT_COLOR_CHANNEL1, // Framebuffer attachment type: color 1 RL_ATTACHMENT_COLOR_CHANNEL1, // Framebuffer attachment type: color 1

View File

@ -1125,7 +1125,7 @@ void UnloadModel(Model model)
// Unload materials maps // Unload materials maps
// NOTE: As the user could be sharing shaders and textures between models, // NOTE: As the user could be sharing shaders and textures between models,
// we don't unload the material but just free it's maps, // we don't unload the material but just free its maps,
// the user is responsible for freeing models shaders and textures // the user is responsible for freeing models shaders and textures
for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps); for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps);
@ -1146,7 +1146,7 @@ void UnloadModelKeepMeshes(Model model)
{ {
// Unload materials maps // Unload materials maps
// NOTE: As the user could be sharing shaders and textures between models, // NOTE: As the user could be sharing shaders and textures between models,
// we don't unload the material but just free it's maps, // we don't unload the material but just free its maps,
// the user is responsible for freeing models shaders and textures // the user is responsible for freeing models shaders and textures
for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps); for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps);
@ -1230,7 +1230,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
rlEnableVertexAttribute(1); rlEnableVertexAttribute(1);
// WARNING: When setting default vertex attribute values, the values for each generic vertex attribute // WARNING: When setting default vertex attribute values, the values for each generic vertex attribute
// is part of current state and it is maintained even if a different program object is used // is part of current state, and it is maintained even if a different program object is used
if (mesh->normals != NULL) if (mesh->normals != NULL)
{ {
@ -1383,7 +1383,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
} }
// Get a copy of current matrices to work with, // Get a copy of current matrices to work with,
// just in case stereo render is required and we need to modify them // just in case stereo render is required, and we need to modify them
// NOTE: At this point the modelview matrix just contains the view matrix (camera) // NOTE: At this point the modelview matrix just contains the view matrix (camera)
// That's because BeginMode3D() sets it and there is no model-drawing function // That's because BeginMode3D() sets it and there is no model-drawing function
// that modifies it, all use rlPushMatrix() and rlPopMatrix() // that modifies it, all use rlPushMatrix() and rlPopMatrix()
@ -1396,7 +1396,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
if (material.shader.locs[SHADER_LOC_MATRIX_VIEW] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_VIEW], matView); if (material.shader.locs[SHADER_LOC_MATRIX_VIEW] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_VIEW], matView);
if (material.shader.locs[SHADER_LOC_MATRIX_PROJECTION] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_PROJECTION], matProjection); if (material.shader.locs[SHADER_LOC_MATRIX_PROJECTION] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_PROJECTION], matProjection);
// Model transformation matrix is send to shader uniform location: SHADER_LOC_MATRIX_MODEL // Model transformation matrix is sent to shader uniform location: SHADER_LOC_MATRIX_MODEL
if (material.shader.locs[SHADER_LOC_MATRIX_MODEL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_MODEL], transform); if (material.shader.locs[SHADER_LOC_MATRIX_MODEL] != -1) rlSetUniformMatrix(material.shader.locs[SHADER_LOC_MATRIX_MODEL], transform);
// Accumulate several model transformations: // Accumulate several model transformations:
@ -1587,7 +1587,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
} }
// Get a copy of current matrices to work with, // Get a copy of current matrices to work with,
// just in case stereo render is required and we need to modify them // just in case stereo render is required, and we need to modify them
// NOTE: At this point the modelview matrix just contains the view matrix (camera) // NOTE: At this point the modelview matrix just contains the view matrix (camera)
// That's because BeginMode3D() sets it and there is no model-drawing function // That's because BeginMode3D() sets it and there is no model-drawing function
// that modifies it, all use rlPushMatrix() and rlPopMatrix() // that modifies it, all use rlPushMatrix() and rlPopMatrix()
@ -1738,7 +1738,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i
else rlDrawVertexArrayInstanced(0, mesh.vertexCount, instances); else rlDrawVertexArrayInstanced(0, mesh.vertexCount, instances);
} }
// Unbind all binded texture maps // Unbind all bound texture maps
for (int i = 0; i < MAX_MATERIAL_MAPS; i++) for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
{ {
if (material.maps[i].texture.id > 0) if (material.maps[i].texture.id > 0)
@ -2045,7 +2045,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
int boneId = 0; int boneId = 0;
int boneCounter = 0; int boneCounter = 0;
float boneWeight = 0.0; float boneWeight = 0.0f;
const int vValues = mesh.vertexCount*3; const int vValues = mesh.vertexCount*3;
for (int vCounter = 0; vCounter < vValues; vCounter += 3) for (int vCounter = 0; vCounter < vValues; vCounter += 3)
@ -2559,7 +2559,7 @@ Mesh GenMeshSphere(float radius, int rings, int slices)
return mesh; return mesh;
} }
// Generate hemi-sphere mesh (half sphere, no bottom cap) // Generate hemisphere mesh (half sphere, no bottom cap)
Mesh GenMeshHemiSphere(float radius, int rings, int slices) Mesh GenMeshHemiSphere(float radius, int rings, int slices)
{ {
Mesh mesh = { 0 }; Mesh mesh = { 0 };
@ -3242,7 +3242,7 @@ Mesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize)
} }
} }
// Move data from mapVertices temp arays to vertices float array // Move data from mapVertices temp arrays to vertices float array
mesh.vertexCount = vCounter; mesh.vertexCount = vCounter;
mesh.triangleCount = vCounter/3; mesh.triangleCount = vCounter/3;
@ -3325,7 +3325,7 @@ BoundingBox GetMeshBoundingBox(Mesh mesh)
} }
// Compute mesh tangents // Compute mesh tangents
// NOTE: To calculate mesh tangents and binormals we need mesh vertex positions and texture coordinates // NOTE: To calculate mesh tangents and binomials we need mesh vertex positions and texture coordinates
// Implementation base don: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html // Implementation base don: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html
void GenMeshTangents(Mesh *mesh) void GenMeshTangents(Mesh *mesh)
{ {
@ -3727,8 +3727,8 @@ RayCollision GetRayCollisionBox(Ray ray, BoundingBox box)
t[3] = (box.max.y - ray.position.y)*t[9]; t[3] = (box.max.y - ray.position.y)*t[9];
t[4] = (box.min.z - ray.position.z)*t[10]; t[4] = (box.min.z - ray.position.z)*t[10];
t[5] = (box.max.z - ray.position.z)*t[10]; t[5] = (box.max.z - ray.position.z)*t[10];
t[6] = (float)fmax(fmax(fmin(t[0], t[1]), fmin(t[2], t[3])), fmin(t[4], t[5])); t[6] = fmax(fmax(fminf(t[0], t[1]), fminf(t[2], t[3])), fminf(t[4], t[5]));
t[7] = (float)fmin(fmin(fmax(t[0], t[1]), fmax(t[2], t[3])), fmax(t[4], t[5])); t[7] = fmin(fmin(fmaxf(t[0], t[1]), fmaxf(t[2], t[3])), fmaxf(t[4], t[5]));
collision.hit = !((t[7] < 0) || (t[6] > t[7])); collision.hit = !((t[7] < 0) || (t[6] > t[7]));
collision.distance = t[6]; collision.distance = t[6];
@ -3742,7 +3742,7 @@ RayCollision GetRayCollisionBox(Ray ray, BoundingBox box)
// NOTE: We use an additional .01 to fix numerical errors // NOTE: We use an additional .01 to fix numerical errors
collision.normal = Vector3Scale(collision.normal, 2.01f); collision.normal = Vector3Scale(collision.normal, 2.01f);
collision.normal = Vector3Divide(collision.normal, Vector3Subtract(box.max, box.min)); collision.normal = Vector3Divide(collision.normal, Vector3Subtract(box.max, box.min));
// The relevant elemets of the vector are now slightly larger than 1.0f (or smaller than -1.0f) // The relevant elements of the vector are now slightly larger than 1.0f (or smaller than -1.0f)
// and the others are somewhere between -1.0 and 1.0 casting to int is exactly our wanted normal! // and the others are somewhere between -1.0 and 1.0 casting to int is exactly our wanted normal!
collision.normal.x = (float)((int)collision.normal.x); collision.normal.x = (float)((int)collision.normal.x);
collision.normal.y = (float)((int)collision.normal.y); collision.normal.y = (float)((int)collision.normal.y);
@ -3842,7 +3842,7 @@ RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3
// Calculate u parameter and test bound // Calculate u parameter and test bound
u = Vector3DotProduct(tv, p)*invDet; u = Vector3DotProduct(tv, p)*invDet;
// The intersection lies outside of the triangle // The intersection lies outside the triangle
if ((u < 0.0f) || (u > 1.0f)) return collision; if ((u < 0.0f) || (u > 1.0f)) return collision;
// Prepare to test v parameter // Prepare to test v parameter
@ -3851,7 +3851,7 @@ RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3
// Calculate V parameter and test bound // Calculate V parameter and test bound
v = Vector3DotProduct(ray.direction, q)*invDet; v = Vector3DotProduct(ray.direction, q)*invDet;
// The intersection lies outside of the triangle // The intersection lies outside the triangle
if ((v < 0.0f) || ((u + v) > 1.0f)) return collision; if ((v < 0.0f) || ((u + v) > 1.0f)) return collision;
t = Vector3DotProduct(edge2, q)*invDet; t = Vector3DotProduct(edge2, q)*invDet;
@ -4287,10 +4287,10 @@ static Model LoadIQM(const char *fileName)
for (unsigned int m = 0; m < iqmHeader->num_meshes; m++) for (unsigned int m = 0; m < iqmHeader->num_meshes; m++)
{ {
int vCounter = 0; int vCounter = 0;
for (unsigned int i = imesh[m].first_vertex*3; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*3; i++) for (unsigned int j = imesh[m].first_vertex * 3; j < (imesh[m].first_vertex + imesh[m].num_vertexes) * 3; j++)
{ {
model.meshes[m].vertices[vCounter] = vertex[i]; model.meshes[m].vertices[vCounter] = vertex[j];
model.meshes[m].animVertices[vCounter] = vertex[i]; model.meshes[m].animVertices[vCounter] = vertex[j];
vCounter++; vCounter++;
} }
} }
@ -4305,10 +4305,10 @@ static Model LoadIQM(const char *fileName)
for (unsigned int m = 0; m < iqmHeader->num_meshes; m++) for (unsigned int m = 0; m < iqmHeader->num_meshes; m++)
{ {
int vCounter = 0; int vCounter = 0;
for (unsigned int i = imesh[m].first_vertex*3; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*3; i++) for (unsigned int j = imesh[m].first_vertex * 3; j < (imesh[m].first_vertex + imesh[m].num_vertexes) * 3; j++)
{ {
model.meshes[m].normals[vCounter] = normal[i]; model.meshes[m].normals[vCounter] = normal[j];
model.meshes[m].animNormals[vCounter] = normal[i]; model.meshes[m].animNormals[vCounter] = normal[j];
vCounter++; vCounter++;
} }
} }
@ -4323,9 +4323,9 @@ static Model LoadIQM(const char *fileName)
for (unsigned int m = 0; m < iqmHeader->num_meshes; m++) for (unsigned int m = 0; m < iqmHeader->num_meshes; m++)
{ {
int vCounter = 0; int vCounter = 0;
for (unsigned int i = imesh[m].first_vertex*2; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*2; i++) for (unsigned int j = imesh[m].first_vertex * 2; j < (imesh[m].first_vertex + imesh[m].num_vertexes) * 2; j++)
{ {
model.meshes[m].texcoords[vCounter] = text[i]; model.meshes[m].texcoords[vCounter] = text[j];
vCounter++; vCounter++;
} }
} }
@ -4340,9 +4340,9 @@ static Model LoadIQM(const char *fileName)
for (unsigned int m = 0; m < iqmHeader->num_meshes; m++) for (unsigned int m = 0; m < iqmHeader->num_meshes; m++)
{ {
int boneCounter = 0; int boneCounter = 0;
for (unsigned int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++) for (unsigned int j = imesh[m].first_vertex * 4; j < (imesh[m].first_vertex + imesh[m].num_vertexes) * 4; j++)
{ {
model.meshes[m].boneIds[boneCounter] = blendi[i]; model.meshes[m].boneIds[boneCounter] = blendi[j];
boneCounter++; boneCounter++;
} }
} }
@ -4357,9 +4357,9 @@ static Model LoadIQM(const char *fileName)
for (unsigned int m = 0; m < iqmHeader->num_meshes; m++) for (unsigned int m = 0; m < iqmHeader->num_meshes; m++)
{ {
int boneCounter = 0; int boneCounter = 0;
for (unsigned int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++) for (unsigned int j = imesh[m].first_vertex * 4; j < (imesh[m].first_vertex + imesh[m].num_vertexes) * 4; j++)
{ {
model.meshes[m].boneWeights[boneCounter] = blendw[i]/255.0f; model.meshes[m].boneWeights[boneCounter] = blendw[j] / 255.0f;
boneCounter++; boneCounter++;
} }
} }
@ -4376,9 +4376,9 @@ static Model LoadIQM(const char *fileName)
model.meshes[m].colors = RL_CALLOC(model.meshes[m].vertexCount*4, sizeof(unsigned char)); model.meshes[m].colors = RL_CALLOC(model.meshes[m].vertexCount*4, sizeof(unsigned char));
int vCounter = 0; int vCounter = 0;
for (unsigned int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++) for (unsigned int j = imesh[m].first_vertex * 4; j < (imesh[m].first_vertex + imesh[m].num_vertexes) * 4; j++)
{ {
model.meshes[m].colors[vCounter] = color[i]; model.meshes[m].colors[vCounter] = color[j];
vCounter++; vCounter++;
} }
} }
@ -4671,7 +4671,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat
{ {
Image image = { 0 }; Image image = { 0 };
if (cgltfImage->uri != NULL) // Check if image data is provided as a uri (base64 or path) if (cgltfImage->uri != NULL) // Check if image data is provided as an uri (base64 or path)
{ {
if ((strlen(cgltfImage->uri) > 5) && if ((strlen(cgltfImage->uri) > 5) &&
(cgltfImage->uri[0] == 'd') && (cgltfImage->uri[0] == 'd') &&
@ -5042,7 +5042,7 @@ static Model LoadGLTF(const char *fileName)
// Load data into a temp buffer to be converted to raylib data type // Load data into a temp buffer to be converted to raylib data type
unsigned short *temp = RL_MALLOC(attribute->count*4*sizeof(unsigned short)); unsigned short *temp = RL_MALLOC(attribute->count*4*sizeof(unsigned short));
LOAD_ATTRIBUTE(attribute, 4, unsigned short, temp); LOAD_ATTRIBUTE(attribute, 4, unsigned short, temp)
// Convert data to raylib color data type (4 bytes) // Convert data to raylib color data type (4 bytes)
for (unsigned int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(((float)temp[c]/65535.0f)*255.0f); for (unsigned int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(((float)temp[c]/65535.0f)*255.0f);
@ -5056,7 +5056,7 @@ static Model LoadGLTF(const char *fileName)
// Load data into a temp buffer to be converted to raylib data type // Load data into a temp buffer to be converted to raylib data type
float *temp = RL_MALLOC(attribute->count*4*sizeof(float)); float *temp = RL_MALLOC(attribute->count*4*sizeof(float));
LOAD_ATTRIBUTE(attribute, 4, float, temp); LOAD_ATTRIBUTE(attribute, 4, float, temp)
// Convert data to raylib color data type (4 bytes), we expect the color data normalized // Convert data to raylib color data type (4 bytes), we expect the color data normalized
for (unsigned int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(temp[c]*255.0f); for (unsigned int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(temp[c]*255.0f);
@ -5091,7 +5091,7 @@ static Model LoadGLTF(const char *fileName)
// Load data into a temp buffer to be converted to raylib data type // Load data into a temp buffer to be converted to raylib data type
unsigned int *temp = RL_MALLOC(attribute->count*sizeof(unsigned int)); unsigned int *temp = RL_MALLOC(attribute->count*sizeof(unsigned int));
LOAD_ATTRIBUTE(attribute, 1, unsigned int, temp); LOAD_ATTRIBUTE(attribute, 1, unsigned int, temp)
// Convert data to raylib indices data type (unsigned short) // Convert data to raylib indices data type (unsigned short)
for (unsigned int d = 0; d < attribute->count; d++) model.meshes[meshIndex].indices[d] = (unsigned short)temp[d]; for (unsigned int d = 0; d < attribute->count; d++) model.meshes[meshIndex].indices[d] = (unsigned short)temp[d];
@ -5110,7 +5110,7 @@ static Model LoadGLTF(const char *fileName)
{ {
// The primitive actually keeps the pointer to the corresponding material, // The primitive actually keeps the pointer to the corresponding material,
// raylib instead assigns to the mesh the by its index, as loaded in model.materials array // raylib instead assigns to the mesh the by its index, as loaded in model.materials array
// To get the index, we check if material pointers match and we assign the corresponding index, // To get the index, we check if material pointers match, and we assign the corresponding index,
// skipping index 0, the default material // skipping index 0, the default material
if (&data->materials[m] == data->meshes[i].primitives[p].material) if (&data->materials[m] == data->meshes[i].primitives[p].material)
{ {
@ -5613,7 +5613,7 @@ static Model LoadM3D(const char *fileName)
// Materials are grouped together // Materials are grouped together
if (mi != m3d->face[i].materialid) if (mi != m3d->face[i].materialid)
{ {
// there should be only one material switch per material kind, but be bulletproof for unoptimal model files // there should be only one material switch per material kind, but be bulletproof for non-optimal model files
if (k + 1 >= model.meshCount) if (k + 1 >= model.meshCount)
{ {
model.meshCount++; model.meshCount++;
@ -5842,7 +5842,7 @@ static Model LoadM3D(const char *fileName)
} }
// Load bone-pose default mesh into animation vertices. These will be updated when UpdateModelAnimation gets // Load bone-pose default mesh into animation vertices. These will be updated when UpdateModelAnimation gets
// called, but not before, however DrawMesh uses these if they exists (so not good if they are left empty). // called, but not before, however DrawMesh uses these if they exist (so not good if they are left empty).
if (m3d->numbone && m3d->numskin) if (m3d->numbone && m3d->numskin)
{ {
for(i = 0; i < model.meshCount; i++) for(i = 0; i < model.meshCount; i++)

View File

@ -230,7 +230,7 @@ void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color)
DrawTriangleStrip(points, 2*BEZIER_LINE_DIVISIONS+2, color); DrawTriangleStrip(points, 2*BEZIER_LINE_DIVISIONS+2, color);
} }
// Draw line using quadratic bezier curves with a control point // Draw line using quadratic zier curves with a control point
void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color) void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color)
{ {
const float step = 1.0f/BEZIER_LINE_DIVISIONS; const float step = 1.0f/BEZIER_LINE_DIVISIONS;
@ -275,7 +275,7 @@ void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, fl
DrawTriangleStrip(points, 2*BEZIER_LINE_DIVISIONS+2, color); DrawTriangleStrip(points, 2*BEZIER_LINE_DIVISIONS+2, color);
} }
// Draw line using cubic bezier curves with 2 control points // Draw line using cubic zier curves with 2 control points
void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color) void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color)
{ {
const float step = 1.0f/BEZIER_LINE_DIVISIONS; const float step = 1.0f/BEZIER_LINE_DIVISIONS;
@ -978,7 +978,7 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
// Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner // Draw all the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
{ {
float angle = angles[k]; float angle = angles[k];
@ -1207,7 +1207,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner // Draw all the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
{ {
float angle = angles[k]; float angle = angles[k];
@ -1342,7 +1342,7 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
// Use LINES to draw the outline // Use LINES to draw the outline
rlBegin(RL_LINES); rlBegin(RL_LINES);
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner // Draw all the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop for (int k = 0; k < 4; ++k) // Hope the compiler is smart enough to unroll this loop
{ {
float angle = angles[k]; float angle = angles[k];

View File

@ -65,7 +65,7 @@
#include <stdio.h> // Required for: vsprintf() #include <stdio.h> // Required for: vsprintf()
#include <string.h> // Required for: strcmp(), strstr(), strcpy(), strncpy() [Used in TextReplace()], sscanf() [Used in LoadBMFont()] #include <string.h> // Required for: strcmp(), strstr(), strcpy(), strncpy() [Used in TextReplace()], sscanf() [Used in LoadBMFont()]
#include <stdarg.h> // Required for: va_list, va_start(), vsprintf(), va_end() [Used in TextFormat()] #include <stdarg.h> // Required for: va_list, va_start(), vsprintf(), va_end() [Used in TextFormat()]
#include <ctype.h> // Requried for: toupper(), tolower() [Used in TextToUpper(), TextToLower()] #include <ctype.h> // Required for: toupper(), tolower() [Used in TextToUpper(), TextToLower()]
#if defined(SUPPORT_FILEFORMAT_TTF) #if defined(SUPPORT_FILEFORMAT_TTF)
#define STB_RECT_PACK_IMPLEMENTATION #define STB_RECT_PACK_IMPLEMENTATION
@ -336,7 +336,7 @@ Font LoadFont(const char *fileName)
} }
else else
{ {
SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default we set point filter (best performance) SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default, we set point filter (the best performance)
TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", FONT_TTF_DEFAULT_SIZE, FONT_TTF_DEFAULT_NUMCHARS); TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", FONT_TTF_DEFAULT_SIZE, FONT_TTF_DEFAULT_NUMCHARS);
} }
@ -584,7 +584,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
glyphCount = (glyphCount > 0)? glyphCount : 95; glyphCount = (glyphCount > 0)? glyphCount : 95;
// Fill fontChars in case not provided externally // Fill fontChars in case not provided externally
// NOTE: By default we fill glyphCount consecutevely, starting at 32 (Space) // NOTE: By default we fill glyphCount consecutively, starting at 32 (Space)
if (fontChars == NULL) if (fontChars == NULL)
{ {
@ -777,7 +777,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
for (int i = 0; i < glyphCount; i++) for (int i = 0; i < glyphCount; i++)
{ {
// It return char rectangles in atlas // It returns char rectangles in atlas
recs[i].x = rects[i].x + (float)padding; recs[i].x = rects[i].x + (float)padding;
recs[i].y = rects[i].y + (float)padding; recs[i].y = rects[i].y + (float)padding;
recs[i].width = (float)chars[i].image.width; recs[i].width = (float)chars[i].image.width;
@ -855,7 +855,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
#define TEXT_BYTES_PER_LINE 20 #define TEXT_BYTES_PER_LINE 20
#endif #endif
#define MAX_FONT_DATA_SIZE 1024*1024 // 1 MB #define MAX_FONT_DATA_SIZE (1024*1024) // 1 MB
// Get file name from path // Get file name from path
char fileNamePascal[256] = { 0 }; char fileNamePascal[256] = { 0 };
@ -1053,7 +1053,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
int index = GetGlyphIndex(font, codepoint); int index = GetGlyphIndex(font, codepoint);
// NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f) // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
// but we need to draw all of the bad bytes using the '?' symbol moving one byte // but we need to draw all the bad bytes using the '?' symbol moving one byte
if (codepoint == 0x3f) codepointByteCount = 1; if (codepoint == 0x3f) codepointByteCount = 1;
if (codepoint == '\n') if (codepoint == '\n')
@ -1195,7 +1195,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
index = GetGlyphIndex(font, letter); index = GetGlyphIndex(font, letter);
// NOTE: normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f) // NOTE: normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
// but we need to draw all of the bad bytes using the '?' symbol so to not skip any we set next = 1 // but we need to draw all the bad bytes using the '?' symbol so to not skip any we set next = 1
if (letter == 0x3f) next = 1; if (letter == 0x3f) next = 1;
i += next - 1; i += next - 1;
@ -1410,7 +1410,7 @@ char *TextReplace(char *text, const char *replace, const char *by)
char *insertPoint = NULL; // Next insert point char *insertPoint = NULL; // Next insert point
char *temp = NULL; // Temp pointer char *temp = NULL; // Temp pointer
int replaceLen = 0; // Replace string length of (the string to remove) int replaceLen = 0; // Replace string length of (the string to remove)
int byLen = 0; // Replacement length (the string to replace replace by) int byLen = 0; // Replacement length (the string to replace by)
int lastReplacePos = 0; // Distance between replace and end of last replace int lastReplacePos = 0; // Distance between replace and end of last replace
int count = 0; // Number of replacements int count = 0; // Number of replacements
@ -1756,7 +1756,7 @@ const char *CodepointToUTF8(int codepoint, int *utf8Size)
#endif // SUPPORT_TEXT_MANIPULATION #endif // SUPPORT_TEXT_MANIPULATION
// Get next codepoint in a UTF-8 encoded text, scanning until '\0' is found // Get next codepoint in a UTF-8 encoded text, scanning until '\0' is found
// When a invalid UTF-8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned // When an invalid UTF-8 byte is encountered we exit as soon as possible and a '?'(0x3f) codepoint is returned
// Total number of bytes processed are returned as a parameter // Total number of bytes processed are returned as a parameter
// NOTE: The standard says U+FFFD should be returned in case of errors // NOTE: The standard says U+FFFD should be returned in case of errors
// but that character is not supported by the default font in raylib // but that character is not supported by the default font in raylib

View File

@ -750,8 +750,8 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner,
float dist = hypotf((float)x - centerX, (float)y - centerY); float dist = hypotf((float)x - centerX, (float)y - centerY);
float factor = (dist - radius*density)/(radius*(1.0f - density)); float factor = (dist - radius*density)/(radius*(1.0f - density));
factor = (float)fmax(factor, 0.0f); factor = fmaxf(factor, 0.0f);
factor = (float)fmin(factor, 1.f); // dist can be bigger than radius so we have to check factor = fminf(factor, 1.f); // dist can be bigger than radius, so we have to check
pixels[y*width + x].r = (int)((float)outer.r*factor + (float)inner.r*(1.0f - factor)); pixels[y*width + x].r = (int)((float)outer.r*factor + (float)inner.r*(1.0f - factor));
pixels[y*width + x].g = (int)((float)outer.g*factor + (float)inner.g*(1.0f - factor)); pixels[y*width + x].g = (int)((float)outer.g*factor + (float)inner.g*(1.0f - factor));
@ -893,12 +893,12 @@ Image GenImageCellular(int width, int height, int tileSize)
Vector2 neighborSeed = seeds[(tileY + j)*seedsPerRow + tileX + i]; Vector2 neighborSeed = seeds[(tileY + j)*seedsPerRow + tileX + i];
float dist = (float)hypot(x - (int)neighborSeed.x, y - (int)neighborSeed.y); float dist = hypotf(x - (int)neighborSeed.x, y - (int)neighborSeed.y);
minDistance = (float)fmin(minDistance, dist); minDistance = fminf(minDistance, dist);
} }
} }
// I made this up but it seems to give good results at all tile sizes // I made this up, but it seems to give good results at all tile sizes
int intensity = (int)(minDistance*256.0f/tileSize); int intensity = (int)(minDistance*256.0f/tileSize);
if (intensity > 255) intensity = 255; if (intensity > 255) intensity = 255;
@ -1103,9 +1103,9 @@ void ImageFormat(Image *image, int newFormat)
for (int i = 0; i < image->width*image->height; i++) for (int i = 0; i < image->width*image->height; i++)
{ {
r = (unsigned char)(round(pixels[i].x*31.0f)); r = (unsigned char)(roundf(pixels[i].x*31.0f));
g = (unsigned char)(round(pixels[i].y*63.0f)); g = (unsigned char)(roundf(pixels[i].y*63.0f));
b = (unsigned char)(round(pixels[i].z*31.0f)); b = (unsigned char)(roundf(pixels[i].z*31.0f));
((unsigned short *)image->data)[i] = (unsigned short)r << 11 | (unsigned short)g << 5 | (unsigned short)b; ((unsigned short *)image->data)[i] = (unsigned short)r << 11 | (unsigned short)g << 5 | (unsigned short)b;
} }
@ -1115,11 +1115,11 @@ void ImageFormat(Image *image, int newFormat)
{ {
image->data = (unsigned char *)RL_MALLOC(image->width*image->height*3*sizeof(unsigned char)); image->data = (unsigned char *)RL_MALLOC(image->width*image->height*3*sizeof(unsigned char));
for (int i = 0, k = 0; i < image->width*image->height*3; i += 3, k++) for (int i = 0, j = 0; i < image->width * image->height * 3; i += 3, j++)
{ {
((unsigned char *)image->data)[i] = (unsigned char)(pixels[k].x*255.0f); ((unsigned char *)image->data)[i] = (unsigned char)(pixels[j].x * 255.0f);
((unsigned char *)image->data)[i + 1] = (unsigned char)(pixels[k].y*255.0f); ((unsigned char *)image->data)[i + 1] = (unsigned char)(pixels[j].y * 255.0f);
((unsigned char *)image->data)[i + 2] = (unsigned char)(pixels[k].z*255.0f); ((unsigned char *)image->data)[i + 2] = (unsigned char)(pixels[j].z * 255.0f);
} }
} break; } break;
case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1:
@ -1133,9 +1133,9 @@ void ImageFormat(Image *image, int newFormat)
for (int i = 0; i < image->width*image->height; i++) for (int i = 0; i < image->width*image->height; i++)
{ {
r = (unsigned char)(round(pixels[i].x*31.0f)); r = (unsigned char)(roundf(pixels[i].x*31.0f));
g = (unsigned char)(round(pixels[i].y*31.0f)); g = (unsigned char)(roundf(pixels[i].y*31.0f));
b = (unsigned char)(round(pixels[i].z*31.0f)); b = (unsigned char)(roundf(pixels[i].z*31.0f));
a = (pixels[i].w > ((float)PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD/255.0f))? 1 : 0; a = (pixels[i].w > ((float)PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD/255.0f))? 1 : 0;
((unsigned short *)image->data)[i] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a; ((unsigned short *)image->data)[i] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a;
@ -1153,10 +1153,10 @@ void ImageFormat(Image *image, int newFormat)
for (int i = 0; i < image->width*image->height; i++) for (int i = 0; i < image->width*image->height; i++)
{ {
r = (unsigned char)(round(pixels[i].x*15.0f)); r = (unsigned char)(roundf(pixels[i].x*15.0f));
g = (unsigned char)(round(pixels[i].y*15.0f)); g = (unsigned char)(roundf(pixels[i].y*15.0f));
b = (unsigned char)(round(pixels[i].z*15.0f)); b = (unsigned char)(roundf(pixels[i].z*15.0f));
a = (unsigned char)(round(pixels[i].w*15.0f)); a = (unsigned char)(roundf(pixels[i].w*15.0f));
((unsigned short *)image->data)[i] = (unsigned short)r << 12 | (unsigned short)g << 8 | (unsigned short)b << 4 | (unsigned short)a; ((unsigned short *)image->data)[i] = (unsigned short)r << 12 | (unsigned short)g << 8 | (unsigned short)b << 4 | (unsigned short)a;
} }
@ -1166,17 +1166,17 @@ void ImageFormat(Image *image, int newFormat)
{ {
image->data = (unsigned char *)RL_MALLOC(image->width*image->height*4*sizeof(unsigned char)); image->data = (unsigned char *)RL_MALLOC(image->width*image->height*4*sizeof(unsigned char));
for (int i = 0, k = 0; i < image->width*image->height*4; i += 4, k++) for (int i = 0, j = 0; i < image->width * image->height * 4; i += 4, j++)
{ {
((unsigned char *)image->data)[i] = (unsigned char)(pixels[k].x*255.0f); ((unsigned char *)image->data)[i] = (unsigned char)(pixels[j].x * 255.0f);
((unsigned char *)image->data)[i + 1] = (unsigned char)(pixels[k].y*255.0f); ((unsigned char *)image->data)[i + 1] = (unsigned char)(pixels[j].y * 255.0f);
((unsigned char *)image->data)[i + 2] = (unsigned char)(pixels[k].z*255.0f); ((unsigned char *)image->data)[i + 2] = (unsigned char)(pixels[j].z * 255.0f);
((unsigned char *)image->data)[i + 3] = (unsigned char)(pixels[k].w*255.0f); ((unsigned char *)image->data)[i + 3] = (unsigned char)(pixels[j].w * 255.0f);
} }
} break; } break;
case PIXELFORMAT_UNCOMPRESSED_R32: case PIXELFORMAT_UNCOMPRESSED_R32:
{ {
// WARNING: Image is converted to GRAYSCALE eqeuivalent 32bit // WARNING: Image is converted to GRAYSCALE equivalent 32bit
image->data = (float *)RL_MALLOC(image->width*image->height*sizeof(float)); image->data = (float *)RL_MALLOC(image->width*image->height*sizeof(float));
@ -1189,23 +1189,23 @@ void ImageFormat(Image *image, int newFormat)
{ {
image->data = (float *)RL_MALLOC(image->width*image->height*3*sizeof(float)); image->data = (float *)RL_MALLOC(image->width*image->height*3*sizeof(float));
for (int i = 0, k = 0; i < image->width*image->height*3; i += 3, k++) for (int i = 0, j = 0; i < image->width * image->height * 3; i += 3, j++)
{ {
((float *)image->data)[i] = pixels[k].x; ((float *)image->data)[i] = pixels[j].x;
((float *)image->data)[i + 1] = pixels[k].y; ((float *)image->data)[i + 1] = pixels[j].y;
((float *)image->data)[i + 2] = pixels[k].z; ((float *)image->data)[i + 2] = pixels[j].z;
} }
} break; } break;
case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32:
{ {
image->data = (float *)RL_MALLOC(image->width*image->height*4*sizeof(float)); image->data = (float *)RL_MALLOC(image->width*image->height*4*sizeof(float));
for (int i = 0, k = 0; i < image->width*image->height*4; i += 4, k++) for (int i = 0, j = 0; i < image->width * image->height * 4; i += 4, j++)
{ {
((float *)image->data)[i] = pixels[k].x; ((float *)image->data)[i] = pixels[j].x;
((float *)image->data)[i + 1] = pixels[k].y; ((float *)image->data)[i + 1] = pixels[j].y;
((float *)image->data)[i + 2] = pixels[k].z; ((float *)image->data)[i + 2] = pixels[j].z;
((float *)image->data)[i + 3] = pixels[k].w; ((float *)image->data)[i + 3] = pixels[j].w;
} }
} break; } break;
default: break; default: break;
@ -1214,7 +1214,7 @@ void ImageFormat(Image *image, int newFormat)
RL_FREE(pixels); RL_FREE(pixels);
pixels = NULL; pixels = NULL;
// In case original image had mipmaps, generate mipmaps for formated image // In case original image had mipmaps, generate mipmaps for formatted image
// NOTE: Original mipmaps are replaced by new ones, if custom mipmaps were used, they are lost // NOTE: Original mipmaps are replaced by new ones, if custom mipmaps were used, they are lost
if (image->mipmaps > 1) if (image->mipmaps > 1)
{ {
@ -1286,7 +1286,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
int index = GetGlyphIndex(font, codepoint); // WARNING: Module required: rtext int index = GetGlyphIndex(font, codepoint); // WARNING: Module required: rtext
// NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f) // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
// but we need to draw all of the bad bytes using the '?' symbol moving one byte // but we need to draw all the bad bytes using the '?' symbol moving one byte
if (codepoint == 0x3f) codepointByteCount = 1; if (codepoint == 0x3f) codepointByteCount = 1;
if (codepoint == '\n') if (codepoint == '\n')
@ -1331,7 +1331,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
} }
// Crop image depending on alpha value // Crop image depending on alpha value
// NOTE: Threshold is defined as a percentatge: 0.0f -> 1.0f // NOTE: Threshold is defined as a percentage: 0.0f -> 1.0f
void ImageAlphaCrop(Image *image, float threshold) void ImageAlphaCrop(Image *image, float threshold)
{ {
// Security check to avoid program crash // Security check to avoid program crash
@ -1372,9 +1372,9 @@ void ImageAlphaClear(Image *image, Color color, float threshold)
{ {
unsigned char thresholdValue = ((threshold < 0.5f)? 0 : 1); unsigned char thresholdValue = ((threshold < 0.5f)? 0 : 1);
unsigned char r = (unsigned char)(round((float)color.r*31.0f)); unsigned char r = (unsigned char)(roundf((float)color.r*31.0f));
unsigned char g = (unsigned char)(round((float)color.g*31.0f)); unsigned char g = (unsigned char)(roundf((float)color.g*31.0f));
unsigned char b = (unsigned char)(round((float)color.b*31.0f)); unsigned char b = (unsigned char)(roundf((float)color.b*31.0f));
unsigned char a = (color.a < 128)? 0 : 1; unsigned char a = (color.a < 128)? 0 : 1;
for (int i = 0; i < image->width*image->height; i++) for (int i = 0; i < image->width*image->height; i++)
@ -1389,10 +1389,10 @@ void ImageAlphaClear(Image *image, Color color, float threshold)
{ {
unsigned char thresholdValue = (unsigned char)(threshold*15.0f); unsigned char thresholdValue = (unsigned char)(threshold*15.0f);
unsigned char r = (unsigned char)(round((float)color.r*15.0f)); unsigned char r = (unsigned char)(roundf((float)color.r*15.0f));
unsigned char g = (unsigned char)(round((float)color.g*15.0f)); unsigned char g = (unsigned char)(roundf((float)color.g*15.0f));
unsigned char b = (unsigned char)(round((float)color.b*15.0f)); unsigned char b = (unsigned char)(roundf((float)color.b*15.0f));
unsigned char a = (unsigned char)(round((float)color.a*15.0f)); unsigned char a = (unsigned char)(roundf((float)color.a*15.0f));
for (int i = 0; i < image->width*image->height; i++) for (int i = 0; i < image->width*image->height; i++)
{ {
@ -1711,7 +1711,7 @@ void ImageResize(Image *image, int newWidth, int newHeight)
Color *pixels = LoadImageColors(*image); Color *pixels = LoadImageColors(*image);
Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color)); Color *output = (Color *)RL_MALLOC(newWidth*newHeight*sizeof(Color));
// NOTE: Color data is casted to (unsigned char *), there shouldn't been any problem... // NOTE: Color data is cast to (unsigned char *), there shouldn't been any problem...
stbir_resize_uint8((unsigned char *)pixels, image->width, image->height, 0, (unsigned char *)output, newWidth, newHeight, 0, 4); stbir_resize_uint8((unsigned char *)pixels, image->width, image->height, 0, (unsigned char *)output, newWidth, newHeight, 0, 4);
int format = image->format; int format = image->format;
@ -1891,7 +1891,7 @@ void ImageMipmaps(Image *image)
} }
// Dither image data to 16bpp or lower (Floyd-Steinberg dithering) // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
// NOTE: In case selected bpp do not represent an known 16bit format, // NOTE: In case selected bpp do not represent a known 16bit format,
// dithered data is stored in the LSB part of the unsigned short // dithered data is stored in the LSB part of the unsigned short
void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp) void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
{ {
@ -2531,7 +2531,7 @@ void UnloadImagePalette(Color *colors)
} }
// Get image alpha border rectangle // Get image alpha border rectangle
// NOTE: Threshold is defined as a percentatge: 0.0f -> 1.0f // NOTE: Threshold is defined as a percentage: 0.0f -> 1.0f
Rectangle GetImageAlphaBorder(Image image, float threshold) Rectangle GetImageAlphaBorder(Image image, float threshold)
{ {
Rectangle crop = { 0 }; Rectangle crop = { 0 };
@ -2729,9 +2729,9 @@ void ImageDrawPixel(Image *dst, int x, int y, Color color)
// NOTE: Calculate R5G6B5 equivalent color // NOTE: Calculate R5G6B5 equivalent color
Vector3 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f }; Vector3 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f };
unsigned char r = (unsigned char)(round(coln.x*31.0f)); unsigned char r = (unsigned char)(roundf(coln.x*31.0f));
unsigned char g = (unsigned char)(round(coln.y*63.0f)); unsigned char g = (unsigned char)(roundf(coln.y*63.0f));
unsigned char b = (unsigned char)(round(coln.z*31.0f)); unsigned char b = (unsigned char)(roundf(coln.z*31.0f));
((unsigned short *)dst->data)[y*dst->width + x] = (unsigned short)r << 11 | (unsigned short)g << 5 | (unsigned short)b; ((unsigned short *)dst->data)[y*dst->width + x] = (unsigned short)r << 11 | (unsigned short)g << 5 | (unsigned short)b;
@ -2741,9 +2741,9 @@ void ImageDrawPixel(Image *dst, int x, int y, Color color)
// NOTE: Calculate R5G5B5A1 equivalent color // NOTE: Calculate R5G5B5A1 equivalent color
Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f }; Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f };
unsigned char r = (unsigned char)(round(coln.x*31.0f)); unsigned char r = (unsigned char)(roundf(coln.x*31.0f));
unsigned char g = (unsigned char)(round(coln.y*31.0f)); unsigned char g = (unsigned char)(roundf(coln.y*31.0f));
unsigned char b = (unsigned char)(round(coln.z*31.0f)); unsigned char b = (unsigned char)(roundf(coln.z*31.0f));
unsigned char a = (coln.w > ((float)PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD/255.0f))? 1 : 0; unsigned char a = (coln.w > ((float)PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD/255.0f))? 1 : 0;
((unsigned short *)dst->data)[y*dst->width + x] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a; ((unsigned short *)dst->data)[y*dst->width + x] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a;
@ -2754,10 +2754,10 @@ void ImageDrawPixel(Image *dst, int x, int y, Color color)
// NOTE: Calculate R5G5B5A1 equivalent color // NOTE: Calculate R5G5B5A1 equivalent color
Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f }; Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f };
unsigned char r = (unsigned char)(round(coln.x*15.0f)); unsigned char r = (unsigned char)(roundf(coln.x*15.0f));
unsigned char g = (unsigned char)(round(coln.y*15.0f)); unsigned char g = (unsigned char)(roundf(coln.y*15.0f));
unsigned char b = (unsigned char)(round(coln.z*15.0f)); unsigned char b = (unsigned char)(roundf(coln.z*15.0f));
unsigned char a = (unsigned char)(round(coln.w*15.0f)); unsigned char a = (unsigned char)(roundf(coln.w*15.0f));
((unsigned short *)dst->data)[y*dst->width + x] = (unsigned short)r << 12 | (unsigned short)g << 8 | (unsigned short)b << 4 | (unsigned short)a; ((unsigned short *)dst->data)[y*dst->width + x] = (unsigned short)r << 12 | (unsigned short)g << 8 | (unsigned short)b << 4 | (unsigned short)a;
@ -3049,7 +3049,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
if ((srcRec.y + srcRec.height) > src.height) srcRec.height = src.height - srcRec.y; if ((srcRec.y + srcRec.height) > src.height) srcRec.height = src.height - srcRec.y;
// Check if source rectangle needs to be resized to destination rectangle // Check if source rectangle needs to be resized to destination rectangle
// In that case, we make a copy of source and we apply all required transform // In that case, we make a copy of source, and we apply all required transform
if (((int)srcRec.width != (int)dstRec.width) || ((int)srcRec.height != (int)dstRec.height)) if (((int)srcRec.width != (int)dstRec.width) || ((int)srcRec.height != (int)dstRec.height))
{ {
srcMod = ImageFromImage(src, srcRec); // Create image from another image srcMod = ImageFromImage(src, srcRec); // Create image from another image
@ -3080,7 +3080,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
if (dst->width < srcRec.width) srcRec.width = (float)dst->width; if (dst->width < srcRec.width) srcRec.width = (float)dst->width;
if (dst->height < srcRec.height) srcRec.height = (float)dst->height; if (dst->height < srcRec.height) srcRec.height = (float)dst->height;
// This blitting method is quite fast! The process followed is: // This blotting method is quite fast! The process followed is:
// for every pixel -> [get_src_format/get_dst_format -> blend -> format_to_dst] // for every pixel -> [get_src_format/get_dst_format -> blend -> format_to_dst]
// Some optimization ideas: // Some optimization ideas:
// [x] Avoid creating source copy if not required (no resize required) // [x] Avoid creating source copy if not required (no resize required)
@ -3273,7 +3273,7 @@ TextureCubemap LoadTextureCubemap(Image image, int layout)
faces = GenImageColor(size, size*6, MAGENTA); faces = GenImageColor(size, size*6, MAGENTA);
ImageFormat(&faces, image.format); ImageFormat(&faces, image.format);
// NOTE: Image formating does not work with compressed textures // NOTE: Image formatting does not work with compressed textures
for (int i = 0; i < 6; i++) ImageDraw(&faces, image, faceRecs[i], (Rectangle){ 0, (float)size*i, (float)size, (float)size }, WHITE); for (int i = 0; i < 6; i++) ImageDraw(&faces, image, faceRecs[i], (Rectangle){ 0, (float)size*i, (float)size, (float)size }, WHITE);
} }
@ -3606,7 +3606,7 @@ void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2
// NOTE: Vertex position can be transformed using matrices // NOTE: Vertex position can be transformed using matrices
// but the process is way more costly than just calculating // but the process is way more costly than just calculating
// the vertex positions manually, like done above. // the vertex positions manually, like done above.
// I leave here the old implementation for educational pourposes, // I leave here the old implementation for educational purposes,
// just in case someone wants to do some performance test // just in case someone wants to do some performance test
/* /*
rlSetTexture(texture.id); rlSetTexture(texture.id);
@ -4244,9 +4244,9 @@ void SetPixelColor(void *dstPtr, Color color, int format)
// NOTE: Calculate R5G6B5 equivalent color // NOTE: Calculate R5G6B5 equivalent color
Vector3 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f }; Vector3 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f };
unsigned char r = (unsigned char)(round(coln.x*31.0f)); unsigned char r = (unsigned char)(roundf(coln.x*31.0f));
unsigned char g = (unsigned char)(round(coln.y*63.0f)); unsigned char g = (unsigned char)(roundf(coln.y*63.0f));
unsigned char b = (unsigned char)(round(coln.z*31.0f)); unsigned char b = (unsigned char)(roundf(coln.z*31.0f));
((unsigned short *)dstPtr)[0] = (unsigned short)r << 11 | (unsigned short)g << 5 | (unsigned short)b; ((unsigned short *)dstPtr)[0] = (unsigned short)r << 11 | (unsigned short)g << 5 | (unsigned short)b;
@ -4256,9 +4256,9 @@ void SetPixelColor(void *dstPtr, Color color, int format)
// NOTE: Calculate R5G5B5A1 equivalent color // NOTE: Calculate R5G5B5A1 equivalent color
Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f }; Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f };
unsigned char r = (unsigned char)(round(coln.x*31.0f)); unsigned char r = (unsigned char)(roundf(coln.x*31.0f));
unsigned char g = (unsigned char)(round(coln.y*31.0f)); unsigned char g = (unsigned char)(roundf(coln.y*31.0f));
unsigned char b = (unsigned char)(round(coln.z*31.0f)); unsigned char b = (unsigned char)(roundf(coln.z*31.0f));
unsigned char a = (coln.w > ((float)PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD/255.0f))? 1 : 0; unsigned char a = (coln.w > ((float)PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD/255.0f))? 1 : 0;
((unsigned short *)dstPtr)[0] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a; ((unsigned short *)dstPtr)[0] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a;
@ -4269,10 +4269,10 @@ void SetPixelColor(void *dstPtr, Color color, int format)
// NOTE: Calculate R5G5B5A1 equivalent color // NOTE: Calculate R5G5B5A1 equivalent color
Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f }; Vector4 coln = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f, (float)color.a/255.0f };
unsigned char r = (unsigned char)(round(coln.x*15.0f)); unsigned char r = (unsigned char)(roundf(coln.x*15.0f));
unsigned char g = (unsigned char)(round(coln.y*15.0f)); unsigned char g = (unsigned char)(roundf(coln.y*15.0f));
unsigned char b = (unsigned char)(round(coln.z*15.0f)); unsigned char b = (unsigned char)(roundf(coln.z*15.0f));
unsigned char a = (unsigned char)(round(coln.w*15.0f)); unsigned char a = (unsigned char)(roundf(coln.w*15.0f));
((unsigned short *)dstPtr)[0] = (unsigned short)r << 12 | (unsigned short)g << 8 | (unsigned short)b << 4 | (unsigned short)a; ((unsigned short *)dstPtr)[0] = (unsigned short)r << 12 | (unsigned short)g << 8 | (unsigned short)b << 4 | (unsigned short)a;

View File

@ -63,10 +63,10 @@
static int logTypeLevel = LOG_INFO; // Minimum log type level static int logTypeLevel = LOG_INFO; // Minimum log type level
static TraceLogCallback traceLog = NULL; // TraceLog callback function pointer static TraceLogCallback traceLog = NULL; // TraceLog callback function pointer
static LoadFileDataCallback loadFileData = NULL; // LoadFileData callback funtion pointer static LoadFileDataCallback loadFileData = NULL; // LoadFileData callback function pointer
static SaveFileDataCallback saveFileData = NULL; // SaveFileText callback funtion pointer static SaveFileDataCallback saveFileData = NULL; // SaveFileText callback function pointer
static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback funtion pointer static LoadFileTextCallback loadFileText = NULL; // LoadFileText callback function pointer
static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback funtion pointer static SaveFileTextCallback saveFileText = NULL; // SaveFileText callback function pointer
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Functions to set internal callbacks // Functions to set internal callbacks
@ -166,7 +166,7 @@ void *MemAlloc(unsigned int size)
return ptr; return ptr;
} }
// Internal memory reallocator // Internal memory re-allocator
void *MemRealloc(void *ptr, unsigned int size) void *MemRealloc(void *ptr, unsigned int size)
{ {
void *ret = RL_REALLOC(ptr, size); void *ret = RL_REALLOC(ptr, size);