Added operator overloading

This commit is contained in:
Zak Strange
2016-03-13 15:19:26 -07:00
parent f62ec8a09a
commit a2700e4a22
3 changed files with 99 additions and 3 deletions

View File

@@ -531,6 +531,8 @@ HINLINE vec2
Multiply(vec2 Left, vec2 Right)
{
vec2 Result = MultiplyV2(Left, Right);
return(Result);
}
HINLINE vec3
@@ -553,7 +555,7 @@ HINLINE vec2
Divide(vec2 Left, vec2 Right)
{
vec2 Result = DivideV2(Left, Right);
return(Result);
}
@@ -573,6 +575,91 @@ Divide(vec4 Left, vec4 Right)
return(Result);
}
vec2 operator+(vec2 Left, vec2 Right)
{
vec2 Result = Add(Left, Right);
return(Result);
}
vec3 operator+(vec3 Left, vec3 Right)
{
vec3 Result = Add(Left, Right);
return(Result);
}
vec4 operator+(vec4 Left, vec4 Right)
{
vec4 Result = Add(Left, Right);
return(Result);
}
vec2 operator-(vec2 Left, vec2 Right)
{
vec2 Result = Subtract(Left, Right);
return(Result);
}
vec3 operator-(vec3 Left, vec3 Right)
{
vec3 Result = Subtract(Left, Right);
return(Result);
}
vec4 operator-(vec4 Left, vec4 Right)
{
vec4 Result = Subtract(Left, Right);
return(Result);
}
vec2 operator*(vec2 Left, vec2 Right)
{
vec2 Result = Multiply(Left, Right);
return(Result);
}
vec3 operator*(vec3 Left, vec3 Right)
{
vec3 Result = Multiply(Left, Right);
return(Result);
}
vec4 operator*(vec4 Left, vec4 Right)
{
vec4 Result = Multiply(Left, Right);
return(Result);
}
vec2 operator/(vec2 Left, vec2 Right)
{
vec2 Result = Divide(Left, Right);
return(Result);
}
vec3 operator/(vec3 Left, vec3 Right)
{
vec3 Result = Divide(Left, Right);
return(Result);
}
vec4 operator/(vec4 Left, vec4 Right)
{
vec4 Result = Divide(Left, Right);
return(Result);
}
#endif /* HANDMADE_MATH_CPP_MODE */
#endif /* HANDMADE_MATH_IMPLEMENTATION */

View File

@@ -5,9 +5,9 @@ IF NOT EXIST build mkdir build
pushd build
REM C Build
cl -FC -nologo -Z7 -Tc ../main.c
REM cl -FC -nologo -Z7 -Tc ../main.c
REM C++ Build
REM cl -nologo -Zi ../main.cpp
cl -nologo -Zi -FC ../main.cpp
popd

View File

@@ -2,8 +2,17 @@
#define HANDMADE_MATH_CPP_MODE
#include "HandmadeMath.h"
#include <stdio.h>
#include <conio.h>
int
main(int ArgC, char **ArgV)
{
vec2 TestVector1 = V2(50.0f, 36.0f);
vec2 TestVector2 = V2(5.0f, 6.0f);
vec2 Result = TestVector1 - TestVector2;
_getch();
return(0);
}