mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Update raylib to use #row_major matrices
This commit is contained in:
Vendored
+6
-6
@@ -213,17 +213,17 @@ MAGENTA :: Color{ 255, 0, 255, 255 } // Magenta
|
|||||||
RAYWHITE :: Color{ 245, 245, 245, 255 } // My own White (raylib logo)
|
RAYWHITE :: Color{ 245, 245, 245, 255 } // My own White (raylib logo)
|
||||||
|
|
||||||
// Vector2 type
|
// Vector2 type
|
||||||
Vector2 :: linalg.Vector2f32
|
Vector2 :: [2]f32
|
||||||
// Vector3 type
|
// Vector3 type
|
||||||
Vector3 :: linalg.Vector3f32
|
Vector3 :: [3]f32
|
||||||
// Vector4 type
|
// Vector4 type
|
||||||
Vector4 :: linalg.Vector4f32
|
Vector4 :: [4]f32
|
||||||
|
|
||||||
// Quaternion type
|
// Quaternion type
|
||||||
Quaternion :: linalg.Quaternionf32
|
Quaternion :: quaternion128
|
||||||
|
|
||||||
// Matrix type (OpenGL style 4x4 - right handed, stored column major)
|
// Matrix type (right handed, stored row major)
|
||||||
Matrix :: linalg.Matrix4x4f32
|
Matrix :: #row_major matrix[4, 4]f32
|
||||||
|
|
||||||
|
|
||||||
// Color, 4 components, R8G8B8A8 (32bit)
|
// Color, 4 components, R8G8B8A8 (32bit)
|
||||||
|
|||||||
Vendored
+18
-13
@@ -590,74 +590,79 @@ MatrixMultiply :: proc "c" (left, right: Matrix) -> Matrix {
|
|||||||
// Get translation matrix
|
// Get translation matrix
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixTranslate :: proc "c" (x, y, z: f32) -> Matrix {
|
MatrixTranslate :: proc "c" (x, y, z: f32) -> Matrix {
|
||||||
return linalg.matrix4_translate(Vector3{x, y, z})
|
return {
|
||||||
|
1, 0, 0, x,
|
||||||
|
0, 1, 0, y,
|
||||||
|
0, 0, 1, z,
|
||||||
|
0, 0, 0, 1,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create rotation matrix from axis and angle
|
// Create rotation matrix from axis and angle
|
||||||
// NOTE: Angle should be provided in radians
|
// NOTE: Angle should be provided in radians
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixRotate :: proc "c" (axis: Vector3, angle: f32) -> Matrix {
|
MatrixRotate :: proc "c" (axis: Vector3, angle: f32) -> Matrix {
|
||||||
return linalg.matrix4_rotate(angle, axis)
|
return auto_cast linalg.matrix4_rotate(angle, axis)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get x-rotation matrix
|
// Get x-rotation matrix
|
||||||
// NOTE: Angle must be provided in radians
|
// NOTE: Angle must be provided in radians
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixRotateX :: proc "c" (angle: f32) -> Matrix {
|
MatrixRotateX :: proc "c" (angle: f32) -> Matrix {
|
||||||
return linalg.matrix4_rotate(angle, Vector3{1, 0, 0})
|
return auto_cast linalg.matrix4_rotate(angle, Vector3{1, 0, 0})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get y-rotation matrix
|
// Get y-rotation matrix
|
||||||
// NOTE: Angle must be provided in radians
|
// NOTE: Angle must be provided in radians
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixRotateY :: proc "c" (angle: f32) -> Matrix {
|
MatrixRotateY :: proc "c" (angle: f32) -> Matrix {
|
||||||
return linalg.matrix4_rotate(angle, Vector3{0, 1, 0})
|
return auto_cast linalg.matrix4_rotate(angle, Vector3{0, 1, 0})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get z-rotation matrix
|
// Get z-rotation matrix
|
||||||
// NOTE: Angle must be provided in radians
|
// NOTE: Angle must be provided in radians
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixRotateZ :: proc "c" (angle: f32) -> Matrix {
|
MatrixRotateZ :: proc "c" (angle: f32) -> Matrix {
|
||||||
return linalg.matrix4_rotate(angle, Vector3{0, 0, 1})
|
return auto_cast linalg.matrix4_rotate(angle, Vector3{0, 0, 1})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get xyz-rotation matrix
|
// Get xyz-rotation matrix
|
||||||
// NOTE: Angle must be provided in radians
|
// NOTE: Angle must be provided in radians
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixRotateXYZ :: proc "c" (angle: Vector3) -> Matrix {
|
MatrixRotateXYZ :: proc "c" (angle: Vector3) -> Matrix {
|
||||||
return linalg.matrix4_from_euler_angles_xyz(angle.x, angle.y, angle.z)
|
return auto_cast linalg.matrix4_from_euler_angles_xyz(angle.x, angle.y, angle.z)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get zyx-rotation matrix
|
// Get zyx-rotation matrix
|
||||||
// NOTE: Angle must be provided in radians
|
// NOTE: Angle must be provided in radians
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixRotateZYX :: proc "c" (angle: Vector3) -> Matrix {
|
MatrixRotateZYX :: proc "c" (angle: Vector3) -> Matrix {
|
||||||
return linalg.matrix4_from_euler_angles_zyx(angle.x, angle.y, angle.z)
|
return auto_cast linalg.matrix4_from_euler_angles_zyx(angle.x, angle.y, angle.z)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get scaling matrix
|
// Get scaling matrix
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixScale :: proc "c" (x, y, z: f32) -> Matrix {
|
MatrixScale :: proc "c" (x, y, z: f32) -> Matrix {
|
||||||
return linalg.matrix4_scale(Vector3{x, y, z})
|
return auto_cast linalg.matrix4_scale(Vector3{x, y, z})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get orthographic projection matrix
|
// Get orthographic projection matrix
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixOrtho :: proc "c" (left, right, bottom, top, near, far: f32) -> Matrix {
|
MatrixOrtho :: proc "c" (left, right, bottom, top, near, far: f32) -> Matrix {
|
||||||
return linalg.matrix_ortho3d(left, right, bottom, top, near, far)
|
return auto_cast linalg.matrix_ortho3d(left, right, bottom, top, near, far)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get perspective projection matrix
|
// Get perspective projection matrix
|
||||||
// NOTE: Fovy angle must be provided in radians
|
// NOTE: Fovy angle must be provided in radians
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixPerspective :: proc "c" (fovY, aspect, nearPlane, farPlane: f32) -> Matrix {
|
MatrixPerspective :: proc "c" (fovY, aspect, nearPlane, farPlane: f32) -> Matrix {
|
||||||
return linalg.matrix4_perspective(fovY, aspect, nearPlane, farPlane)
|
return auto_cast linalg.matrix4_perspective(fovY, aspect, nearPlane, farPlane)
|
||||||
}
|
}
|
||||||
// Get camera look-at matrix (view matrix)
|
// Get camera look-at matrix (view matrix)
|
||||||
@(require_results)
|
@(require_results)
|
||||||
MatrixLookAt :: proc "c" (eye, target, up: Vector3) -> Matrix {
|
MatrixLookAt :: proc "c" (eye, target, up: Vector3) -> Matrix {
|
||||||
return linalg.matrix4_look_at(eye, target, up)
|
return auto_cast linalg.matrix4_look_at(eye, target, up)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get float array of matrix data
|
// Get float array of matrix data
|
||||||
@@ -755,12 +760,12 @@ QuaternionFromVector3ToVector3 :: proc "c" (from, to: Vector3) -> Quaternion {
|
|||||||
// Get a quaternion for a given rotation matrix
|
// Get a quaternion for a given rotation matrix
|
||||||
@(require_results)
|
@(require_results)
|
||||||
QuaternionFromMatrix :: proc "c" (mat: Matrix) -> Quaternion {
|
QuaternionFromMatrix :: proc "c" (mat: Matrix) -> Quaternion {
|
||||||
return linalg.quaternion_from_matrix4(mat)
|
return linalg.quaternion_from_matrix4(linalg.Matrix4f32(mat))
|
||||||
}
|
}
|
||||||
// Get a matrix for a given quaternion
|
// Get a matrix for a given quaternion
|
||||||
@(require_results)
|
@(require_results)
|
||||||
QuaternionToMatrix :: proc "c" (q: Quaternion) -> Matrix {
|
QuaternionToMatrix :: proc "c" (q: Quaternion) -> Matrix {
|
||||||
return linalg.matrix4_from_quaternion(q)
|
return auto_cast linalg.matrix4_from_quaternion(q)
|
||||||
}
|
}
|
||||||
// Get rotation quaternion for an angle and axis NOTE: Angle must be provided in radians
|
// Get rotation quaternion for an angle and axis NOTE: Angle must be provided in radians
|
||||||
@(require_results)
|
@(require_results)
|
||||||
|
|||||||
Reference in New Issue
Block a user