From 7db895ab5d415d931e0319061d437c952a6155b2 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Wed, 22 Apr 2015 18:36:52 +0200 Subject: [PATCH] Corrected some bugs and warnings --- src/core.c | 4 ++-- src/gestures.c | 10 +++++----- src/raylib.h | 2 +- src/raymath.c | 6 +++--- src/rlgl.c | 2 ++ src/shapes.c | 4 ++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/core.c b/src/core.c index 7196fbb0..81583bf3 100644 --- a/src/core.c +++ b/src/core.c @@ -718,7 +718,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera) float realy = (float)GetScreenHeight() - mousePosition.y; - float z; + //float z; // glReadPixels(mousePosition.x, mousePosition.y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); //http://www.bfilipek.com/2012/06/select-mouse-opengl.html @@ -955,7 +955,7 @@ bool IsCursorHidden() // TODO: Enable gamepad usage on Rapsberry Pi // NOTE: emscripten not implemented -#if defined(PLATFORM_DESKTOP) +#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) // Detect if a gamepad is available bool IsGamepadAvailable(int gamepad) { diff --git a/src/gestures.c b/src/gestures.c index 594c3cd5..00b57e4c 100644 --- a/src/gestures.c +++ b/src/gestures.c @@ -30,7 +30,8 @@ #include // malloc(), free() #include // printf(), fprintf() #include // Used for ... -#include +#include // Used for clock functions +#include // Defines int32_t, int64_t #if defined(PLATFORM_ANDROID) #include // Java native interface @@ -40,7 +41,7 @@ #if defined(PLATFORM_WEB) #include - #include + #include #endif //---------------------------------------------------------------------------------- @@ -78,7 +79,7 @@ typedef struct { static GestureType gestureType = TYPE_MOTIONLESS; // Gestures detection variables -static int32_t touchId; +//static int32_t touchId; // Not used... // Event static int64_t eventTime = 0; @@ -616,13 +617,12 @@ static EM_BOOL EmscriptenInputCallback(int eventType, const EmscriptenTouchEvent else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) gestureEvent.action = MOVE; // Points - gestureEvent.pointCount = event->numTouches; + gestureEvent.pointCount = touchEvent->numTouches; // Position gestureEvent.position[0] = (Vector2){ touchEvent->touches[0].canvasX, touchEvent->touches[0].canvasY }; gestureEvent.position[1] = (Vector2){ touchEvent->touches[1].canvasX, touchEvent->touches[1].canvasY }; - ProcessMotionEvent(gestureEvent); return 1; diff --git a/src/raylib.h b/src/raylib.h index 962376a9..ad1df97a 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -437,7 +437,7 @@ void HideCursor(void); // Hides cursor bool IsCursorHidden(void); // Returns true if cursor is not visible #endif -#if defined(PLATFORM_DESKTOP) +#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available Vector2 GetGamepadMovement(int gamepad); // Return axis movement vector for a gamepad bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once diff --git a/src/raymath.c b/src/raymath.c index 8ad50312..9763b075 100644 --- a/src/raymath.c +++ b/src/raymath.c @@ -920,13 +920,13 @@ Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount) float cosHalfTheta = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w; - if (abs(cosHalfTheta) >= 1.0f) result = q1; + if (fabs(cosHalfTheta) >= 1.0f) result = q1; else { float halfTheta = acos(cosHalfTheta); float sinHalfTheta = sqrt(1.0f - cosHalfTheta*cosHalfTheta); - if (abs(sinHalfTheta) < 0.001f) + if (fabs(sinHalfTheta) < 0.001f) { result.x = (q1.x*0.5f + q2.x*0.5f); result.y = (q1.y*0.5f + q2.y*0.5f); @@ -1072,7 +1072,7 @@ Matrix QuaternionToMatrix(Quaternion q) // Returns the axis and the angle for a given quaternion void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle) { - if (abs(q.w) > 1.0f) QuaternionNormalize(&q); + if (fabs(q.w) > 1.0f) QuaternionNormalize(&q); Vector3 resAxis = { 0, 0, 0 }; float resAngle = 0; diff --git a/src/rlgl.c b/src/rlgl.c index cedad6a7..a5c40815 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1411,12 +1411,14 @@ Vector3 rlglUnproject(Vector3 source, Matrix proj, Matrix view) //glGetIntegerv(GL_VIEWPORT, viewport); // Viewport data +/* int x = 0; int y = 0; int width = GetScreenWidth(); int height = GetScreenHeight(); float minDepth = 0.0f; float maxDepth = 1.0f; +*/ /* Matrix modelviewprojection = MatrixMultiply(modelview, projection); MatrixInvert(&modelviewprojection); diff --git a/src/shapes.c b/src/shapes.c index d88845cc..6e6c9dd7 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -395,8 +395,8 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec) { bool collision = false; - float dx = abs((rec.x + rec.width/2) - center.x); - float dy = abs((rec.y + rec.height/2) - center.y); + float dx = fabs((rec.x + rec.width/2) - center.x); + float dy = fabs((rec.y + rec.height/2) - center.y); if ((dx <= (rec.width/2 + radius)) && (dy <= (rec.height/2 + radius))) collision = true;