summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG2
-rw-r--r--README.md5
-rw-r--r--ROADMAP.md2
-rw-r--r--examples/audio_module_playing.c2
-rw-r--r--examples/physics_demo.c2
-rw-r--r--examples/physics_friction.c2
-rw-r--r--examples/physics_movement.c2
-rw-r--r--examples/physics_restitution.c2
-rw-r--r--examples/physics_shatter.c2
-rw-r--r--project/vs2015/raylib/ReadMe.txt29
-rw-r--r--src/audio.c16
-rw-r--r--src/camera.h70
-rw-r--r--src/core.c4
-rw-r--r--src/gestures.h12
-rw-r--r--src/models.c6
-rw-r--r--src/raylib.h2
-rw-r--r--src/raymath.h16
-rw-r--r--src/rlgl.c14
-rw-r--r--src/shapes.c15
-rw-r--r--src/text.c33
-rw-r--r--src/textures.c25
21 files changed, 123 insertions, 140 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 8b51d799..71f3d071 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,7 +11,7 @@ NOTE:
It includes some interesting new features and is a stepping stone towards raylib future.
HUGE changes:
-[rlua] LUA BINDING: Complete raylib LUA binding, ALL raylib functions ported to LUA plus the +60 code examples.
+[rlua] Lua BINDING: Complete raylib Lua binding, ALL raylib functions ported to Lua plus the +60 code examples.
[audio] COMPLETE REDESIGN: Improved music support and also raw audio data processing and playing, +20 new functions added.
[physac] COMPLETE REWRITE: Improved performance, functionality and simplified usage, moved to own repository and added multiple examples!
diff --git a/README.md b/README.md
index 6d032350..78c74a91 100644
--- a/README.md
+++ b/README.md
@@ -158,7 +158,7 @@ notes on raylib 1.6
On November 2016, only 4 months after raylib 1.5, arrives raylib 1.6. This new version represents another big review of the library and includes some interesting additions. This version conmmemorates raylib 3rd anniversary (raylib 1.0 was published on November 2013) and it is a stepping stone for raylib future. raylib roadmap has been reviewed and redefined to focus on its primary objective: create a simple and easy-to-use library to learn videogames programming. Some of the new features:
-Complete raylib LUA binding. All raylib functions plus the +60 code examples have been ported to LUA, now LUA users can enjoy coding videogames in LUA while using all the internal power of raylib. This addition also open the doors to LUA scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to LUA scripts while keep using raylib functionality.
+Complete raylib Lua binding. All raylib functions plus the +60 code examples have been ported to Lua, now Lua users can enjoy coding videogames in Lua while using all the internal power of raylib. This addition also open the doors to Lua scripting support for a future raylib-based engine, being able to move game logic (Init, Update, Draw, De-Init) to Lua scripts while keep using raylib functionality.
Completely redesigned audio module. Based on the new direction taken in raylib 1.5, it has been further improved and more functionality added (+20 new functions) to allow raw audio processing and streaming. FLAC file format support has also been added. In the same line, OpenAL Soft backend is now provided as a static library in Windows to allow static linking and get ride of OpenAL32.dll. Now raylib Windows games are completey self-contained, no external libraries required any more!
@@ -273,6 +273,9 @@ contributing (in some way or another) to make raylib project better. Huge thanks
- [Emanuele Petriglia](https://github.com/LelixSuper) for working on multiple GNU/Linux improvements and developing [TicTacToe](https://github.com/LelixSuper/TicTacToe) raylib game.
- [Joshua Reisenauer](https://github.com/kd7tck) for adding audio modules support (XM, MOD) and reviewing audio system.
- Marcelo Paez (paezao) for his help on OSX to solve High DPI display issue. Thanks Marcelo!
+ - [Ghassan Al-Mashareqa](https://github.com/ghassanpl) for his amazing contribution with raylib Lua module, I just work over his code to implement [rlua](https://github.com/raysan5/raylib/blob/master/src/rlua.h)
+ - [Teodor Stoenescu](https://github.com/teodor-stoenescu) for his improvements on OBJ object loading.
+Please, if I forget someone in this list, excuse me and write me an email to remind me to add you!
[raysan5]: mailto:[email protected] "Ramon Santamaria - Ray San"
diff --git a/ROADMAP.md b/ROADMAP.md
index 4c153d78..a7d51f0d 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -17,7 +17,7 @@ raylib 1.x
raylib 1.6
- [DONE] LUA scripting support (raylib lua wrapper)
+ [DONE] Lua scripting support (raylib Lua wrapper)
[DONE] Redesigned audio module
raylib 1.5
diff --git a/examples/audio_module_playing.c b/examples/audio_module_playing.c
index a9ee4619..4582a561 100644
--- a/examples/audio_module_playing.c
+++ b/examples/audio_module_playing.c
@@ -112,7 +112,7 @@ int main()
//----------------------------------------------------------------------------------
BeginDrawing();
- ClearBackground(WHITE);
+ ClearBackground(RAYWHITE);
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
{
diff --git a/examples/physics_demo.c b/examples/physics_demo.c
index bed7c94d..de8d515e 100644
--- a/examples/physics_demo.c
+++ b/examples/physics_demo.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
int main()
{
diff --git a/examples/physics_friction.c b/examples/physics_friction.c
index 28d3c4b8..a4baad53 100644
--- a/examples/physics_friction.c
+++ b/examples/physics_friction.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
int main()
{
diff --git a/examples/physics_movement.c b/examples/physics_movement.c
index ca18f3df..ee97845f 100644
--- a/examples/physics_movement.c
+++ b/examples/physics_movement.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
#define VELOCITY 0.5f
diff --git a/examples/physics_restitution.c b/examples/physics_restitution.c
index 3543db69..378f6f24 100644
--- a/examples/physics_restitution.c
+++ b/examples/physics_restitution.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
int main()
{
diff --git a/examples/physics_shatter.c b/examples/physics_shatter.c
index 2cb9d195..637a163e 100644
--- a/examples/physics_shatter.c
+++ b/examples/physics_shatter.c
@@ -12,7 +12,7 @@
#include "raylib.h"
#define PHYSAC_IMPLEMENTATION
-#include "..\src\physac.h"
+#include "../src/physac.h"
int main()
{
diff --git a/project/vs2015/raylib/ReadMe.txt b/project/vs2015/raylib/ReadMe.txt
deleted file mode 100644
index 0d46b9fa..00000000
--- a/project/vs2015/raylib/ReadMe.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-========================================================================
- STATIC LIBRARY : raylib Project Overview
-========================================================================
-
-AppWizard has created this raylib library project for you.
-
-No source files were created as part of your project.
-
-
-raylib.vcxproj
- This is the main project file for VC++ projects generated using an Application Wizard.
- It contains information about the version of Visual C++ that generated the file, and
- information about the platforms, configurations, and project features selected with the
- Application Wizard.
-
-raylib.vcxproj.filters
- This is the filters file for VC++ projects generated using an Application Wizard.
- It contains information about the association between the files in your project
- and the filters. This association is used in the IDE to show grouping of files with
- similar extensions under a specific node (for e.g. ".cpp" files are associated with the
- "Source Files" filter).
-
-/////////////////////////////////////////////////////////////////////////////
-Other notes:
-
-AppWizard uses "TODO:" comments to indicate parts of the source code you
-should add to or customize.
-
-/////////////////////////////////////////////////////////////////////////////
diff --git a/src/audio.c b/src/audio.c
index 49aca4b0..eef07154 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -411,6 +411,7 @@ Sound LoadSoundFromRES(const char *rresName, int resId)
else
{
// Depending on type, skip the right amount of parameters
+ /* TODO: Review
switch (infoHeader.type)
{
case 0: fseek(rresFile, 6, SEEK_CUR); break; // IMAGE: Jump 6 bytes of parameters
@@ -420,6 +421,7 @@ Sound LoadSoundFromRES(const char *rresName, int resId)
case 4: break; // RAW: No parameters
default: break;
}
+ */
// Jump DATA to read next infoHeader
fseek(rresFile, infoHeader.size, SEEK_CUR);
@@ -604,7 +606,7 @@ void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels)
// Copy a wave to a new wave
Wave WaveCopy(Wave wave)
{
- Wave newWave;
+ Wave newWave = { 0 };
if (wave.sampleSize == 8) newWave.data = (unsigned char *)malloc(wave.sampleCount*wave.channels*sizeof(unsigned char));
else if (wave.sampleSize == 16) newWave.data = (short *)malloc(wave.sampleCount*wave.channels*sizeof(short));
@@ -822,8 +824,8 @@ void UpdateMusicStream(Music music)
if (processed > 0)
{
bool active = true;
- short pcm[AUDIO_BUFFER_SIZE];
- float pcmf[AUDIO_BUFFER_SIZE];
+ short pcm[AUDIO_BUFFER_SIZE]; // TODO: Dynamic allocation (uses more than 16KB of stack)
+ float pcmf[AUDIO_BUFFER_SIZE]; // TODO: Dynamic allocation (uses more than 16KB of stack)
int numBuffersToProcess = processed;
int numSamples = 0; // Total size of data steamed in L+R samples for xm floats,
@@ -952,7 +954,7 @@ float GetMusicTimePlayed(Music music)
float secondsPlayed = 0.0f;
unsigned int samplesPlayed = music->totalSamples - music->samplesLeft;
- secondsPlayed = (float)samplesPlayed/(music->stream.sampleRate*music->stream.channels);
+ secondsPlayed = (float)(samplesPlayed/(music->stream.sampleRate*music->stream.channels));
return secondsPlayed;
}
@@ -1004,17 +1006,17 @@ AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, un
{
if (stream.sampleSize == 8)
{
- unsigned char pcm[AUDIO_BUFFER_SIZE] = { 0 };
+ unsigned char pcm[AUDIO_BUFFER_SIZE] = { 0 }; // TODO: Dynamic allocation (uses more than 16KB of stack)
alBufferData(stream.buffers[i], stream.format, pcm, AUDIO_BUFFER_SIZE*sizeof(unsigned char), stream.sampleRate);
}
else if (stream.sampleSize == 16)
{
- short pcm[AUDIO_BUFFER_SIZE] = { 0 };
+ short pcm[AUDIO_BUFFER_SIZE] = { 0 }; // TODO: Dynamic allocation (uses more than 16KB of stack)
alBufferData(stream.buffers[i], stream.format, pcm, AUDIO_BUFFER_SIZE*sizeof(short), stream.sampleRate);
}
else if (stream.sampleSize == 32)
{
- float pcm[AUDIO_BUFFER_SIZE] = { 0.0f };
+ float pcm[AUDIO_BUFFER_SIZE] = { 0.0f }; // TODO: Dynamic allocation (uses more than 16KB of stack)
alBufferData(stream.buffers[i], stream.format, pcm, AUDIO_BUFFER_SIZE*sizeof(float), stream.sampleRate);
}
}
diff --git a/src/camera.h b/src/camera.h
index 33220390..cf542288 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -223,15 +223,15 @@ void SetCameraMode(Camera camera, int mode)
float dy = v2.y - v1.y;
float dz = v2.z - v1.z;
- cameraTargetDistance = sqrt(dx*dx + dy*dy + dz*dz);
+ cameraTargetDistance = sqrtf(dx*dx + dy*dy + dz*dz);
Vector2 distance = { 0.0f, 0.0f };
- distance.x = sqrt(dx*dx + dz*dz);
- distance.y = sqrt(dx*dx + dy*dy);
+ distance.x = sqrtf(dx*dx + dz*dz);
+ distance.y = sqrtf(dx*dx + dy*dy);
// Camera angle calculation
- cameraAngle.x = asin(fabs(dx)/distance.x); // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
- cameraAngle.y = -asin(fabs(dy)/distance.y); // Camera angle in plane XY (0 aligned with X, move positive CW)
+ cameraAngle.x = asinf(fabsf(dx)/distance.x); // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
+ cameraAngle.y = -asinf(fabsf(dy)/distance.y); // Camera angle in plane XY (0 aligned with X, move positive CW)
// NOTE: Just testing what cameraAngle means
//cameraAngle.x = 0.0f*DEG2RAD; // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
@@ -285,10 +285,10 @@ void UpdateCamera(Camera *camera)
{
HideCursor();
- if (mousePosition.x < screenHeight/3) SetMousePosition((Vector2){ screenWidth - screenHeight/3, mousePosition.y });
- else if (mousePosition.y < screenHeight/3) SetMousePosition((Vector2){ mousePosition.x, screenHeight - screenHeight/3 });
- else if (mousePosition.x > (screenWidth - screenHeight/3)) SetMousePosition((Vector2){ screenHeight/3, mousePosition.y });
- else if (mousePosition.y > (screenHeight - screenHeight/3)) SetMousePosition((Vector2){ mousePosition.x, screenHeight/3 });
+ if (mousePosition.x < (float)screenHeight/3.0f) SetMousePosition((Vector2){ screenWidth - screenHeight/3, mousePosition.y });
+ else if (mousePosition.y < (float)screenHeight/3.0f) SetMousePosition((Vector2){ mousePosition.x, screenHeight - screenHeight/3 });
+ else if (mousePosition.x > (screenWidth - (float)screenHeight/3.0f)) SetMousePosition((Vector2){ screenHeight/3, mousePosition.y });
+ else if (mousePosition.y > (screenHeight - (float)screenHeight/3.0f)) SetMousePosition((Vector2){ mousePosition.x, screenHeight/3 });
else
{
mousePositionDelta.x = mousePosition.x - previousMousePosition.x;
@@ -321,6 +321,7 @@ void UpdateCamera(Camera *camera)
if (cameraTargetDistance > CAMERA_FREE_DISTANCE_MAX_CLAMP) cameraTargetDistance = CAMERA_FREE_DISTANCE_MAX_CLAMP;
}
// Camera looking down
+ // TODO: Review, weird comparisson of cameraTargetDistance == 120.0f?
else if ((camera->position.y > camera->target.y) && (cameraTargetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0))
{
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/cameraTargetDistance;
@@ -341,6 +342,7 @@ void UpdateCamera(Camera *camera)
if (cameraTargetDistance < CAMERA_FREE_DISTANCE_MIN_CLAMP) cameraTargetDistance = CAMERA_FREE_DISTANCE_MIN_CLAMP;
}
// Camera looking up
+ // TODO: Review, weird comparisson of cameraTargetDistance == 120.0f?
else if ((camera->position.y < camera->target.y) && (cameraTargetDistance == CAMERA_FREE_DISTANCE_MAX_CLAMP) && (mouseWheelMove < 0))
{
camera->target.x += mouseWheelMove*(camera->target.x - camera->position.x)*CAMERA_MOUSE_SCROLL_SENSITIVITY/cameraTargetDistance;
@@ -385,9 +387,9 @@ void UpdateCamera(Camera *camera)
else
{
// Camera panning
- camera->target.x += ((mousePositionDelta.x*-CAMERA_FREE_MOUSE_SENSITIVITY)*cos(cameraAngle.x) + (mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*sin(cameraAngle.x)*sin(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
- camera->target.y += ((mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cos(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
- camera->target.z += ((mousePositionDelta.x*CAMERA_FREE_MOUSE_SENSITIVITY)*sin(cameraAngle.x) + (mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cos(cameraAngle.x)*sin(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
+ camera->target.x += ((mousePositionDelta.x*-CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(cameraAngle.x) + (mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*sinf(cameraAngle.x)*sinf(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
+ camera->target.y += ((mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
+ camera->target.z += ((mousePositionDelta.x*CAMERA_FREE_MOUSE_SENSITIVITY)*sinf(cameraAngle.x) + (mousePositionDelta.y*CAMERA_FREE_MOUSE_SENSITIVITY)*cosf(cameraAngle.x)*sinf(cameraAngle.y))*(cameraTargetDistance/CAMERA_FREE_PANNING_DIVIDER);
}
}
@@ -404,19 +406,19 @@ void UpdateCamera(Camera *camera)
case CAMERA_FIRST_PERSON:
case CAMERA_THIRD_PERSON:
{
- camera->position.x += (sin(cameraAngle.x)*direction[MOVE_BACK] -
- sin(cameraAngle.x)*direction[MOVE_FRONT] -
- cos(cameraAngle.x)*direction[MOVE_LEFT] +
- cos(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY;
+ camera->position.x += (sinf(cameraAngle.x)*direction[MOVE_BACK] -
+ sinf(cameraAngle.x)*direction[MOVE_FRONT] -
+ cosf(cameraAngle.x)*direction[MOVE_LEFT] +
+ cosf(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY;
- camera->position.y += (sin(cameraAngle.y)*direction[MOVE_FRONT] -
- sin(cameraAngle.y)*direction[MOVE_BACK] +
+ camera->position.y += (sinf(cameraAngle.y)*direction[MOVE_FRONT] -
+ sinf(cameraAngle.y)*direction[MOVE_BACK] +
1.0f*direction[MOVE_UP] - 1.0f*direction[MOVE_DOWN])/PLAYER_MOVEMENT_SENSITIVITY;
- camera->position.z += (cos(cameraAngle.x)*direction[MOVE_BACK] -
- cos(cameraAngle.x)*direction[MOVE_FRONT] +
- sin(cameraAngle.x)*direction[MOVE_LEFT] -
- sin(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY;
+ camera->position.z += (cosf(cameraAngle.x)*direction[MOVE_BACK] -
+ cosf(cameraAngle.x)*direction[MOVE_FRONT] +
+ sinf(cameraAngle.x)*direction[MOVE_LEFT] -
+ sinf(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY;
bool isMoving = false; // Required for swinging
@@ -439,9 +441,9 @@ void UpdateCamera(Camera *camera)
if (cameraTargetDistance < CAMERA_THIRD_PERSON_DISTANCE_CLAMP) cameraTargetDistance = CAMERA_THIRD_PERSON_DISTANCE_CLAMP;
// Camera is always looking at player
- camera->target.x = camera->position.x + CAMERA_THIRD_PERSON_OFFSET.x*cos(cameraAngle.x) + CAMERA_THIRD_PERSON_OFFSET.z*sin(cameraAngle.x);
+ camera->target.x = camera->position.x + CAMERA_THIRD_PERSON_OFFSET.x*cosf(cameraAngle.x) + CAMERA_THIRD_PERSON_OFFSET.z*sinf(cameraAngle.x);
camera->target.y = camera->position.y + CAMERA_THIRD_PERSON_OFFSET.y;
- camera->target.z = camera->position.z + CAMERA_THIRD_PERSON_OFFSET.z*sin(cameraAngle.x) - CAMERA_THIRD_PERSON_OFFSET.x*sin(cameraAngle.x);
+ camera->target.z = camera->position.z + CAMERA_THIRD_PERSON_OFFSET.z*sinf(cameraAngle.x) - CAMERA_THIRD_PERSON_OFFSET.x*sinf(cameraAngle.x);
}
else // CAMERA_FIRST_PERSON
{
@@ -450,18 +452,18 @@ void UpdateCamera(Camera *camera)
else if (cameraAngle.y < CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD) cameraAngle.y = CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD;
// Camera is always looking at player
- camera->target.x = camera->position.x - sin(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
- camera->target.y = camera->position.y + sin(cameraAngle.y)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
- camera->target.z = camera->position.z - cos(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
+ camera->target.x = camera->position.x - sinf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
+ camera->target.y = camera->position.y + sinf(cameraAngle.y)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
+ camera->target.z = camera->position.z - cosf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE;
if (isMoving) swingCounter++;
// Camera position update
// NOTE: On CAMERA_FIRST_PERSON player Y-movement is limited to player 'eyes position'
- camera->position.y = playerEyesPosition - sin(swingCounter/CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER)/CAMERA_FIRST_PERSON_STEP_DIVIDER;
+ camera->position.y = playerEyesPosition - sinf(swingCounter/CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER)/CAMERA_FIRST_PERSON_STEP_DIVIDER;
- camera->up.x = sin(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER;
- camera->up.z = -sin(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER;
+ camera->up.x = sinf(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER;
+ camera->up.z = -sinf(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER;
}
} break;
default: break;
@@ -473,10 +475,10 @@ void UpdateCamera(Camera *camera)
(cameraMode == CAMERA_THIRD_PERSON))
{
// TODO: It seems camera->position is not correctly updated or some rounding issue makes the camera move straight to camera->target...
- camera->position.x = sin(cameraAngle.x)*cameraTargetDistance*cos(cameraAngle.y) + camera->target.x;
- if (cameraAngle.y <= 0.0f) camera->position.y = sin(cameraAngle.y)*cameraTargetDistance*sin(cameraAngle.y) + camera->target.y;
- else camera->position.y = -sin(cameraAngle.y)*cameraTargetDistance*sin(cameraAngle.y) + camera->target.y;
- camera->position.z = cos(cameraAngle.x)*cameraTargetDistance*cos(cameraAngle.y) + camera->target.z;
+ camera->position.x = sinf(cameraAngle.x)*cameraTargetDistance*cosf(cameraAngle.y) + camera->target.x;
+ if (cameraAngle.y <= 0.0f) camera->position.y = sinf(cameraAngle.y)*cameraTargetDistance*sinf(cameraAngle.y) + camera->target.y;
+ else camera->position.y = -sinf(cameraAngle.y)*cameraTargetDistance*sinf(cameraAngle.y) + camera->target.y;
+ camera->position.z = cosf(cameraAngle.x)*cameraTargetDistance*cosf(cameraAngle.y) + camera->target.z;
}
}
diff --git a/src/core.c b/src/core.c
index 40bf3990..455417d2 100644
--- a/src/core.c
+++ b/src/core.c
@@ -779,7 +779,7 @@ float GetFrameTime(void)
// As we are operate quite a lot with frameTime,
// it could be no stable, so we round it before passing it around
// NOTE: There are still problems with high framerates (>500fps)
- double roundedFrameTime = round(frameTime*10000)/10000.0;
+ double roundedFrameTime = round(frameTime*10000)/10000.0;
return (float)roundedFrameTime; // Time in seconds to run a frame
}
@@ -1089,7 +1089,7 @@ Vector2 GetWorldToScreen(Vector3 position, Camera camera)
QuaternionTransform(&worldPos, matProj);
// Calculate normalized device coordinates (inverted y)
- Vector3 ndcPos = { worldPos.x/worldPos.w, -worldPos.y/worldPos.w, worldPos.z/worldPos.z };
+ Vector3 ndcPos = { worldPos.x/worldPos.w, -worldPos.y/worldPos.w, worldPos.z/worldPos.w };
// Calculate 2d screen position vector
Vector2 screenPosition = { (ndcPos.x + 1.0f)/2.0f*(float)GetScreenWidth(), (ndcPos.y + 1.0f)/2.0f*(float)GetScreenHeight() };
diff --git a/src/gestures.h b/src/gestures.h
index 481ef317..19b09269 100644
--- a/src/gestures.h
+++ b/src/gestures.h
@@ -179,7 +179,7 @@ static int tapCounter = 0; // TAP counter (one tap implies
// Hold gesture variables
static bool resetHold = false; // HOLD reset to get first touch point again
-static float timeHold = 0.0f; // HOLD duration in milliseconds
+static double timeHold = 0.0f; // HOLD duration in milliseconds
// Drag gesture variables
static Vector2 dragVector = { 0.0f , 0.0f }; // DRAG vector (between initial and current position)
@@ -423,11 +423,11 @@ float GetGestureHoldDuration(void)
{
// NOTE: time is calculated on current gesture HOLD
- float time = 0.0f;
+ double time = 0.0;
- if (currentGesture == GESTURE_HOLD) time = (float)GetCurrentTime() - timeHold;
+ if (currentGesture == GESTURE_HOLD) time = GetCurrentTime() - timeHold;
- return time;
+ return (float)time;
}
// Get drag vector (between initial touch point to current)
@@ -474,7 +474,7 @@ static float Vector2Angle(Vector2 initialPosition, Vector2 finalPosition)
{
float angle;
- angle = atan2(finalPosition.y - initialPosition.y, finalPosition.x - initialPosition.x)*(180.0f/PI);
+ angle = atan2f(finalPosition.y - initialPosition.y, finalPosition.x - initialPosition.x)*(180.0f/PI);
if (angle < 0) angle += 360.0f;
@@ -489,7 +489,7 @@ static float Vector2Distance(Vector2 v1, Vector2 v2)
float dx = v2.x - v1.x;
float dy = v2.y - v1.y;
- result = sqrt(dx*dx + dy*dy);
+ result = (float)sqrt(dx*dx + dy*dy);
return result;
}
diff --git a/src/models.c b/src/models.c
index 48f8b813..97c84abc 100644
--- a/src/models.c
+++ b/src/models.c
@@ -707,6 +707,7 @@ Model LoadModelFromRES(const char *rresName, int resId)
else
{
// Depending on type, skip the right amount of parameters
+ /* Review
switch (infoHeader.type)
{
case 0: fseek(rresFile, 6, SEEK_CUR); break; // IMAGE: Jump 6 bytes of parameters
@@ -716,6 +717,7 @@ Model LoadModelFromRES(const char *rresName, int resId)
case 4: break; // RAW: No parameters
default: break;
}
+ */
// Jump DATA to read next infoHeader
fseek(rresFile, infoHeader.size, SEEK_CUR);
@@ -1517,8 +1519,8 @@ bool CheckCollisionRayBox(Ray ray, BoundingBox box)
t[3] = (box.max.y - ray.position.y)/ray.direction.y;
t[4] = (box.min.z - ray.position.z)/ray.direction.z;
t[5] = (box.max.z - ray.position.z)/ray.direction.z;
- t[6] = fmax(fmax(fmin(t[0], t[1]), fmin(t[2], t[3])), fmin(t[4], t[5]));
- t[7] = fmin(fmin(fmax(t[0], t[1]), fmax(t[2], t[3])), fmax(t[4], t[5]));
+ t[6] = (float)fmax(fmax(fmin(t[0], t[1]), fmin(t[2], t[3])), fmin(t[4], t[5]));
+ t[7] = (float)fmin(fmin(fmax(t[0], t[1]), fmax(t[2], t[3])), fmax(t[4], t[5]));
collision = !(t[7] < 0 || t[6] > t[7]);
diff --git a/src/raylib.h b/src/raylib.h
index d28b07a3..8f69438f 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -19,7 +19,7 @@
* Multiple platforms support: Windows, Linux, Mac, Android, Raspberry Pi, HTML5 and Oculus Rift CV1
* Custom color palette for fancy visuals on raywhite background
* Minimal external dependencies (GLFW3, OpenGL, OpenAL)
-* Complete binding for LUA [rlua]
+* Complete binding for Lua [rlua]
*
* External libs:
* GLFW3 (www.glfw.org) for window/context management and input [core]
diff --git a/src/raymath.h b/src/raymath.h
index 10eabb6b..3cd1394e 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -222,16 +222,16 @@ RMDEF Vector3 VectorPerpendicular(Vector3 v)
{
Vector3 result;
- float min = fabs(v.x);
+ float min = fabsf(v.x);
Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};
- if (fabs(v.y) < min)
+ if (fabsf(v.y) < min)
{
- min = fabs(v.y);
+ min = fabsf(v.y);
cardinalAxis = (Vector3){0.0f, 1.0f, 0.0f};
}
- if(fabs(v.z) < min)
+ if(fabsf(v.z) < min)
{
cardinalAxis = (Vector3){0.0f, 0.0f, 1.0f};
}
@@ -256,7 +256,7 @@ RMDEF float VectorLength(const Vector3 v)
{
float length;
- length = sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
+ length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
return length;
}
@@ -284,7 +284,7 @@ RMDEF void VectorNormalize(Vector3 *v)
length = VectorLength(*v);
- if (length == 0) length = 1.0f;
+ if (length == 0.0f) length = 1.0f;
ilength = 1.0f/length;
@@ -302,7 +302,7 @@ RMDEF float VectorDistance(Vector3 v1, Vector3 v2)
float dy = v2.y - v1.y;
float dz = v2.z - v1.z;
- result = sqrt(dx*dx + dy*dy + dz*dz);
+ result = sqrtf(dx*dx + dy*dy + dz*dz);
return result;
}
@@ -590,7 +590,7 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
float x = axis.x, y = axis.y, z = axis.z;
- float length = sqrt(x*x + y*y + z*z);
+ float length = sqrtf(x*x + y*y + z*z);
if ((length != 1.0f) && (length != 0.0f))
{
diff --git a/src/rlgl.c b/src/rlgl.c
index 629d7967..c694dcdc 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -318,6 +318,7 @@ static bool texCompETC1Supported = false; // ETC1 texture compression support
static bool texCompETC2Supported = false; // ETC2/EAC texture compression support
static bool texCompPVRTSupported = false; // PVR texture compression support
static bool texCompASTCSupported = false; // ASTC texture compression support
+#endif
// Extension supported flag: Anisotropic filtering
static bool texAnisotropicFilterSupported = false; // Anisotropic texture filtering support
@@ -325,7 +326,6 @@ static float maxAnisotropicLevel = 0.0f; // Maximum anisotropy level supp
// Extension supported flag: Clamp mirror wrap mode
static bool texClampMirrorSupported = false; // Clamp mirror wrap mode supported
-#endif
#if defined(RLGL_OCULUS_SUPPORT)
// OVR device variables
@@ -902,6 +902,10 @@ void rlDisableTexture(void)
#if defined(GRAPHICS_API_OPENGL_11)
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
+#else
+ // NOTE: If quads batch limit is reached,
+ // we force a draw call and next batch starts
+ if (quads.vCounter/4 >= MAX_QUADS_BATCH) rlglDraw();
#endif
}
@@ -922,11 +926,11 @@ void rlTextureParameters(unsigned int id, int param, int value)
case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_2D, param, value); break;
case RL_TEXTURE_ANISOTROPIC_FILTER:
{
- if (value <= maxAnisotropicLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, value);
+ if (value <= maxAnisotropicLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
else if (maxAnisotropicLevel > 0.0f)
{
TraceLog(WARNING, "[TEX ID %i] Maximum anisotropic filter level supported is %iX", id, maxAnisotropicLevel);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, value);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value);
}
else TraceLog(WARNING, "Anisotropic filtering not supported");
} break;
@@ -1733,7 +1737,7 @@ void rlglGenerateMipmaps(Texture2D *texture)
{
#if defined(GRAPHICS_API_OPENGL_11)
// Compute required mipmaps
- void *data = rlglReadTexturePixels(texture);
+ void *data = rlglReadTexturePixels(*texture);
// NOTE: data size is reallocated to fit mipmaps data
// NOTE: CPU mipmap generation only supports RGBA 32bit data
@@ -1776,7 +1780,7 @@ void rlglGenerateMipmaps(Texture2D *texture)
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
- texture->mipmaps = 1 + floor(log2(MAX(texture->width, texture->height)));
+ texture->mipmaps = 1 + (int)floor(log(MAX(texture->width, texture->height))/log(2));
#endif
}
else TraceLog(WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id);
diff --git a/src/shapes.c b/src/shapes.c
index 70aad59a..3d3333c1 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -453,16 +453,17 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
int recCenterX = rec.x + rec.width/2;
int recCenterY = rec.y + rec.height/2;
- float dx = fabs(center.x - recCenterX);
- float dy = fabs(center.y - recCenterY);
+ float dx = fabsf(center.x - recCenterX);
+ float dy = fabsf(center.y - recCenterY);
- if (dx > (rec.width/2 + radius)) { return false; }
- if (dy > (rec.height/2 + radius)) { return false; }
+ if (dx > ((float)rec.width/2.0f + radius)) { return false; }
+ if (dy > ((float)rec.height/2.0f + radius)) { return false; }
- if (dx <= (rec.width/2)) { return true; }
- if (dy <= (rec.height/2)) { return true; }
+ if (dx <= ((float)rec.width/2.0f)) { return true; }
+ if (dy <= ((float)rec.height/2.0f)) { return true; }
- float cornerDistanceSq = (dx - rec.width/2)*(dx - rec.width/2) + (dy - rec.height/2)*(dy - rec.height/2);
+ float cornerDistanceSq = (dx - (float)rec.width/2.0f)*(dx - (float)rec.width/2.0f) +
+ (dy - (float)rec.height/2.0f)*(dy - (float)rec.height/2.0f);
return (cornerDistanceSq <= (radius*radius));
}
diff --git a/src/text.c b/src/text.c
index c394889e..27b0a9ce 100644
--- a/src/text.c
+++ b/src/text.c
@@ -367,7 +367,7 @@ void DrawTextEx(SpriteFont spriteFont, const char *text, Vector2 position, float
if ((unsigned char)text[i] == '\n')
{
// NOTE: Fixed line spacing of 1.5 lines
- textOffsetY += ((spriteFont.size + spriteFont.size/2)*scaleFactor);
+ textOffsetY += (int)((spriteFont.size + spriteFont.size/2)*scaleFactor);
textOffsetX = 0;
}
else
@@ -394,8 +394,8 @@ void DrawTextEx(SpriteFont spriteFont, const char *text, Vector2 position, float
spriteFont.charRecs[index].width*scaleFactor,
spriteFont.charRecs[index].height*scaleFactor }, (Vector2){ 0, 0 }, 0.0f, tint);
- if (spriteFont.charAdvanceX[index] == 0) textOffsetX += (spriteFont.charRecs[index].width*scaleFactor + spacing);
- else textOffsetX += (spriteFont.charAdvanceX[index]*scaleFactor + spacing);
+ if (spriteFont.charAdvanceX[index] == 0) textOffsetX += (int)(spriteFont.charRecs[index].width*scaleFactor + spacing);
+ else textOffsetX += (int)(spriteFont.charAdvanceX[index]*scaleFactor + spacing);
}
}
}
@@ -460,14 +460,14 @@ int MeasureText(const char *text, int fontSize)
Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, int spacing)
{
int len = strlen(text);
- int tempLen = 0; // Used to count longer text line num chars
+ int tempLen = 0; // Used to count longer text line num chars
int lenCounter = 0;
- int textWidth = 0;
- int tempTextWidth = 0; // Used to count longer text line width
+ float textWidth = 0;
+ float tempTextWidth = 0; // Used to count longer text line width
- int textHeight = spriteFont.size;
- float scaleFactor = fontSize/spriteFont.size;
+ float textHeight = (float)spriteFont.size;
+ float scaleFactor = fontSize/(float)spriteFont.size;
for (int i = 0; i < len; i++)
{
@@ -485,7 +485,7 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, i
if (tempTextWidth < textWidth) tempTextWidth = textWidth;
lenCounter = 0;
textWidth = 0;
- textHeight += (spriteFont.size + spriteFont.size/2); // NOTE: Fixed line spacing of 1.5 lines
+ textHeight += ((float)spriteFont.size*1.5f); // NOTE: Fixed line spacing of 1.5 lines
}
if (tempLen < lenCounter) tempLen = lenCounter;
@@ -494,8 +494,8 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, i
if (tempTextWidth < textWidth) tempTextWidth = textWidth;
Vector2 vec;
- vec.x = (float)tempTextWidth*scaleFactor + (tempLen - 1)*spacing; // Adds chars spacing to measure
- vec.y = (float)textHeight*scaleFactor;
+ vec.x = tempTextWidth*scaleFactor + (float)((tempLen - 1)*spacing); // Adds chars spacing to measure
+ vec.y = textHeight*scaleFactor;
return vec;
}
@@ -504,10 +504,8 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, i
// NOTE: Uses default font
void DrawFPS(int posX, int posY)
{
- char buffer[20];
-
// NOTE: We are rendering fps every second for better viewing on high framerates
- // TODO: Not working properly on ANDROID and RPI
+ // TODO: Not working properly on ANDROID and RPI (for high framerates)
static float fps = 0.0f;
static int counter = 0;
@@ -520,12 +518,11 @@ void DrawFPS(int posX, int posY)
else
{
fps = GetFPS();
- refreshRate = fps;
+ refreshRate = (int)fps;
counter = 0;
}
-
- sprintf(buffer, "%2.0f FPS", fps);
- DrawText(buffer, posX, posY, 20, LIME);
+
+ DrawText(FormatText("%2.0f FPS", fps), posX, posY, 20, LIME);
}
//----------------------------------------------------------------------------------
diff --git a/src/textures.c b/src/textures.c
index 126adad3..631468f9 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -317,6 +317,7 @@ Image LoadImageFromRES(const char *rresName, int resId)
else
{
// Depending on type, skip the right amount of parameters
+ /* TODO: Review
switch (infoHeader.type)
{
case 0: fseek(rresFile, 6, SEEK_CUR); break; // IMAGE: Jump 6 bytes of parameters
@@ -326,7 +327,7 @@ Image LoadImageFromRES(const char *rresName, int resId)
case 4: break; // RAW: No parameters
default: break;
}
-
+ */
// Jump DATA to read next infoHeader
fseek(rresFile, infoHeader.size, SEEK_CUR);
}
@@ -1100,18 +1101,18 @@ void ImageResizeNN(Image *image,int newWidth,int newHeight)
Color *output = (Color *)malloc(newWidth*newHeight*sizeof(Color));
// EDIT: added +1 to account for an early rounding problem
- int x_ratio = (int)((image->width<<16)/newWidth) + 1;
- int y_ratio = (int)((image->height<<16)/newHeight) + 1;
+ int xRatio = (int)((image->width << 16)/newWidth) + 1;
+ int yRatio = (int)((image->height << 16)/newHeight) + 1;
int x2, y2;
- for (int i = 0; i < newHeight; i++)
+ for (int y = 0; y < newHeight; y++)
{
- for (int j = 0; j < newWidth; j++)
+ for (int x = 0; x < newWidth; x++)
{
- x2 = ((j*x_ratio) >> 16);
- y2 = ((i*y_ratio) >> 16);
+ x2 = ((x*xRatio) >> 16);
+ y2 = ((y*yRatio) >> 16);
- output[(i*newWidth) + j] = pixels[(y2*image->width) + x2] ;
+ output[(y*newWidth) + x] = pixels[(y2*image->width) + x2] ;
}
}
@@ -1584,7 +1585,7 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V
rlEnableTexture(texture.id);
rlPushMatrix();
- rlTranslatef(destRec.x, destRec.y, 0);
+ rlTranslatef((float)destRec.x, (float)destRec.y, 0);
rlRotatef(rotation, 0, 0, 1);
rlTranslatef(-origin.x, -origin.y, 0);
@@ -1598,15 +1599,15 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V
// Bottom-right corner for texture and quad
rlTexCoord2f((float)sourceRec.x/texture.width, (float)(sourceRec.y + sourceRec.height)/texture.height);
- rlVertex2f(0.0f, destRec.height);
+ rlVertex2f(0.0f, (float)destRec.height);
// Top-right corner for texture and quad
rlTexCoord2f((float)(sourceRec.x + sourceRec.width)/texture.width, (float)(sourceRec.y + sourceRec.height)/texture.height);
- rlVertex2f(destRec.width, destRec.height);
+ rlVertex2f((float)destRec.width, (float)destRec.height);
// Top-left corner for texture and quad
rlTexCoord2f((float)(sourceRec.x + sourceRec.width)/texture.width, (float)sourceRec.y/texture.height);
- rlVertex2f(destRec.width, 0.0f);
+ rlVertex2f((float)destRec.width, 0.0f);
rlEnd();
rlPopMatrix();