MSVC and TDMGCC fixes

This commit is contained in:
Charles J. Cliffe
2015-07-31 18:21:30 -04:00
parent c1774ee96a
commit 3fbb1def49
15 changed files with 219 additions and 211 deletions
+5
View File
@@ -38,4 +38,9 @@ namespace CubicVR {
}
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#endif
+6 -5
View File
@@ -10,6 +10,7 @@
#define CubicVR2_frustum_h
#include <vector>
#include "cubic_types.h"
#include "mat4.h"
#include "vec3.h"
#include "vec4.h"
@@ -75,14 +76,14 @@ namespace CubicVR {
//Sphere
__float fov = 1 / pMatrix[5];
__float near = -planes[PLANE_NEAR][3];
__float far = planes[PLANE_FAR][3];
__float view_length = far - near;
__float znear = -planes[PLANE_NEAR][3];
__float zfar = planes[PLANE_FAR][3];
__float view_length = zfar - znear;
__float height = view_length * fov;
__float width = height;
vec3 P(0, 0, near + view_length * 0.5f);
vec3 Q(width, height, near + view_length);
vec3 P(0, 0, znear + view_length * 0.5f);
vec3 Q(width, height, znear + view_length);
vec3 diff = vec3::subtract(P, Q);
__float diff_mag = vec3::length(diff);
+1
View File
@@ -11,6 +11,7 @@
#include <iostream>
#include "vec3.h"
#include <cstring>
namespace CubicVR {
+4 -4
View File
@@ -72,15 +72,15 @@ namespace CubicVR {
return mOut;
}
static mat4 perspective(__float fovy, __float aspect, __float near, __float far) {
static mat4 perspective(__float fovy, __float aspect, __float znear, __float zfar) {
__float yFac = tan(fovy * (float)M_PI / 360.0f);
__float xFac = yFac * aspect;
return mat4(
1.0f / xFac, 0, 0, 0, 0, 1.0f / yFac, 0, 0, 0, 0, -(far + near) / (far - near), -1, 0, 0, -(2.0f * far * near) / (far - near), 0);
1.0f / xFac, 0, 0, 0, 0, 1.0f / yFac, 0, 0, 0, 0, -(zfar + znear) / (zfar - znear), -1, 0, 0, -(2.0f * zfar * znear) / (zfar - znear), 0);
};
static mat4 ortho(__float left,__float right,__float bottom,__float top,__float near,__float far) {
return mat4(2.0f / (right - left), 0, 0, 0, 0, 2.0f / (top - bottom), 0, 0, 0, 0, -2.0f / (far - near), 0, -(left + right) / (right - left), -(top + bottom) / (top - bottom), -(far + near) / (far - near), 1);
static mat4 ortho(__float left,__float right,__float bottom,__float top,__float znear,__float zfar) {
return mat4(2.0f / (right - left), 0, 0, 0, 0, 2.0f / (top - bottom), 0, 0, 0, 0, -2.0f / (zfar - znear), 0, -(left + right) / (right - left), -(top + bottom) / (top - bottom), -(zfar + znear) / (zfar - znear), 1);
};
static __float determinant(mat4 m) {