SDL_gpu  0.11.0
A hardware-accelerated, cross-platform 2D graphics API
Macros | Functions
SDL_gpu_matrix.c File Reference
#include "SDL_gpu.h"
#include <math.h>
#include <string.h>

Go to the source code of this file.

Macros

#define M_PI   3.1415926f
 
#define static_inline   static inline
 
#define INDEX(row, col)   ((col)*4 + (row))
 
#define FILL_MATRIX_4x4(A, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)
 

Functions

float GPU_VectorLength (float *vec3)
 
void GPU_VectorNormalize (float *vec3)
 
float GPU_VectorDot (float *A, float *B)
 
void GPU_VectorCross (float *result, float *A, float *B)
 
void GPU_VectorCopy (float *result, float *A)
 
void GPU_VectorApplyMatrix (float *vec3, float *matrix_4x4)
 
void GPU_MatrixCopy (float *result, const float *A)
 
void GPU_MatrixIdentity (float *result)
 
void GPU_MatrixOrtho (float *result, float left, float right, float bottom, float top, float near, float far)
 
void GPU_MatrixFrustum (float *result, float left, float right, float bottom, float top, float near, float far)
 
void GPU_MatrixPerspective (float *result, float fovy, float aspect, float zNear, float zFar)
 
void GPU_MatrixLookAt (float *matrix, float eye_x, float eye_y, float eye_z, float target_x, float target_y, float target_z, float up_x, float up_y, float up_z)
 
void GPU_MatrixTranslate (float *result, float x, float y, float z)
 
void GPU_MatrixScale (float *result, float sx, float sy, float sz)
 
void GPU_MatrixRotate (float *result, float degrees, float x, float y, float z)
 
void GPU_Multiply4x4 (float *result, float *A, float *B)
 
void GPU_MultiplyAndAssign (float *result, float *B)
 
const char * GPU_GetMatrixString (float *A)
 
void GPU_MatrixMode (int matrix_mode)
 
float * GPU_GetModelView (void)
 
float * GPU_GetProjection (void)
 
float * GPU_GetCurrentMatrix (void)
 
void GPU_PushMatrix (void)
 
void GPU_PopMatrix (void)
 
void GPU_LoadIdentity (void)
 
void GPU_Ortho (float left, float right, float bottom, float top, float near, float far)
 
void GPU_Frustum (float left, float right, float bottom, float top, float near, float far)
 
void GPU_Translate (float x, float y, float z)
 
void GPU_Scale (float sx, float sy, float sz)
 
void GPU_Rotate (float degrees, float x, float y, float z)
 
void GPU_MultMatrix (float *A)
 
void GPU_GetModelViewProjection (float *result)
 

Macro Definition Documentation

◆ FILL_MATRIX_4x4

#define FILL_MATRIX_4x4 (   A,
  a0,
  a1,
  a2,
  a3,
  a4,
  a5,
  a6,
  a7,
  a8,
  a9,
  a10,
  a11,
  a12,
  a13,
  a14,
  a15 
)
Value:
A[0] = a0; \
A[1] = a1; \
A[2] = a2; \
A[3] = a3; \
A[4] = a4; \
A[5] = a5; \
A[6] = a6; \
A[7] = a7; \
A[8] = a8; \
A[9] = a9; \
A[10] = a10; \
A[11] = a11; \
A[12] = a12; \
A[13] = a13; \
A[14] = a14; \
A[15] = a15;

Definition at line 104 of file SDL_gpu_matrix.c.

◆ INDEX

#define INDEX (   row,
  col 
)    ((col)*4 + (row))

Definition at line 55 of file SDL_gpu_matrix.c.

◆ M_PI

#define M_PI   3.1415926f

Definition at line 10 of file SDL_gpu_matrix.c.

◆ static_inline

#define static_inline   static inline

Definition at line 19 of file SDL_gpu_matrix.c.

Function Documentation

◆ GPU_Frustum()

void GPU_Frustum ( float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)

Multiplies a perspective projection matrix into the current matrix.

Definition at line 484 of file SDL_gpu_matrix.c.

◆ GPU_GetCurrentMatrix()

float* GPU_GetCurrentMatrix ( void  )

Returns the current matrix from the top of the matrix stack. Returns NULL if stack is empty.

Definition at line 415 of file SDL_gpu_matrix.c.

◆ GPU_GetMatrixString()

const char* GPU_GetMatrixString ( float *  A)

Returns an internal string that represents the contents of matrix A.

Definition at line 360 of file SDL_gpu_matrix.c.

◆ GPU_GetModelView()

float* GPU_GetModelView ( void  )

Returns the current modelview matrix from the top of the matrix stack. Returns NULL if stack is empty.

Definition at line 389 of file SDL_gpu_matrix.c.

◆ GPU_GetModelViewProjection()

void GPU_GetModelViewProjection ( float *  result)

Copies the current modelview-projection matrix into the given 'result' matrix (result = P*M).

Definition at line 519 of file SDL_gpu_matrix.c.

◆ GPU_GetProjection()

float* GPU_GetProjection ( void  )

Returns the current projection matrix from the top of the matrix stack. Returns NULL if stack is empty.

Definition at line 402 of file SDL_gpu_matrix.c.

◆ GPU_LoadIdentity()

void GPU_LoadIdentity ( void  )

Fills current matrix with the identity matrix.

Definition at line 468 of file SDL_gpu_matrix.c.

◆ GPU_MatrixCopy()

void GPU_MatrixCopy ( float *  result,
const float *  A 
)

Overwrite 'result' matrix with the values from matrix A.

Definition at line 122 of file SDL_gpu_matrix.c.

◆ GPU_MatrixFrustum()

void GPU_MatrixFrustum ( float *  result,
float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)

Multiplies a perspective projection matrix into the given matrix.

Definition at line 163 of file SDL_gpu_matrix.c.

◆ GPU_MatrixIdentity()

void GPU_MatrixIdentity ( float *  result)

Fills 'result' matrix with the identity matrix.

Definition at line 127 of file SDL_gpu_matrix.c.

◆ GPU_MatrixLookAt()

void GPU_MatrixLookAt ( float *  matrix,
float  eye_x,
float  eye_y,
float  eye_z,
float  target_x,
float  target_y,
float  target_z,
float  up_x,
float  up_y,
float  up_z 
)

Multiplies a view matrix into the given matrix.

Definition at line 194 of file SDL_gpu_matrix.c.

◆ GPU_MatrixMode()

void GPU_MatrixMode ( int  matrix_mode)

Changes matrix mode to either GPU_PROJECTION or GPU_MODELVIEW. Further matrix stack operations manipulate that particular stack.

Definition at line 380 of file SDL_gpu_matrix.c.

◆ GPU_MatrixOrtho()

void GPU_MatrixOrtho ( float *  result,
float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)

Multiplies an orthographic projection matrix into the given matrix.

Definition at line 134 of file SDL_gpu_matrix.c.

◆ GPU_MatrixPerspective()

void GPU_MatrixPerspective ( float *  result,
float  fovy,
float  aspect,
float  zNear,
float  zFar 
)

Multiplies a perspective projection matrix into the given matrix.

Definition at line 181 of file SDL_gpu_matrix.c.

◆ GPU_MatrixRotate()

void GPU_MatrixRotate ( float *  result,
float  degrees,
float  x,
float  y,
float  z 
)

Multiplies a rotation matrix into the given matrix.

Definition at line 279 of file SDL_gpu_matrix.c.

◆ GPU_MatrixScale()

void GPU_MatrixScale ( float *  result,
float  sx,
float  sy,
float  sz 
)

Multiplies a scaling matrix into the given matrix.

Definition at line 261 of file SDL_gpu_matrix.c.

◆ GPU_MatrixTranslate()

void GPU_MatrixTranslate ( float *  result,
float  x,
float  y,
float  z 
)

Adds a translation into the given matrix.

Definition at line 233 of file SDL_gpu_matrix.c.

◆ GPU_Multiply4x4()

void GPU_Multiply4x4 ( float *  result,
float *  A,
float *  B 
)

Multiplies matrices A and B and stores the result in the given 'result' matrix (result = A*B). Do not use A or B as 'result'.

See also
GPU_MultiplyAndAssign

Definition at line 325 of file SDL_gpu_matrix.c.

◆ GPU_MultiplyAndAssign()

void GPU_MultiplyAndAssign ( float *  result,
float *  B 
)

Multiplies matrices 'result' and B and stores the result in the given 'result' matrix (result = result * B).

Definition at line 348 of file SDL_gpu_matrix.c.

◆ GPU_MultMatrix()

void GPU_MultMatrix ( float *  matrix4x4)

Multiplies a given matrix into the current matrix.

Definition at line 508 of file SDL_gpu_matrix.c.

◆ GPU_Ortho()

void GPU_Ortho ( float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)

Multiplies an orthographic projection matrix into the current matrix.

Definition at line 478 of file SDL_gpu_matrix.c.

◆ GPU_PopMatrix()

void GPU_PopMatrix ( void  )

Removes the current matrix from the stack.

Definition at line 450 of file SDL_gpu_matrix.c.

◆ GPU_PushMatrix()

void GPU_PushMatrix ( void  )

Pushes the current matrix as a new matrix stack item.

Definition at line 432 of file SDL_gpu_matrix.c.

◆ GPU_Rotate()

void GPU_Rotate ( float  degrees,
float  x,
float  y,
float  z 
)

Multiplies a rotation matrix into the current matrix.

Definition at line 502 of file SDL_gpu_matrix.c.

◆ GPU_Scale()

void GPU_Scale ( float  sx,
float  sy,
float  sz 
)

Multiplies a scaling matrix into the current matrix.

Definition at line 496 of file SDL_gpu_matrix.c.

◆ GPU_Translate()

void GPU_Translate ( float  x,
float  y,
float  z 
)

Adds a translation into the current matrix.

Definition at line 490 of file SDL_gpu_matrix.c.

◆ GPU_VectorApplyMatrix()

void GPU_VectorApplyMatrix ( float *  vec3,
float *  matrix_4x4 
)

Multiplies the given matrix into the given vector (vec3 = matrix*vec3).

Definition at line 90 of file SDL_gpu_matrix.c.

◆ GPU_VectorCopy()

void GPU_VectorCopy ( float *  result,
float *  A 
)

Overwrite 'result' vector with the values from vector A.

Definition at line 83 of file SDL_gpu_matrix.c.

◆ GPU_VectorCross()

void GPU_VectorCross ( float *  result,
float *  A,
float *  B 
)

Performs the cross product of vectors A and B (result = A x B). Do not use A or B as 'result'.

Definition at line 76 of file SDL_gpu_matrix.c.

◆ GPU_VectorDot()

float GPU_VectorDot ( float *  A,
float *  B 
)

Returns the dot product of two vectors.

Definition at line 71 of file SDL_gpu_matrix.c.

◆ GPU_VectorNormalize()

void GPU_VectorNormalize ( float *  vec3)

Modifies the given vector so that it has a new length of 1.

Definition at line 63 of file SDL_gpu_matrix.c.