Gamedev Framework (gf)
0.1.0
A C++11 framework for 2D games
|
All the core generic classes and functions. More...
Classes | |
class | gf::Array2D< T > |
A two-dimensional array. More... | |
class | gf::Clock |
Utility class that measures the elapsed time. More... | |
class | gf::Direction |
Cardinal and ordinal directions. More... | |
class | gf::InputStream |
Abstract class for custom file input streams. More... | |
class | gf::FileInputStream |
File based input stream. More... | |
class | gf::MemoryInputStream |
Memory based input stream. More... | |
class | gf::Library |
A class to represent the library. More... | |
struct | gf::Library::Version |
Information about version. More... | |
class | gf::Log |
Logging functions. More... | |
struct | gf::Matrix< T, ROWS, COLS > |
General purpose math matrix. More... | |
struct | gf::Matrix< T, 2, 2 > |
A 2x2 matrix. More... | |
struct | gf::Matrix< T, 3, 3 > |
A 3x3 matrix. More... | |
struct | gf::Matrix< T, 4, 4 > |
A 4x4 matrix. More... | |
class | gf::GradientNoise |
Gradient noise. More... | |
class | gf::FractalNoise |
Fractal noise. More... | |
class | gf::PerlinNoise |
Perlin noise. More... | |
class | gf::SimplexNoise |
Simplex noise. More... | |
class | gf::OpenSimplexNoise |
OpenSimplex noise. More... | |
class | gf::Queue< T > |
A simple concurrent queue. More... | |
class | gf::Random |
A random engine. More... | |
struct | gf::Range< T > |
A half-open range of values. More... | |
struct | gf::Range< T >::Iterator |
A range iterator. More... | |
struct | gf::Rect< T > |
Utility class for manipulating 2D axis aligned rectangles. More... | |
class | gf::Singleton< T > |
A singleton that wraps a pointer provided by a storage. More... | |
class | gf::SingletonStorage< T > |
A storage for a singleton. More... | |
class | gf::SystemInfo |
A class for system info. More... | |
class | gf::Time |
Represents a time value. More... | |
struct | gf::Vector< T, N > |
General purpose math vector. More... | |
struct | gf::Vector< T, 2 > |
A 2D vector. More... | |
struct | gf::Vector< T, 3 > |
A 3D vector. More... | |
struct | gf::Vector< T, 4 > |
A 4D vector. More... | |
Typedefs | |
using | gf::Path = boost::filesystem::path |
A path in the filesystem. More... | |
typedef uint64_t | gf::Id |
An identifier. More... | |
template<typename T > | |
using | gf::Step = T(*)(T) |
A step is a function with special features. More... | |
typedef Matrix< float, 2, 2 > | gf::Matrix2f |
A float square matrix of size 2. More... | |
typedef Matrix< float, 3, 3 > | gf::Matrix3f |
A float square matrix of size 3. More... | |
typedef Matrix< float, 4, 4 > | gf::Matrix4f |
A float square matrix of size 4. More... | |
typedef Range< float > | gf::RangeF |
A float range. More... | |
typedef Range< int > | gf::RangeI |
A int range. More... | |
typedef Range< unsigned > | gf::RangeU |
A unsigned range. More... | |
typedef Range< std::size_t > | gf::RangeZ |
A std::size_t range. More... | |
typedef Rect< float > | gf::RectF |
A float rectangle. More... | |
typedef Rect< int > | gf::RectI |
A int rectangle. More... | |
typedef Rect< unsigned > | gf::RectU |
A unsigned rectangle. More... | |
typedef Rect< std::size_t > | gf::RectZ |
A std::size_t rectangle. More... | |
typedef Vector< float, 2 > | gf::Vector2f |
A float vector with 2 components. More... | |
typedef Vector< float, 3 > | gf::Vector3f |
A float vector with 3 components. More... | |
typedef Vector< float, 4 > | gf::Vector4f |
A float vector with 4 components. More... | |
typedef Vector< double, 2 > | gf::Vector2d |
A double vector with 2 components. More... | |
typedef Vector< double, 3 > | gf::Vector3d |
A double vector with 3 components. More... | |
typedef Vector< double, 4 > | gf::Vector4d |
A double vector with 4 components. More... | |
typedef Vector< int, 2 > | gf::Vector2i |
A int vector with 2 components. More... | |
typedef Vector< int, 3 > | gf::Vector3i |
A int vector with 3 components. More... | |
typedef Vector< int, 4 > | gf::Vector4i |
A int vector with 4 components. More... | |
typedef Vector< unsigned, 2 > | gf::Vector2u |
A unsigned vector with 2 components. More... | |
typedef Vector< unsigned, 3 > | gf::Vector3u |
A unsigned vector with 3 components. More... | |
typedef Vector< unsigned, 4 > | gf::Vector4u |
A unsigned vector with 4 components. More... | |
typedef Vector< std::size_t, 2 > | gf::Vector2z |
A std::size_t vector with 2 components. More... | |
typedef Vector< std::size_t, 3 > | gf::Vector3z |
A std::size_t vector with 3 components. More... | |
typedef Vector< std::size_t, 4 > | gf::Vector4z |
A std::size_t vector with 4 components. More... | |
typedef Vector< bool, 2 > | gf::Vector2b |
A bool vector with 2 components. More... | |
typedef Vector< bool, 3 > | gf::Vector3b |
A bool vector with 3 components. More... | |
typedef Vector< bool, 4 > | gf::Vector4b |
A bool vector with 4 components. More... | |
typedef Vector< float, 3 > | gf::Color3f |
A float color vector with 3 components. More... | |
typedef Vector< float, 4 > | gf::Color4f |
A float color vector with 4 components. More... | |
typedef Vector< uint8_t, 3 > | gf::Color3u |
A uint8_t color vector with 3 components. More... | |
typedef Vector< uint8_t, 4 > | gf::Color4u |
A uint8_t color vector with 4 components. More... | |
Enumerations | |
enum | gf::Log::Level : int { gf::Log::Debug, gf::Log::Info, gf::Log::Warn, gf::Log::Error, gf::Log::Fatal } |
The severity level of the log. More... | |
enum | gf::Log::Category : int { gf::Log::General, gf::Log::Graphics, gf::Log::Network, gf::Log::Physics, gf::Log::Resources } |
The category of the log. More... | |
Functions | |
constexpr Id | gf::hash (const char *str, std::size_t sz) |
Get an identifier from a string. More... | |
Id | gf::hash (const std::string &str) |
Get an idenfitier from a string. More... | |
template<typename T > | |
constexpr T | gf::linearStep (T t) |
Linear step. More... | |
template<typename T > | |
constexpr T | gf::cubicStep (T t) |
Cubic step (smoothstep) More... | |
template<typename T > | |
constexpr T | gf::quinticStep (T t) |
Quintic step (smootherstep) More... | |
template<typename T > | |
T | gf::cosineStep (T t) |
Cosine step. More... | |
template<typename T , typename U > | |
T | gf::lerp (T lhs, T rhs, U t) |
Linear interpolation function. More... | |
template<typename T > | |
constexpr T | gf::clamp (T val, T lo, T hi) |
Clamping function. More... | |
template<typename T > | |
constexpr T | gf::square (T val) |
Square function. More... | |
Vector2f | gf::transform (const Matrix3f &mat, Vector2f point) |
Apply an affine transformation to a 2D point. More... | |
RectF | gf::transform (const Matrix3f &mat, const RectF &rect) |
Apply an affine transformaton to a rectangle. More... | |
Matrix3f | gf::translation (Vector2f offset) |
Get a translation matrix. More... | |
void | gf::translate (Matrix3f &mat, Vector2f offset) |
Combine the current transform with a translation. More... | |
Matrix3f | gf::rotation (float angle) |
Get a rotation matrix. More... | |
Matrix3f | gf::rotation (float angle, Vector2f center) |
Get a rotation matrix. More... | |
void | gf::rotate (Matrix3f &mat, float angle) |
Combine the current transform with a rotation. More... | |
void | gf::rotate (Matrix3f &mat, float angle, Vector2f center) |
Combine the current transform with a rotation. More... | |
Matrix3f | gf::scaling (Vector2f factor) |
Get a scaling matrix. More... | |
Matrix3f | gf::scaling (Vector2f factor, Vector2f center) |
Get a scaling matrix. More... | |
void | gf::scale (Matrix3f &mat, Vector2f factor) |
Combine the current transform with a scaling. More... | |
void | gf::scale (Matrix3f &mat, Vector2f factor, Vector2f center) |
Combine the current transform with a scaling. More... | |
Variables | |
constexpr Id | gf::InvalidId = 0 |
The invalid id (which is 0) More... | |
constexpr float | gf::Pi = 3.14159265358979323846f |
The \( \pi \) constant. More... | |
constexpr float | gf::Pi2 = Pi / 2 |
The \( \frac{\pi}{2} \) constant. More... | |
constexpr float | gf::Pi4 = Pi / 4 |
The \( \frac{\pi}{4} \) constant. More... | |
constexpr float | gf::Sqrt2 = 1.41421356237309504880f |
The \( \sqrt{2} \) constant. More... | |
constexpr float | gf::InvSqrt2 = 1 / Sqrt2 |
The \( \frac{1}{\sqrt{2}} \) constant. More... | |
All the core generic classes and functions.
typedef Vector<float, 3> gf::Color3f |
A float color vector with 3 components.
typedef Vector<uint8_t, 3> gf::Color3u |
A uint8_t color vector with 3 components.
typedef Vector<float, 4> gf::Color4f |
A float color vector with 4 components.
typedef Vector<uint8_t, 4> gf::Color4u |
A uint8_t color vector with 4 components.
typedef uint64_t gf::Id |
An identifier.
typedef Matrix<float, 2, 2> gf::Matrix2f |
A float square matrix of size 2.
typedef Matrix<float, 3, 3> gf::Matrix3f |
A float square matrix of size 3.
typedef Matrix<float, 4, 4> gf::Matrix4f |
A float square matrix of size 4.
using gf::Path = typedef boost::filesystem::path |
A path in the filesystem.
gf::Path is a simple typedef for boost::filesystem::path
. Boost.Filesystem will eventually be part of the C++17 standard. So, in the future, gf::Path will be a typedef for std::path
.
typedef Range<float> gf::RangeF |
A float range.
typedef Range<int> gf::RangeI |
A int range.
typedef Range<unsigned> gf::RangeU |
A unsigned range.
typedef Range<std::size_t> gf::RangeZ |
A std::size_t
range.
typedef Rect<float> gf::RectF |
A float
rectangle.
typedef Rect<int> gf::RectI |
A int
rectangle.
typedef Rect<unsigned> gf::RectU |
A unsigned
rectangle.
typedef Rect<std::size_t> gf::RectZ |
A std::size_t
rectangle.
using gf::Step = typedef T (*)(T) |
A step is a function with special features.
A step \( f \) is a (mathematical) function which has the following properties:
It can be used to smooth a linear interpolation.
typedef Vector<bool, 2> gf::Vector2b |
A bool vector with 2 components.
typedef Vector<double, 2> gf::Vector2d |
A double vector with 2 components.
typedef Vector<float, 2> gf::Vector2f |
A float vector with 2 components.
typedef Vector<int, 2> gf::Vector2i |
A int vector with 2 components.
typedef Vector<unsigned, 2> gf::Vector2u |
A unsigned vector with 2 components.
typedef Vector<std::size_t, 2> gf::Vector2z |
A std::size_t vector with 2 components.
typedef Vector<bool, 3> gf::Vector3b |
A bool vector with 3 components.
typedef Vector<double, 3> gf::Vector3d |
A double vector with 3 components.
typedef Vector<float, 3> gf::Vector3f |
A float vector with 3 components.
typedef Vector<int, 3> gf::Vector3i |
A int vector with 3 components.
typedef Vector<unsigned, 3> gf::Vector3u |
A unsigned vector with 3 components.
typedef Vector<std::size_t, 3> gf::Vector3z |
A std::size_t vector with 3 components.
typedef Vector<bool, 4> gf::Vector4b |
A bool vector with 4 components.
typedef Vector<double, 4> gf::Vector4d |
A double vector with 4 components.
typedef Vector<float, 4> gf::Vector4f |
A float vector with 4 components.
typedef Vector<int, 4> gf::Vector4i |
A int vector with 4 components.
typedef Vector<unsigned, 4> gf::Vector4u |
A unsigned vector with 4 components.
typedef Vector<std::size_t, 4> gf::Vector4z |
A std::size_t vector with 4 components.
enum gf::Log::Category : int |
enum gf::Log::Level : int |
constexpr T gf::clamp | ( | T | val, |
T | lo, | ||
T | hi | ||
) |
Clamping function.
This function takes a value and returns it if it is in a specified range. If not, the returned value is the nearest value in the range.
val | The value to clamp |
lo | The minimum accepted value |
hi | The maximum accepted value |
|
inline |
constexpr T gf::cubicStep | ( | T | t | ) |
Cubic step (smoothstep)
\[ f(t) = -2 * t^3 + 3 * t^2 \]
Compared to a step, it has the following properties:
This function is also known as smoothstep
constexpr Id gf::hash | ( | const char * | str, |
std::size_t | sz | ||
) |
Get an identifier from a string.
The hash is a Fowler–Noll–Vo 1a hash. This function is mainly for internal use. You should instead use the user-defined literal _id
.
Example:
str | The string |
sz | The size of the string |
|
inline |
Get an idenfitier from a string.
The hash is a Fowler–Noll–Vo 1a hash. This function can be used for computing an id at runtime. For computing an id from a string at compile time, you should use the the user-defined literal _id
.
|
inline |
Linear interpolation function.
This functions returns an interpolated value between two values lhs
and rhs
according to a parameter \( t \). When \( t = 0 \) then lhs
is returned, and when \( t = 1 \) then rhs
is returned.
lhs | The first value |
rhs | The second value |
t | The interpolation parameter, generally in the interval \( [0,1] \) |
constexpr T gf::linearStep | ( | T | t | ) |
constexpr T gf::quinticStep | ( | T | t | ) |
Quintic step (smootherstep)
\[ f(t) = 6 * t^5 - 15 * t^4 + 10 * t^3 \]
Compared to a step, it has the following properties:
This function is also known as smootherstep
void gf::rotate | ( | Matrix3f & | mat, |
float | angle | ||
) |
Combine the current transform with a rotation.
mat | The current transform |
angle | The angle of the rotation (in radians) |
void gf::rotate | ( | Matrix3f & | mat, |
float | angle, | ||
Vector2f | center | ||
) |
Combine the current transform with a rotation.
mat | The current transform |
angle | The angle of the rotation (in radians) |
center | The center of the rotation |
|
inline |
Get a rotation matrix.
angle | The angle of the rotation (in radians) |
angle
radians
|
inline |
Get a rotation matrix.
angle | The angle of the rotation (in radians) |
center | The center of the rotation |
angle
radians of origin center
void gf::scale | ( | Matrix3f & | mat, |
Vector2f | factor | ||
) |
Combine the current transform with a scaling.
mat | The current transform |
factor | The scaling factor |
void gf::scale | ( | Matrix3f & | mat, |
Vector2f | factor, | ||
Vector2f | center | ||
) |
Combine the current transform with a scaling.
mat | The current transform |
factor | The scaling factor |
center | The center of the scaling |
|
inline |
Get a scaling matrix.
factor | The scaling factor |
factor
|
inline |
Get a scaling matrix.
factor | The scaling factor |
center | The center of the scaling |
factor
of origin center
constexpr T gf::square | ( | T | val | ) |
Square function.
For a value \( x \), the square value is \( x^2 \).
val | A value |
|
inline |
Apply an affine transformation to a 2D point.
mat | The transformation matrix |
point | The point to transform |
RectF gf::transform | ( | const Matrix3f & | mat, |
const RectF & | rect | ||
) |
Apply an affine transformaton to a rectangle.
The resulting rectangle is axis-aligned
mat | The transformation matrix |
rect | The rectangle to transform |
void gf::translate | ( | Matrix3f & | mat, |
Vector2f | offset | ||
) |
Combine the current transform with a translation.
mat | The current transform |
offset | The offset of the translation |
|
inline |
Get a translation matrix.
offset | The offset of the translation |
offset
constexpr Id gf::InvalidId = 0 |
The invalid id (which is 0)
constexpr float gf::InvSqrt2 = 1 / Sqrt2 |
The \( \frac{1}{\sqrt{2}} \) constant.
constexpr float gf::Pi = 3.14159265358979323846f |
The \( \pi \) constant.
constexpr float gf::Pi2 = Pi / 2 |
The \( \frac{\pi}{2} \) constant.
constexpr float gf::Pi4 = Pi / 4 |
The \( \frac{\pi}{4} \) constant.
constexpr float gf::Sqrt2 = 1.41421356237309504880f |
The \( \sqrt{2} \) constant.