citro3d/include/c3d/types.h

82 lines
1.3 KiB
C
Raw Normal View History

2014-12-20 21:34:19 +01:00
#pragma once
2021-08-07 13:11:39 +02:00
#if defined(__3DS__) || defined(_3DS)
2014-12-20 21:34:19 +01:00
#include <3ds.h>
#else
#include <stdbool.h>
#include <stdint.h>
typedef uint8_t u8;
typedef uint32_t u32;
#endif
2014-12-20 21:34:19 +01:00
#ifndef CITRO3D_NO_DEPRECATION
#define C3D_DEPRECATED __attribute__ ((deprecated))
#else
#define C3D_DEPRECATED
#endif
2014-12-20 21:34:19 +01:00
typedef u32 C3D_IVec;
2017-02-09 04:30:25 +01:00
static inline C3D_IVec IVec_Pack(u8 x, u8 y, u8 z, u8 w)
{
return (u32)x | ((u32)y << 8) | ((u32)z << 16) | ((u32)w << 24);
}
/**
* @defgroup math_support Math Support Library
* @brief Implementations of matrix, vector, and quaternion operations.
* @{
*/
/**
* @struct C3D_FVec
* @brief Float vector
*
* Matches PICA layout
*/
typedef union
2014-12-20 21:34:19 +01:00
{
2017-02-09 04:30:25 +01:00
/**
* @brief Vector access
*/
struct
{
float w; ///< W-component
float z; ///< Z-component
float y; ///< Y-component
float x; ///< X-component
};
/**
* @brief Quaternion access
*/
struct
{
float r; ///< Real component
float k; ///< K-component
float j; ///< J-component
float i; ///< I-component
};
/**
* @brief Raw access
*/
float c[4];
2014-12-20 21:34:19 +01:00
} C3D_FVec;
2017-02-09 04:30:25 +01:00
/**
* @struct C3D_FQuat
* @brief Float quaternion. See @ref C3D_FVec.
*/
typedef C3D_FVec C3D_FQuat;
2017-02-09 04:30:25 +01:00
/**
* @struct C3D_Mtx
* @brief Row-major 4x4 matrix
*/
typedef union
2014-12-20 21:34:19 +01:00
{
2017-02-09 04:30:25 +01:00
C3D_FVec r[4]; ///< Rows are vectors
float m[4*4]; ///< Raw access
2014-12-20 21:34:19 +01:00
} C3D_Mtx;
2017-02-09 04:30:25 +01:00
/** @} */