citro3d
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/**
2 * @file types.h
3 * @brief Various citro3d types.
4 */
5#pragma once
6#if defined(__3DS__) || defined(_3DS)
7#include <3ds.h>
8#else
9#include <stdbool.h>
10#include <stdint.h>
11typedef uint8_t u8;
12typedef uint32_t u32;
13#endif
14
15#ifndef CITRO3D_NO_DEPRECATION
16#define C3D_DEPRECATED __attribute__ ((deprecated))
17#else
18#define C3D_DEPRECATED
19#endif
20
21/**
22 * @brief Integer vector
23 */
24typedef u32 C3D_IVec;
25
26/**
27 * @brief Packs 4 u8 integers into a vector.
28 * @param[in] x X component of the vector.
29 * @param[in] y Y component of the vector.
30 * @param[in] z Z component of the vector.
31 * @param[in] w W component of the vector.
32 * @return Returns \ref C3D_IVec.
33 */
34static inline C3D_IVec IVec_Pack(u8 x, u8 y, u8 z, u8 w)
35{
36 return (u32)x | ((u32)y << 8) | ((u32)z << 16) | ((u32)w << 24);
37}
38
39/**
40 * @defgroup math_support Math Support Library
41 * @brief Implementations of matrix, vector, and quaternion operations.
42 * @{
43 */
44
45/**
46 * @struct C3D_FVec
47 * @brief Float vector
48 *
49 * Matches PICA layout
50 */
51typedef union
52{
53 /**
54 * @brief Vector access
55 */
56 struct
57 {
58 float w; ///< W-component
59 float z; ///< Z-component
60 float y; ///< Y-component
61 float x; ///< X-component
62 };
63
64 /**
65 * @brief Quaternion access
66 */
67 struct
68 {
69 float r; ///< Real component
70 float k; ///< K-component
71 float j; ///< J-component
72 float i; ///< I-component
73 };
74
75 /**
76 * @brief Raw access
77 */
78 float c[4];
79} C3D_FVec;
80
81/**
82 * @brief Float quaternion. See @ref C3D_FVec.
83 */
85
86/**
87 * @struct C3D_Mtx
88 * @brief Row-major 4x4 matrix
89 */
90typedef union
91{
92 C3D_FVec r[4]; ///< Rows are vectors
93 float m[4*4]; ///< Raw access
94} C3D_Mtx;
95/** @} */
C3D_FVec C3D_FQuat
Float quaternion. See C3D_FVec.
Definition types.h:84
static C3D_IVec IVec_Pack(u8 x, u8 y, u8 z, u8 w)
Packs 4 u8 integers into a vector.
Definition types.h:34
uint8_t u8
u32 C3D_IVec
Integer vector.
Definition types.h:24
uint32_t u32
Float vector.
Definition types.h:52
float x
X-component.
Definition types.h:61
float j
J-component.
Definition types.h:71
float z
Z-component.
Definition types.h:59
float w
W-component.
Definition types.h:58
float k
K-component.
Definition types.h:70
float r
Real component.
Definition types.h:69
float i
I-component.
Definition types.h:72
float y
Y-component.
Definition types.h:60
Row-major 4x4 matrix.
Definition types.h:91