aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2015-04-22 18:36:52 +0200
committerraysan5 <raysan5@gmail.com>2015-04-22 18:36:52 +0200
commit7db895ab5d415d931e0319061d437c952a6155b2 (patch)
tree2a869121e96cc4059fe979c5421893330003a026 /src
parentceb73257272e34a739b6225e1f30e4e377fdab77 (diff)
downloadraylib-7db895ab5d415d931e0319061d437c952a6155b2.tar.gz
raylib-7db895ab5d415d931e0319061d437c952a6155b2.zip
Corrected some bugs and warnings
Diffstat (limited to 'src')
-rw-r--r--src/core.c4
-rw-r--r--src/gestures.c10
-rw-r--r--src/raylib.h2
-rw-r--r--src/raymath.c6
-rw-r--r--src/rlgl.c2
-rw-r--r--src/shapes.c4
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 <stdlib.h> // malloc(), free()
#include <stdio.h> // printf(), fprintf()
#include <math.h> // Used for ...
-#include <time.h>
+#include <time.h> // Used for clock functions
+#include <stdint.h> // Defines int32_t, int64_t
#if defined(PLATFORM_ANDROID)
#include <jni.h> // Java native interface
@@ -40,7 +41,7 @@
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
- #include <emscripten/emscripten/html5.h>
+ #include <emscripten/html5.h>
#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;