Gamedev Framework (gf)  0.1.0
A C++11 framework for 2D games
Classes | Typedefs | Enumerations | Functions | Variables
Core classes and functions

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 >
gf::cosineStep (T t)
 Cosine step. More...
 
template<typename T , typename U >
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...
 

Detailed Description

All the core generic classes and functions.

Typedef Documentation

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.

See also
Matrix<T, 2, 2>
typedef Matrix<float, 3, 3> gf::Matrix3f

A float square matrix of size 3.

See also
Matrix<T, 3, 3>
typedef Matrix<float, 4, 4> gf::Matrix4f

A float square matrix of size 4.

See also
Matrix<T, 4, 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.

template<typename T >
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:

  • \( f(0) = 0 \)
  • \( f(1) = 1 \)

It can be used to smooth a linear interpolation.

gf::Vector2f point1 = ...;
gf::Vector2f point2 = ...;
float t = ...;
gf::Step<float> step = gf::cubicStep<float>;
gf::Vector2f interpolatedPoint = gf::lerp(point1, point2, t);
gf::Vector2f smoothedInterpolatedPoint = gf::lerp(point1, point2, step(t));
See also
linearStep(), cubicStep(), quinticStep(), cosineStep()
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.

Enumeration Type Documentation

enum gf::Log::Category : int

The category of the log.

Enumerator
General 

The general category.

Graphics 

The graphics category.

Network 

The network category.

Physics 

The physics category.

Resources 

The resources category.

enum gf::Log::Level : int

The severity level of the log.

Enumerator
Debug 

The debug level.

Info 

The info level.

Warn 

The warn level.

Error 

The error level.

Fatal 

The fatal level.

Function Documentation

template<typename T >
constexpr T gf::clamp ( val,
lo,
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.

Parameters
valThe value to clamp
loThe minimum accepted value
hiThe maximum accepted value
Returns
The clamped value
template<typename T >
T gf::cosineStep ( t)
inline

Cosine step.

\[ f(t) = (1 - \cos(\pi * t)) * 0.5 \]

See also
gf::Step
template<typename T >
constexpr T gf::cubicStep ( t)

Cubic step (smoothstep)

\[ f(t) = -2 * t^3 + 3 * t^2 \]

Compared to a step, it has the following properties:

  • \( f'(0) = 0 \)
  • \( f'(1) = 0 \)

This function is also known as smoothstep

See also
gf::Step
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:

gf::Id id = "A string"_id; // computed at compile time
Parameters
strThe string
szThe size of the string
Id gf::hash ( const std::string &  str)
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.

template<typename T , typename U >
T gf::lerp ( lhs,
rhs,
t 
)
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.

Parameters
lhsThe first value
rhsThe second value
tThe interpolation parameter, generally in the interval \( [0,1] \)
Returns
A value between the first and second value
template<typename T >
constexpr T gf::linearStep ( t)

Linear step.

\[ f(t) = t \]

See also
gf::Step
template<typename T >
constexpr T gf::quinticStep ( t)

Quintic step (smootherstep)

\[ f(t) = 6 * t^5 - 15 * t^4 + 10 * t^3 \]

Compared to a step, it has the following properties:

  • \( f'(0) = 0 \)
  • \( f'(1) = 0 \)
  • \( f''(0) = 0 \)
  • \( f''(1) = 0 \)

This function is also known as smootherstep

See also
gf::Step
void gf::rotate ( Matrix3f &  mat,
float  angle 
)

Combine the current transform with a rotation.

Parameters
matThe current transform
angleThe angle of the rotation (in radians)
void gf::rotate ( Matrix3f &  mat,
float  angle,
Vector2f  center 
)

Combine the current transform with a rotation.

Parameters
matThe current transform
angleThe angle of the rotation (in radians)
centerThe center of the rotation
Matrix3f gf::rotation ( float  angle)
inline

Get a rotation matrix.

Parameters
angleThe angle of the rotation (in radians)
Returns
A rotation of angle radians
Matrix3f gf::rotation ( float  angle,
Vector2f  center 
)
inline

Get a rotation matrix.

Parameters
angleThe angle of the rotation (in radians)
centerThe center of the rotation
Returns
A rotation of angle radians of origin center
void gf::scale ( Matrix3f &  mat,
Vector2f  factor 
)

Combine the current transform with a scaling.

Parameters
matThe current transform
factorThe scaling factor
void gf::scale ( Matrix3f &  mat,
Vector2f  factor,
Vector2f  center 
)

Combine the current transform with a scaling.

Parameters
matThe current transform
factorThe scaling factor
centerThe center of the scaling
Matrix3f gf::scaling ( Vector2f  factor)
inline

Get a scaling matrix.

Parameters
factorThe scaling factor
Returns
A scaling by factor
Matrix3f gf::scaling ( Vector2f  factor,
Vector2f  center 
)
inline

Get a scaling matrix.

Parameters
factorThe scaling factor
centerThe center of the scaling
Returns
A scaling by factor of origin center
template<typename T >
constexpr T gf::square ( val)

Square function.

For a value \( x \), the square value is \( x^2 \).

Parameters
valA value
Returns
The square of the value
Vector2f gf::transform ( const Matrix3f &  mat,
Vector2f  point 
)
inline

Apply an affine transformation to a 2D point.

Parameters
matThe transformation matrix
pointThe point to transform
Returns
The transformed point
RectF gf::transform ( const Matrix3f &  mat,
const RectF &  rect 
)

Apply an affine transformaton to a rectangle.

The resulting rectangle is axis-aligned

Parameters
matThe transformation matrix
rectThe rectangle to transform
Returns
The transformed rectangle
void gf::translate ( Matrix3f &  mat,
Vector2f  offset 
)

Combine the current transform with a translation.

Parameters
matThe current transform
offsetThe offset of the translation
Matrix3f gf::translation ( Vector2f  offset)
inline

Get a translation matrix.

Parameters
offsetThe offset of the translation
Returns
A translation by offset

Variable Documentation

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.