Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Utils.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
13#ifndef ENGINE_UTILS
14#define ENGINE_UTILS
15
16namespace Engine {
29 typedef enum {
30 FAILURE = -1,
31 SUCCESS = -2,
32 WARNING = -3
33 } Success;
34
40 typedef struct {
41 unsigned char* data = nullptr;
42 int size = 0;
43 unsigned char req_state = 0;
45
49 struct Vec2f {
50 float x;
51 float y;
52
53 // /**
54 // * Assign a Vec2f
55 // */
56 // Vec2f operator=(const Vec2f& rhs);
57
61 Vec2f operator+(const Vec2f& rhs);
62
63 // /**
64 // * Subtract two Vec2f objects
65 // */
66 // Vec2f operator-(const Vec2f& rhs);
67
71 Vec2f operator*(const float& rhs);
72
76 Vec2f operator*(const Vec2f& rhs);
77
78 // /**
79 // * Dot product calculation
80 // */
81 // Vec2f operator*(const Vec2f& rhs);
82
83 // /**
84 // * Scalar division
85 // */
86 // Vec2f operator/(const float& rhs);
87
88 // /**
89 // * Negate a Vec2f
90 // */
91 // Vec2f operator-();
92 };
93
97 struct Vec3f {
98 float x;
99 float y;
100 float z;
101
105 Vec3f operator+(const Vec3f& rhs);
106
110 Vec3f operator*(const float& rhs);
111
115 Vec3f operator*(const Vec3f& rhs);
116
120 float lengthSquared();
121
122 bool operator==(const Vec3f& rhs);
123 };
124
128 struct Color {
129 unsigned char r;
130 unsigned char g;
131 unsigned char b;
132 unsigned char a;
133 };
134
142 Vec2f Rotate(Vec2f v, float angle);
143
151 Vec3f Rotate(Vec3f v, Vec3f angle);
152
161 float InvSQRT(float x);
162}
163
164#endif
float InvSQRT(float x)
returns the inverse square root of a float
Definition Utils.cpp:69
Vec2f Rotate(Vec2f v, float angle)
Rotates a 2D vector by an angle.
Definition Utils.cpp:50
A struct used to manage asset pulling.
Definition Utils.hpp:40
A color struct with 4 components: RGBA.
Definition Utils.hpp:128
A 2D vector struct with overloaded operators.
Definition Utils.hpp:49
Vec2f operator+(const Vec2f &rhs)
Add two Vec2f objects together.
Definition Utils.cpp:14
Vec2f operator*(const float &rhs)
Compute scalar multiplication.
Definition Utils.cpp:18
A 3D vector struct with overloaded operators.
Definition Utils.hpp:97
Vec3f operator*(const float &rhs)
Compute scalar multiplication.
Definition Utils.cpp:32
Vec3f operator+(const Vec3f &rhs)
Adds two Vec3f objects.
Definition Utils.cpp:28
float lengthSquared()
Returns the length of the vector.
Definition Utils.cpp:40