Browse Source

Corrected some bugs and warnings

pull/23/head
raysan5 9 years ago
parent
commit
7db895ab5d
6 changed files with 15 additions and 13 deletions
  1. +2
    -2
      src/core.c
  2. +5
    -5
      src/gestures.c
  3. +1
    -1
      src/raylib.h
  4. +3
    -3
      src/raymath.c
  5. +2
    -0
      src/rlgl.c
  6. +2
    -2
      src/shapes.c

+ 2
- 2
src/core.c View File

@ -718,7 +718,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
float realy = (float)GetScreenHeight() - mousePosition.y; float realy = (float)GetScreenHeight() - mousePosition.y;
float z;
o">//float z;
// glReadPixels(mousePosition.x, mousePosition.y, 1, 1, GL_DEPTH_COMPONENT, GL_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 //http://www.bfilipek.com/2012/06/select-mouse-opengl.html
@ -955,7 +955,7 @@ bool IsCursorHidden()
// TODO: Enable gamepad usage on Rapsberry Pi // TODO: Enable gamepad usage on Rapsberry Pi
// NOTE: emscripten not implemented // NOTE: emscripten not implemented
#if defined(PLATFORM_DESKTOP)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
// Detect if a gamepad is available // Detect if a gamepad is available
bool IsGamepadAvailable(int gamepad) bool IsGamepadAvailable(int gamepad)
{ {

+ 5
- 5
src/gestures.c View File

@ -30,7 +30,8 @@
#include <stdlib.h> // malloc(), free() #include <stdlib.h> // malloc(), free()
#include <stdio.h> // printf(), fprintf() #include <stdio.h> // printf(), fprintf()
#include <math.h> // Used for ... #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) #if defined(PLATFORM_ANDROID)
#include <jni.h> // Java native interface #include <jni.h> // Java native interface
@ -40,7 +41,7 @@
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
#include <emscripten/emscripten/html5.h>
#include <emscripten/html5.h>
#endif #endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -78,7 +79,7 @@ typedef struct {
static GestureType gestureType = TYPE_MOTIONLESS; static GestureType gestureType = TYPE_MOTIONLESS;
// Gestures detection variables // Gestures detection variables
static int32_t touchId;
//static int32_t touchId; // Not used...
// Event // Event
static int64_t eventTime = 0; 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; else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) gestureEvent.action = MOVE;
// Points // Points
gestureEvent.pointCount = event->numTouches;
gestureEvent.pointCount = touchEvent->numTouches;
// Position // Position
gestureEvent.position[0] = (Vector2){ touchEvent->touches[0].canvasX, touchEvent->touches[0].canvasY }; gestureEvent.position[0] = (Vector2){ touchEvent->touches[0].canvasX, touchEvent->touches[0].canvasY };
gestureEvent.position[1] = (Vector2){ touchEvent->touches[1].canvasX, touchEvent->touches[1].canvasY }; gestureEvent.position[1] = (Vector2){ touchEvent->touches[1].canvasX, touchEvent->touches[1].canvasY };
ProcessMotionEvent(gestureEvent); ProcessMotionEvent(gestureEvent);
return 1; return 1;

+ 1
- 1
src/raylib.h View File

@ -437,7 +437,7 @@ void HideCursor(void); // Hides cursor
bool IsCursorHidden(void); // Returns true if cursor is not visible bool IsCursorHidden(void); // Returns true if cursor is not visible
#endif #endif
#if defined(PLATFORM_DESKTOP)
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available
Vector2 GetGamepadMovement(int gamepad); // Return axis movement vector for a gamepad 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 bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once

+ 3
- 3
src/raymath.c View File

@ -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; 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 else
{ {
float halfTheta = acos(cosHalfTheta); float halfTheta = acos(cosHalfTheta);
float sinHalfTheta = sqrt(1.0f - cosHalfTheta*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.x = (q1.x*0.5f + q2.x*0.5f);
result.y = (q1.y*0.5f + q2.y*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 // Returns the axis and the angle for a given quaternion
void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle) 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 }; Vector3 resAxis = { 0, 0, 0 };
float resAngle = 0; float resAngle = 0;

+ 2
- 0
src/rlgl.c View File

@ -1411,12 +1411,14 @@ Vector3 rlglUnproject(Vector3 source, Matrix proj, Matrix view)
//glGetIntegerv(GL_VIEWPORT, viewport); //glGetIntegerv(GL_VIEWPORT, viewport);
// Viewport data // Viewport data
/*
int x = 0; int x = 0;
int y = 0; int y = 0;
int width = GetScreenWidth(); int width = GetScreenWidth();
int height = GetScreenHeight(); int height = GetScreenHeight();
float minDepth = 0.0f; float minDepth = 0.0f;
float maxDepth = 1.0f; float maxDepth = 1.0f;
*/
/* /*
Matrix modelviewprojection = MatrixMultiply(modelview, projection); Matrix modelviewprojection = MatrixMultiply(modelview, projection);
MatrixInvert(&modelviewprojection); MatrixInvert(&modelviewprojection);

+ 2
- 2
src/shapes.c View File

@ -395,8 +395,8 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
{ {
bool collision = false; 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; if ((dx <= (rec.width/2 + radius)) && (dy <= (rec.height/2 + radius))) collision = true;

Loading…
Cancel
Save