aboutsummaryrefslogtreecommitdiff
path: root/src/core.c
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-03-05 13:05:45 +0100
committerraysan5 <raysan5@gmail.com>2016-03-05 13:05:45 +0100
commitd8bd8634ab7d5179cb1481206176af1f8e592e75 (patch)
tree1b22e39d70514808acbef6f7b2dcd2d5a50f3346 /src/core.c
parentdcbf2a0e0c904870ac3ac59a3623a3954ab0243f (diff)
downloadraylib-d8bd8634ab7d5179cb1481206176af1f8e592e75.tar.gz
raylib-d8bd8634ab7d5179cb1481206176af1f8e592e75.zip
3d Camera: Added support for field-of-view Y
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core.c b/src/core.c
index 259e1f29..a8cc593a 100644
--- a/src/core.c
+++ b/src/core.c
@@ -609,10 +609,10 @@ void Begin3dMode(Camera camera)
rlPushMatrix(); // Save previous matrix, which contains the settings for the 2d ortho projection
rlLoadIdentity(); // Reset current matrix (PROJECTION)
-
+
// Setup perspective projection
float aspect = (float)screenWidth/(float)screenHeight;
- double top = 0.01*tan(45.0*PI/360.0);
+ double top = 0.01*tan(camera.fovy*PI/360.0);
double right = top*aspect;
// NOTE: zNear and zFar values are important when computing depth buffer values
@@ -883,7 +883,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
TraceLog(DEBUG, "Device coordinates: (%f, %f, %f)", deviceCoords.x, deviceCoords.y, deviceCoords.z);
// Calculate projection matrix (from perspective instead of frustum)
- Matrix matProj = MatrixPerspective(45.0, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
+ Matrix matProj = MatrixPerspective(camera.fovy, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0);
// Calculate view matrix from camera look at
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
@@ -936,7 +936,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera)
Vector2 WorldToScreen(Vector3 position, Camera camera)
{
// Calculate projection matrix (from perspective instead of frustum
- Matrix matProj = MatrixPerspective(45.0f, (float)((float)GetScreenWidth() / (float)GetScreenHeight()), 0.01f, 1000.0f);
+ Matrix matProj = MatrixPerspective(camera.fovy, (double)GetScreenWidth()/(double)GetScreenHeight(), 0.01, 1000.0);
// Calculate view matrix from camera look at (and transpose it)
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
@@ -1752,8 +1752,8 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int
// Normalize gestureEvent.position[0] for screenWidth and screenHeight
gestureEvent.position[0].x /= (float)GetScreenWidth();
gestureEvent.position[0].y /= (float)GetScreenHeight();
-
- // Gesture data is sent to gestures system for processing
+
+ // Gesture data is sent to gestures system for processing
ProcessGestureEvent(gestureEvent);
#endif
}
@@ -1890,7 +1890,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
// TODO: GPU assets reload in case of lost focus (lost context)
// NOTE: This problem has been solved just unbinding and rebinding context from display
- /*
+ /*
if (assetsReloadRequired)
{
for (int i = 0; i < assetsCount; i++)
@@ -2471,9 +2471,9 @@ static void *GamepadThread(void *arg)
const int joystickAxisY = 1;
// Read gamepad event
- struct js_event gamepadEvent;
+ struct js_event gamepadEvent;
- while (1)
+ while (1)
{
if (read(gamepadStream, &gamepadEvent, sizeof(struct js_event)) == (int)sizeof(struct js_event))
{
@@ -2507,7 +2507,7 @@ static void *GamepadThread(void *arg)
*/
}
}
- }
+ }
return NULL;
}