Added missing component on Perspective matrix

This commit is contained in:
Zak Strange
2016-03-24 21:05:43 -07:00
parent 4256034f7f
commit 2b44bdc9d5

View File

@@ -73,6 +73,7 @@ extern "C" {
#endif #endif
#define Pi32 3.14159265359f #define Pi32 3.14159265359f
#define HMM_PI 3.14159265358979323846
typedef union vec2 typedef union vec2
{ {
@@ -680,10 +681,10 @@ MultiplyMat4(mat4 Left, mat4 Right)
CurrentMatrice < 4; CurrentMatrice < 4;
++CurrentMatrice) ++CurrentMatrice)
{ {
Sum += Left.Elements[Rows][CurrentMatrice] * Right.Elements[CurrentMatrice][Columns]; Sum += Right.Elements[Rows][CurrentMatrice] * Left.Elements[CurrentMatrice][Columns];
} }
Result.Elements[Rows][Columns] = Sum; Result.Elements[Columns][Rows] = Sum;
} }
} }
@@ -706,8 +707,6 @@ Orthographic(float Left, float Right, float Bottom, float Top, float Near, float
return(Result); return(Result);
} }
#define HMM_PI 3.14159265358979323846
HMMDEF mat4 HMMDEF mat4
Perspective(float FOV, float AspectRatio, float Near, float Far) Perspective(float FOV, float AspectRatio, float Near, float Far)
{ {
@@ -718,7 +717,7 @@ Perspective(float FOV, float AspectRatio, float Near, float Far)
Result.Elements[2][3] = -1.0f; Result.Elements[2][3] = -1.0f;
Result.Elements[2][2] = -(Far + Near) / (Far - Near); Result.Elements[2][2] = -(Far + Near) / (Far - Near);
Result.Elements[3][2] = -(2.0f * Far * Near) / (Far - Near); Result.Elements[3][2] = -(2.0f * Far * Near) / (Far - Near);
Result.Elements[3][3] = 0; Result.Elements[3][3] = 0.0f;
return(Result); return(Result);
} }