apple2ix/src/video_util/matrixUtil.h

118 lines
3.4 KiB
C
Raw Normal View History

/*
2014-10-08 04:59:21 +00:00
* Apple // emulator for *nix
*
* This software package is subject to the GNU General Public License
* version 2 or later (your choice) as published by the Free Software
* Foundation.
*
* THERE ARE NO WARRANTIES WHATSOEVER.
*
*/
2014-10-08 04:59:21 +00:00
// Modified sample code from https://developer.apple.com/library/mac/samplecode/GLEssentials/Introduction/Intro.html
#ifndef __MATRIX_UTIL_H__
#define __MATRIX_UTIL_H__
// Matrix is a column major floating point array
// All matrices are 4x4 by unless the mtx3x3 prefix is specified in the function name
// [ 0 4 8 12 ]
// [ 1 5 9 13 ]
// [ 2 6 10 14 ]
// [ 3 7 11 15 ]
// MTX = LeftHandSideMatrix * RightHandSideMatrix
2014-10-08 04:59:21 +00:00
void mtxMultiply(float *ret, const float *lhs, const float *rhs);
// MTX = IdentityMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadIdentity(float *mtx);
// MTX = Transpos(SRC)
2014-10-08 04:59:21 +00:00
void mtxTranspose(float *mtx, const float *src);
// MTX = src^-1
2014-10-08 04:59:21 +00:00
void mtxInvert(float *mtx, const float *src);
// MTX = PerspectiveProjectionMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadPerspective(float *mtx, float fov, float aspect, float nearZ, float farZ);
// MTX = OrthographicProjectionMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadOrthographic(float *mtx, float left, float right, float bottom, float top, float nearZ, float farZ);
// MTX = ObliqueProjectionMatrix(src, clipPlane)
2014-10-08 04:59:21 +00:00
void mtxModifyObliqueProjection(float *mtx, const float *src, const float *plane);
// MTX = TranlationMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadTranslate(float *mtx, float xTrans, float yTrans, float zTrans);
// MTX = ScaleMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadScale(float *mtx, float xScale, float yScale, float zScale);
// MTX = RotateXYZMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadRotate(float *mtx, float deg, float xAxis, float , float zAxis);
// MTX = RotateXMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadRotateX(float *mtx, float deg);
// MTX = RotateYMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadRotateY(float *mtx, float deg);
// MTX = RotateZMatrix
2014-10-08 04:59:21 +00:00
void mtxLoadRotateZ(float *mtx, float deg);
// MTX = MTX * TranslationMatrix - Similar to glTranslate
2014-10-08 04:59:21 +00:00
void mtxTranslateApply(float *mtx, float xTrans, float yTrans, float zTrans);
// MTX = MTX * ScaleMatrix - Similar to glScale
2014-10-08 04:59:21 +00:00
void mtxScaleApply(float *mtx, float xScale, float yScale, float zScale);
// MTX = MTX * RotateXYZMatrix - Similar to glRotate
2014-10-08 04:59:21 +00:00
void mtxRotateApply(float *mtx, float deg, float xAxis, float yAxis, float zAxis);
// MTX = MTX * RotateXMatrix
2014-10-08 04:59:21 +00:00
void mtxRotateXApply(float *mtx, float rad);
// MTX = MTX * RotateYMatrix
2014-10-08 04:59:21 +00:00
void mtxRotateYApply(float *mtx, float rad);
// MTX = MTX * RotateZMatrix
2014-10-08 04:59:21 +00:00
void mtxRotateZApply(float *mtx, float rad);
// MTX = TranslationMatrix * MTX
2014-10-08 04:59:21 +00:00
void mtxTranslateMatrix(float *mtx, float xTrans, float yTrans, float zTrans);
// MTX = ScaleMatrix * MTX
2014-10-08 04:59:21 +00:00
void mtxScaleMatrix(float *mtx, float xScale, float yScale, float zScale);
// MTX = RotateXYZMatrix * MTX
2014-10-08 04:59:21 +00:00
void mtxRotateMatrix(float *mtx, float rad, float xAxis, float yAxis, float zAxis);
// MTX = RotateXMatrix * MTX
2014-10-08 04:59:21 +00:00
void mtxRotateXMatrix(float *mtx, float rad);
// MTX = RotateYMatrix * MTX
2014-10-08 04:59:21 +00:00
void mtxRotateYMatrix(float *mtx, float rad);
// MTX = RotateZMatrix * MTX
2014-10-08 04:59:21 +00:00
void mtxRotateZMatrix(float *mtx, float rad);
2014-10-08 04:59:21 +00:00
// 3x3 MTX = 3x3 IdentityMatrix
void mtx3x3LoadIdentity(float *mtx);
// 3x3 MTX = 3x3 LHS x 3x3 RHS
2014-10-08 04:59:21 +00:00
void mtx3x3Multiply(float *mtx, const float *lhs, const float *rhs);
2014-10-08 04:59:21 +00:00
// 3x3 MTX = TopLeft of MTX
void mtx3x3FromTopLeftOf4x4(float *mtx, const float *src);
// 3x3 MTX = Transpose(3x3 SRC)
2014-10-08 04:59:21 +00:00
void mtx3x3Transpose(float *mtx, const float *src);
// 3x3 MTX = 3x3 SRC^-1
2014-10-08 04:59:21 +00:00
void mtx3x3Invert(float *mtx, const float *src);
#endif //__MATRIX_UTIL_H__