RetroArch
Classes | Macros | Typedefs
matrix_4x4.h File Reference
#include <retro_common_api.h>
#include <math.h>
#include <gfx/math/vector_3.h>
Include dependency graph for matrix_4x4.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  math_matrix_4x4
 

Macros

#define MAT_ELEM_4X4(mat, row, column)   ((mat).data[4 * (column) + (row)])
 
#define matrix_4x4_copy(dst, src)
 
#define matrix_4x4_identity(mat)
 
#define matrix_4x4_transpose(out, in)
 
#define matrix_4x4_rotate_x(mat, radians)
 
#define matrix_4x4_rotate_y(mat, radians)
 
#define matrix_4x4_rotate_z(mat, radians)
 
#define matrix_4x4_ortho(mat, left, right, bottom, top, znear, zfar)
 
#define matrix_4x4_lookat(out, eye, center, up)
 
#define matrix_4x4_multiply(out, a, b)
 
#define matrix_4x4_scale(mat, x, y, z)
 
#define matrix_4x4_translate(mat, x, y, z)
 
#define matrix_4x4_projection(mat, y_fov, aspect, znear, zfar)
 

Typedefs

typedef RETRO_BEGIN_DECLS struct math_matrix_4x4 math_matrix_4x4
 

Macro Definition Documentation

◆ MAT_ELEM_4X4

#define MAT_ELEM_4X4 (   mat,
  row,
  column 
)    ((mat).data[4 * (column) + (row)])

◆ matrix_4x4_copy

#define matrix_4x4_copy (   dst,
  src 
)
Value:
MAT_ELEM_4X4(dst, 0, 0) = MAT_ELEM_4X4(src, 0, 0); \
MAT_ELEM_4X4(dst, 0, 1) = MAT_ELEM_4X4(src, 0, 1); \
MAT_ELEM_4X4(dst, 0, 2) = MAT_ELEM_4X4(src, 0, 2); \
MAT_ELEM_4X4(dst, 0, 3) = MAT_ELEM_4X4(src, 0, 3); \
MAT_ELEM_4X4(dst, 1, 0) = MAT_ELEM_4X4(src, 1, 0); \
MAT_ELEM_4X4(dst, 1, 1) = MAT_ELEM_4X4(src, 1, 1); \
MAT_ELEM_4X4(dst, 1, 2) = MAT_ELEM_4X4(src, 1, 2); \
MAT_ELEM_4X4(dst, 1, 3) = MAT_ELEM_4X4(src, 1, 3); \
MAT_ELEM_4X4(dst, 2, 0) = MAT_ELEM_4X4(src, 2, 0); \
MAT_ELEM_4X4(dst, 2, 1) = MAT_ELEM_4X4(src, 2, 1); \
MAT_ELEM_4X4(dst, 2, 2) = MAT_ELEM_4X4(src, 2, 2); \
MAT_ELEM_4X4(dst, 2, 3) = MAT_ELEM_4X4(src, 2, 3); \
MAT_ELEM_4X4(dst, 3, 0) = MAT_ELEM_4X4(src, 3, 0); \
MAT_ELEM_4X4(dst, 3, 1) = MAT_ELEM_4X4(src, 3, 1); \
MAT_ELEM_4X4(dst, 3, 2) = MAT_ELEM_4X4(src, 3, 2); \
MAT_ELEM_4X4(dst, 3, 3) = MAT_ELEM_4X4(src, 3, 3)
GLenum src
Definition: glext.h:6980
GLenum GLenum dst
Definition: glext.h:6980
#define MAT_ELEM_4X4(mat, row, column)
Definition: matrix_4x4.h:36

◆ matrix_4x4_identity

#define matrix_4x4_identity (   mat)
Value:
MAT_ELEM_4X4(mat, 0, 0) = 1.0f; \
MAT_ELEM_4X4(mat, 0, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 1) = 1.0f; \
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 2) = 1.0f; \
MAT_ELEM_4X4(mat, 2, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 3) = 1.0f
#define MAT_ELEM_4X4(mat, row, column)
Definition: matrix_4x4.h:36

◆ matrix_4x4_lookat

#define matrix_4x4_lookat (   out,
  eye,
  center,
  up 
)
Value:
{ \
vec3_t zaxis; /* the "forward" vector */ \
vec3_t xaxis; /* the "right" vector */ \
vec3_t yaxis; /* the "up" vector */ \
vec3_copy(zaxis, center); \
vec3_subtract(zaxis, eye); \
vec3_normalize(zaxis); \
vec3_cross(xaxis, zaxis, up); \
vec3_normalize(xaxis); \
vec3_cross(yaxis, xaxis, zaxis); \
MAT_ELEM_4X4(out, 0, 0) = xaxis[0]; \
MAT_ELEM_4X4(out, 0, 1) = yaxis[0]; \
MAT_ELEM_4X4(out, 0, 2) = -zaxis[0]; \
MAT_ELEM_4X4(out, 0, 3) = 0.0; \
MAT_ELEM_4X4(out, 1, 0) = xaxis[1]; \
MAT_ELEM_4X4(out, 1, 1) = yaxis[1]; \
MAT_ELEM_4X4(out, 1, 2) = -zaxis[1]; \
MAT_ELEM_4X4(out, 1, 3) = 0.0f; \
MAT_ELEM_4X4(out, 2, 0) = xaxis[2]; \
MAT_ELEM_4X4(out, 2, 1) = yaxis[2]; \
MAT_ELEM_4X4(out, 2, 2) = -zaxis[2]; \
MAT_ELEM_4X4(out, 2, 3) = 0.0f; \
MAT_ELEM_4X4(out, 3, 0) = -(xaxis[0] * eye[0] + xaxis[1] * eye[1] + xaxis[2] * eye[2]); \
MAT_ELEM_4X4(out, 3, 1) = -(yaxis[0] * eye[0] + yaxis[1] * eye[1] + yaxis[2] * eye[2]); \
MAT_ELEM_4X4(out, 3, 2) = (zaxis[0] * eye[0] + zaxis[1] * eye[1] + zaxis[2] * eye[2]); \
MAT_ELEM_4X4(out, 3, 3) = 1.f; \
}
struct passwd out
Definition: missing_libc_functions.c:51
bool up
Definition: connect_wiiupro.c:50

◆ matrix_4x4_multiply

#define matrix_4x4_multiply (   out,
  a,
  b 
)

◆ matrix_4x4_ortho

#define matrix_4x4_ortho (   mat,
  left,
  right,
  bottom,
  top,
  znear,
  zfar 
)
Value:
{ \
float rl = (right) - (left); \
float tb = (top) - (bottom); \
float fn = (zfar) - (znear); \
MAT_ELEM_4X4(mat, 0, 0) = 2.0f / rl; \
MAT_ELEM_4X4(mat, 0, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 3) = -((left) + (right)) / rl; \
MAT_ELEM_4X4(mat, 1, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 1) = 2.0f / tb; \
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 3) = -((top) + (bottom)) / tb; \
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 2) = -2.0f / fn; \
MAT_ELEM_4X4(mat, 2, 3) = -((zfar) + (znear)) / fn; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 3) = 1.0f; \
}
GLint GLint bottom
Definition: glext.h:8393
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:11766
GLdouble GLdouble right
Definition: glext.h:11766
GLint left
Definition: glext.h:8393

◆ matrix_4x4_projection

#define matrix_4x4_projection (   mat,
  y_fov,
  aspect,
  znear,
  zfar 
)
Value:
{ \
float const a = 1.f / tan((y_fov) / 2.f); \
float delta_z = (zfar) - (znear); \
MAT_ELEM_4X4(mat, 0, 0) = a / (aspect); \
MAT_ELEM_4X4(mat, 0, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 1) = a; \
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 2) = -(((zfar) + (znear)) / delta_z); \
MAT_ELEM_4X4(mat, 2, 3) = -1.f; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = -((2.f * (zfar) * (znear)) / delta_z); \
MAT_ELEM_4X4(mat, 3, 3) = 0.0f; \
}
GLfloat f
Definition: glext.h:8207
float aspect
Definition: ffmpeg_core.c:183
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844

◆ matrix_4x4_rotate_x

#define matrix_4x4_rotate_x (   mat,
  radians 
)
Value:
{ \
float cosine = cosf(radians); \
float sine = sinf(radians); \
MAT_ELEM_4X4(mat, 0, 0) = 1.0f; \
MAT_ELEM_4X4(mat, 0, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 1) = cosine; \
MAT_ELEM_4X4(mat, 1, 2) = -sine; \
MAT_ELEM_4X4(mat, 1, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 1) = sine; \
MAT_ELEM_4X4(mat, 2, 2) = cosine; \
MAT_ELEM_4X4(mat, 2, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 3) = 1.0f; \
}

◆ matrix_4x4_rotate_y

#define matrix_4x4_rotate_y (   mat,
  radians 
)
Value:
{ \
float cosine = cosf(radians); \
float sine = sinf(radians); \
MAT_ELEM_4X4(mat, 0, 0) = cosine; \
MAT_ELEM_4X4(mat, 0, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 2) = -sine; \
MAT_ELEM_4X4(mat, 0, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 1) = 1.0f; \
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 0) = sine; \
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 2) = cosine; \
MAT_ELEM_4X4(mat, 2, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 3) = 1.0f; \
}

◆ matrix_4x4_rotate_z

#define matrix_4x4_rotate_z (   mat,
  radians 
)
Value:
{ \
float cosine = cosf(radians); \
float sine = sinf(radians); \
MAT_ELEM_4X4(mat, 0, 0) = cosine; \
MAT_ELEM_4X4(mat, 0, 1) = -sine; \
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 0) = sine; \
MAT_ELEM_4X4(mat, 1, 1) = cosine; \
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 2) = 1.0f; \
MAT_ELEM_4X4(mat, 2, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 3) = 1.0f; \
}

◆ matrix_4x4_scale

#define matrix_4x4_scale (   mat,
  x,
  y,
  z 
)
Value:
MAT_ELEM_4X4(mat, 0, 0) = x; \
MAT_ELEM_4X4(mat, 0, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 1) = y; \
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 2) = z; \
MAT_ELEM_4X4(mat, 2, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 3) = 1.0f
GLdouble GLdouble z
Definition: glext.h:6514
GLint GLint GLint GLint GLint GLint y
Definition: glext.h:6295
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
#define MAT_ELEM_4X4(mat, row, column)
Definition: matrix_4x4.h:36

◆ matrix_4x4_translate

#define matrix_4x4_translate (   mat,
  x,
  y,
  z 
)
Value:
MAT_ELEM_4X4(mat, 0, 0) = 1.0f; \
MAT_ELEM_4X4(mat, 0, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 3) = x; \
MAT_ELEM_4X4(mat, 1, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 1) = 1.0f; \
MAT_ELEM_4X4(mat, 1, 2) = 1.0f; \
MAT_ELEM_4X4(mat, 1, 3) = y; \
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 2) = 1.0f; \
MAT_ELEM_4X4(mat, 2, 3) = z; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 3) = 1.0f
GLdouble GLdouble z
Definition: glext.h:6514
GLint GLint GLint GLint GLint GLint y
Definition: glext.h:6295
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
#define MAT_ELEM_4X4(mat, row, column)
Definition: matrix_4x4.h:36

◆ matrix_4x4_transpose

#define matrix_4x4_transpose (   out,
  in 
)
Value:
MAT_ELEM_4X4(out, 0, 0) = MAT_ELEM_4X4(in, 0, 0); \
MAT_ELEM_4X4(out, 1, 0) = MAT_ELEM_4X4(in, 0, 1); \
MAT_ELEM_4X4(out, 2, 0) = MAT_ELEM_4X4(in, 0, 2); \
MAT_ELEM_4X4(out, 3, 0) = MAT_ELEM_4X4(in, 0, 3); \
MAT_ELEM_4X4(out, 0, 1) = MAT_ELEM_4X4(in, 1, 0); \
MAT_ELEM_4X4(out, 1, 1) = MAT_ELEM_4X4(in, 1, 1); \
MAT_ELEM_4X4(out, 2, 1) = MAT_ELEM_4X4(in, 1, 2); \
MAT_ELEM_4X4(out, 3, 1) = MAT_ELEM_4X4(in, 1, 3); \
MAT_ELEM_4X4(out, 0, 2) = MAT_ELEM_4X4(in, 2, 0); \
MAT_ELEM_4X4(out, 1, 2) = MAT_ELEM_4X4(in, 2, 1); \
MAT_ELEM_4X4(out, 2, 2) = MAT_ELEM_4X4(in, 2, 2); \
MAT_ELEM_4X4(out, 3, 2) = MAT_ELEM_4X4(in, 2, 3); \
MAT_ELEM_4X4(out, 0, 3) = MAT_ELEM_4X4(in, 3, 0); \
MAT_ELEM_4X4(out, 1, 3) = MAT_ELEM_4X4(in, 3, 1); \
MAT_ELEM_4X4(out, 2, 3) = MAT_ELEM_4X4(in, 3, 2); \
MAT_ELEM_4X4(out, 3, 3) = MAT_ELEM_4X4(in, 3, 3)
struct passwd out
Definition: missing_libc_functions.c:51
GLuint in
Definition: glext.h:10523
#define MAT_ELEM_4X4(mat, row, column)
Definition: matrix_4x4.h:36

Typedef Documentation

◆ math_matrix_4x4