REVIEWED: API functions specifiers
This commit is contained in:
parent
9f4a839853
commit
b972b8d324
@ -85,7 +85,7 @@
|
||||
// Module: rlgl - Configuration values
|
||||
//------------------------------------------------------------------------------------
|
||||
// Show OpenGL extensions and capabilities detailed logs on init
|
||||
//#define SUPPORT_GL_DETAILS_INFO 1
|
||||
//#define RLGL_SHOW_GL_DETAILS_INFO 1
|
||||
|
||||
//#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits
|
||||
#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||
|
@ -83,15 +83,18 @@
|
||||
|
||||
#define RAYLIB_VERSION "4.0"
|
||||
|
||||
// Function specifiers definition
|
||||
#ifndef RLAPI
|
||||
#define RLAPI // We are building or using rlgl as a static library (or Linux shared library)
|
||||
#define RLAPI // Functions defined as 'extern' by default (implicit specifiers)
|
||||
#endif
|
||||
|
||||
// Function specifiers in case library is build/used as a shared library (Windows)
|
||||
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
||||
#if defined(_WIN32)
|
||||
#if defined(BUILD_LIBTYPE_SHARED)
|
||||
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll)
|
||||
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
|
||||
#elif defined(USE_LIBTYPE_SHARED)
|
||||
#define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
|
||||
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
228
src/raymath.h
228
src/raymath.h
@ -4,11 +4,6 @@
|
||||
*
|
||||
* CONFIGURATION:
|
||||
*
|
||||
* #define RAYMATH_IMPLEMENTATION
|
||||
* Generates the implementation of the library into the included file.
|
||||
* If not defined, the library is in header only mode and can be included in other headers
|
||||
* or source files without problems. But only ONE file should hold the implementation.
|
||||
*
|
||||
* #define RAYMATH_STATIC_INLINE
|
||||
* Define static inline functions code, so #include header suffices for use.
|
||||
* This may use up lots of memory.
|
||||
@ -47,28 +42,25 @@
|
||||
#ifndef RAYMATH_H
|
||||
#define RAYMATH_H
|
||||
|
||||
#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_STATIC_INLINE)
|
||||
#error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_STATIC_INLINE is contradictory"
|
||||
// Function specifiers definition
|
||||
#ifndef RMAPI
|
||||
#define RMAPI extern inline // Functions defined as 'extern inline' by default
|
||||
#endif
|
||||
|
||||
#if defined(RAYMATH_IMPLEMENTATION)
|
||||
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
|
||||
#define RMDEF __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll).
|
||||
#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
|
||||
#define RMDEF __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
|
||||
#else
|
||||
#define RMDEF extern inline // Provide external definition
|
||||
#endif
|
||||
#elif defined(RAYMATH_STATIC_INLINE)
|
||||
#define RMDEF static inline // Functions may be inlined, no external out-of-line definition
|
||||
#else
|
||||
#if defined(__TINYC__)
|
||||
#define RMDEF static inline // WARNING: Plain inline not supported by tinycc (See issue #435)
|
||||
#else
|
||||
#define RMDEF inline // Functions may be inlined or external definition used
|
||||
// Function specifiers in case library is build/used as a shared library (Windows)
|
||||
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
||||
#if defined(_WIN32)
|
||||
#if defined(BUILD_LIBTYPE_SHARED)
|
||||
#define RMAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
|
||||
#elif defined(USE_LIBTYPE_SHARED)
|
||||
#define RMAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(RAYMATH_STATIC_INLINE)
|
||||
#define RMAPI static inline // Functions may be inlined, no external out-of-line definition
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -160,7 +152,7 @@ typedef struct float16 {
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Clamp float value
|
||||
RMDEF float Clamp(float value, float min, float max)
|
||||
RMAPI float Clamp(float value, float min, float max)
|
||||
{
|
||||
float result = (value < min)? min : value;
|
||||
|
||||
@ -170,7 +162,7 @@ RMDEF float Clamp(float value, float min, float max)
|
||||
}
|
||||
|
||||
// Calculate linear interpolation between two floats
|
||||
RMDEF float Lerp(float start, float end, float amount)
|
||||
RMAPI float Lerp(float start, float end, float amount)
|
||||
{
|
||||
float result = start + amount*(end - start);
|
||||
|
||||
@ -178,7 +170,7 @@ RMDEF float Lerp(float start, float end, float amount)
|
||||
}
|
||||
|
||||
// Normalize input value within input range
|
||||
RMDEF float Normalize(float value, float start, float end)
|
||||
RMAPI float Normalize(float value, float start, float end)
|
||||
{
|
||||
float result = (value - start)/(end - start);
|
||||
|
||||
@ -186,7 +178,7 @@ RMDEF float Normalize(float value, float start, float end)
|
||||
}
|
||||
|
||||
// Remap input value within input range to output range
|
||||
RMDEF float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd)
|
||||
RMAPI float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd)
|
||||
{
|
||||
float result =(value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart;
|
||||
|
||||
@ -198,7 +190,7 @@ RMDEF float Remap(float value, float inputStart, float inputEnd, float outputSta
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Vector with components value 0.0f
|
||||
RMDEF Vector2 Vector2Zero(void)
|
||||
RMAPI Vector2 Vector2Zero(void)
|
||||
{
|
||||
Vector2 result = { 0.0f, 0.0f };
|
||||
|
||||
@ -206,7 +198,7 @@ RMDEF Vector2 Vector2Zero(void)
|
||||
}
|
||||
|
||||
// Vector with components value 1.0f
|
||||
RMDEF Vector2 Vector2One(void)
|
||||
RMAPI Vector2 Vector2One(void)
|
||||
{
|
||||
Vector2 result = { 1.0f, 1.0f };
|
||||
|
||||
@ -214,7 +206,7 @@ RMDEF Vector2 Vector2One(void)
|
||||
}
|
||||
|
||||
// Add two vectors (v1 + v2)
|
||||
RMDEF Vector2 Vector2Add(Vector2 v1, Vector2 v2)
|
||||
RMAPI Vector2 Vector2Add(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
Vector2 result = { v1.x + v2.x, v1.y + v2.y };
|
||||
|
||||
@ -222,7 +214,7 @@ RMDEF Vector2 Vector2Add(Vector2 v1, Vector2 v2)
|
||||
}
|
||||
|
||||
// Add vector and float value
|
||||
RMDEF Vector2 Vector2AddValue(Vector2 v, float add)
|
||||
RMAPI Vector2 Vector2AddValue(Vector2 v, float add)
|
||||
{
|
||||
Vector2 result = { v.x + add, v.y + add };
|
||||
|
||||
@ -230,7 +222,7 @@ RMDEF Vector2 Vector2AddValue(Vector2 v, float add)
|
||||
}
|
||||
|
||||
// Subtract two vectors (v1 - v2)
|
||||
RMDEF Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
|
||||
RMAPI Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
Vector2 result = { v1.x - v2.x, v1.y - v2.y };
|
||||
|
||||
@ -238,7 +230,7 @@ RMDEF Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
|
||||
}
|
||||
|
||||
// Subtract vector by float value
|
||||
RMDEF Vector2 Vector2SubtractValue(Vector2 v, float sub)
|
||||
RMAPI Vector2 Vector2SubtractValue(Vector2 v, float sub)
|
||||
{
|
||||
Vector2 result = { v.x - sub, v.y - sub };
|
||||
|
||||
@ -246,7 +238,7 @@ RMDEF Vector2 Vector2SubtractValue(Vector2 v, float sub)
|
||||
}
|
||||
|
||||
// Calculate vector length
|
||||
RMDEF float Vector2Length(Vector2 v)
|
||||
RMAPI float Vector2Length(Vector2 v)
|
||||
{
|
||||
float result = sqrtf((v.x*v.x) + (v.y*v.y));
|
||||
|
||||
@ -254,7 +246,7 @@ RMDEF float Vector2Length(Vector2 v)
|
||||
}
|
||||
|
||||
// Calculate vector square length
|
||||
RMDEF float Vector2LengthSqr(Vector2 v)
|
||||
RMAPI float Vector2LengthSqr(Vector2 v)
|
||||
{
|
||||
float result = (v.x*v.x) + (v.y*v.y);
|
||||
|
||||
@ -262,7 +254,7 @@ RMDEF float Vector2LengthSqr(Vector2 v)
|
||||
}
|
||||
|
||||
// Calculate two vectors dot product
|
||||
RMDEF float Vector2DotProduct(Vector2 v1, Vector2 v2)
|
||||
RMAPI float Vector2DotProduct(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
float result = (v1.x*v2.x + v1.y*v2.y);
|
||||
|
||||
@ -270,7 +262,7 @@ RMDEF float Vector2DotProduct(Vector2 v1, Vector2 v2)
|
||||
}
|
||||
|
||||
// Calculate distance between two vectors
|
||||
RMDEF float Vector2Distance(Vector2 v1, Vector2 v2)
|
||||
RMAPI float Vector2Distance(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
float result = sqrtf((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y));
|
||||
|
||||
@ -278,7 +270,7 @@ RMDEF float Vector2Distance(Vector2 v1, Vector2 v2)
|
||||
}
|
||||
|
||||
// Calculate angle from two vectors in X-axis
|
||||
RMDEF float Vector2Angle(Vector2 v1, Vector2 v2)
|
||||
RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
float result = atan2f(v2.y - v1.y, v2.x - v1.x)*(180.0f/PI);
|
||||
|
||||
@ -288,7 +280,7 @@ RMDEF float Vector2Angle(Vector2 v1, Vector2 v2)
|
||||
}
|
||||
|
||||
// Scale vector (multiply by value)
|
||||
RMDEF Vector2 Vector2Scale(Vector2 v, float scale)
|
||||
RMAPI Vector2 Vector2Scale(Vector2 v, float scale)
|
||||
{
|
||||
Vector2 result = { v.x*scale, v.y*scale };
|
||||
|
||||
@ -296,7 +288,7 @@ RMDEF Vector2 Vector2Scale(Vector2 v, float scale)
|
||||
}
|
||||
|
||||
// Multiply vector by vector
|
||||
RMDEF Vector2 Vector2Multiply(Vector2 v1, Vector2 v2)
|
||||
RMAPI Vector2 Vector2Multiply(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
Vector2 result = { v1.x*v2.x, v1.y*v2.y };
|
||||
|
||||
@ -304,7 +296,7 @@ RMDEF Vector2 Vector2Multiply(Vector2 v1, Vector2 v2)
|
||||
}
|
||||
|
||||
// Negate vector
|
||||
RMDEF Vector2 Vector2Negate(Vector2 v)
|
||||
RMAPI Vector2 Vector2Negate(Vector2 v)
|
||||
{
|
||||
Vector2 result = { -v.x, -v.y };
|
||||
|
||||
@ -312,7 +304,7 @@ RMDEF Vector2 Vector2Negate(Vector2 v)
|
||||
}
|
||||
|
||||
// Divide vector by vector
|
||||
RMDEF Vector2 Vector2Divide(Vector2 v1, Vector2 v2)
|
||||
RMAPI Vector2 Vector2Divide(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
Vector2 result = { v1.x/v2.x, v1.y/v2.y };
|
||||
|
||||
@ -320,7 +312,7 @@ RMDEF Vector2 Vector2Divide(Vector2 v1, Vector2 v2)
|
||||
}
|
||||
|
||||
// Normalize provided vector
|
||||
RMDEF Vector2 Vector2Normalize(Vector2 v)
|
||||
RMAPI Vector2 Vector2Normalize(Vector2 v)
|
||||
{
|
||||
Vector2 result = { 0 };
|
||||
float length = sqrtf((v.x*v.x) + (v.y*v.y));
|
||||
@ -335,7 +327,7 @@ RMDEF Vector2 Vector2Normalize(Vector2 v)
|
||||
}
|
||||
|
||||
// Calculate linear interpolation between two vectors
|
||||
RMDEF Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)
|
||||
RMAPI Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)
|
||||
{
|
||||
Vector2 result = { 0 };
|
||||
|
||||
@ -346,7 +338,7 @@ RMDEF Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount)
|
||||
}
|
||||
|
||||
// Calculate reflected vector to normal
|
||||
RMDEF Vector2 Vector2Reflect(Vector2 v, Vector2 normal)
|
||||
RMAPI Vector2 Vector2Reflect(Vector2 v, Vector2 normal)
|
||||
{
|
||||
Vector2 result = { 0 };
|
||||
|
||||
@ -359,7 +351,7 @@ RMDEF Vector2 Vector2Reflect(Vector2 v, Vector2 normal)
|
||||
}
|
||||
|
||||
// Rotate vector by angle
|
||||
RMDEF Vector2 Vector2Rotate(Vector2 v, float angle)
|
||||
RMAPI Vector2 Vector2Rotate(Vector2 v, float angle)
|
||||
{
|
||||
Vector2 result = { 0 };
|
||||
|
||||
@ -370,7 +362,7 @@ RMDEF Vector2 Vector2Rotate(Vector2 v, float angle)
|
||||
}
|
||||
|
||||
// Move Vector towards target
|
||||
RMDEF Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance)
|
||||
RMAPI Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance)
|
||||
{
|
||||
Vector2 result = { 0 };
|
||||
|
||||
@ -393,7 +385,7 @@ RMDEF Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Vector with components value 0.0f
|
||||
RMDEF Vector3 Vector3Zero(void)
|
||||
RMAPI Vector3 Vector3Zero(void)
|
||||
{
|
||||
Vector3 result = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
@ -401,7 +393,7 @@ RMDEF Vector3 Vector3Zero(void)
|
||||
}
|
||||
|
||||
// Vector with components value 1.0f
|
||||
RMDEF Vector3 Vector3One(void)
|
||||
RMAPI Vector3 Vector3One(void)
|
||||
{
|
||||
Vector3 result = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
@ -409,7 +401,7 @@ RMDEF Vector3 Vector3One(void)
|
||||
}
|
||||
|
||||
// Add two vectors
|
||||
RMDEF Vector3 Vector3Add(Vector3 v1, Vector3 v2)
|
||||
RMAPI Vector3 Vector3Add(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
Vector3 result = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
|
||||
|
||||
@ -417,7 +409,7 @@ RMDEF Vector3 Vector3Add(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Add vector and float value
|
||||
RMDEF Vector3 Vector3AddValue(Vector3 v, float add)
|
||||
RMAPI Vector3 Vector3AddValue(Vector3 v, float add)
|
||||
{
|
||||
Vector3 result = { v.x + add, v.y + add, v.z + add };
|
||||
|
||||
@ -425,7 +417,7 @@ RMDEF Vector3 Vector3AddValue(Vector3 v, float add)
|
||||
}
|
||||
|
||||
// Subtract two vectors
|
||||
RMDEF Vector3 Vector3Subtract(Vector3 v1, Vector3 v2)
|
||||
RMAPI Vector3 Vector3Subtract(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
Vector3 result = { v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
|
||||
|
||||
@ -433,7 +425,7 @@ RMDEF Vector3 Vector3Subtract(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Subtract vector by float value
|
||||
RMDEF Vector3 Vector3SubtractValue(Vector3 v, float sub)
|
||||
RMAPI Vector3 Vector3SubtractValue(Vector3 v, float sub)
|
||||
{
|
||||
Vector3 result = { v.x - sub, v.y - sub, v.z - sub };
|
||||
|
||||
@ -441,7 +433,7 @@ RMDEF Vector3 Vector3SubtractValue(Vector3 v, float sub)
|
||||
}
|
||||
|
||||
// Multiply vector by scalar
|
||||
RMDEF Vector3 Vector3Scale(Vector3 v, float scalar)
|
||||
RMAPI Vector3 Vector3Scale(Vector3 v, float scalar)
|
||||
{
|
||||
Vector3 result = { v.x*scalar, v.y*scalar, v.z*scalar };
|
||||
|
||||
@ -449,7 +441,7 @@ RMDEF Vector3 Vector3Scale(Vector3 v, float scalar)
|
||||
}
|
||||
|
||||
// Multiply vector by vector
|
||||
RMDEF Vector3 Vector3Multiply(Vector3 v1, Vector3 v2)
|
||||
RMAPI Vector3 Vector3Multiply(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
Vector3 result = { v1.x*v2.x, v1.y*v2.y, v1.z*v2.z };
|
||||
|
||||
@ -457,7 +449,7 @@ RMDEF Vector3 Vector3Multiply(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Calculate two vectors cross product
|
||||
RMDEF Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2)
|
||||
RMAPI Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
Vector3 result = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x };
|
||||
|
||||
@ -465,7 +457,7 @@ RMDEF Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Calculate one vector perpendicular vector
|
||||
RMDEF Vector3 Vector3Perpendicular(Vector3 v)
|
||||
RMAPI Vector3 Vector3Perpendicular(Vector3 v)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -494,7 +486,7 @@ RMDEF Vector3 Vector3Perpendicular(Vector3 v)
|
||||
}
|
||||
|
||||
// Calculate vector length
|
||||
RMDEF float Vector3Length(const Vector3 v)
|
||||
RMAPI float Vector3Length(const Vector3 v)
|
||||
{
|
||||
float result = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
|
||||
|
||||
@ -502,7 +494,7 @@ RMDEF float Vector3Length(const Vector3 v)
|
||||
}
|
||||
|
||||
// Calculate vector square length
|
||||
RMDEF float Vector3LengthSqr(const Vector3 v)
|
||||
RMAPI float Vector3LengthSqr(const Vector3 v)
|
||||
{
|
||||
float result = v.x*v.x + v.y*v.y + v.z*v.z;
|
||||
|
||||
@ -510,7 +502,7 @@ RMDEF float Vector3LengthSqr(const Vector3 v)
|
||||
}
|
||||
|
||||
// Calculate two vectors dot product
|
||||
RMDEF float Vector3DotProduct(Vector3 v1, Vector3 v2)
|
||||
RMAPI float Vector3DotProduct(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
float result = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
|
||||
|
||||
@ -518,7 +510,7 @@ RMDEF float Vector3DotProduct(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Calculate distance between two vectors
|
||||
RMDEF float Vector3Distance(Vector3 v1, Vector3 v2)
|
||||
RMAPI float Vector3Distance(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
float result = 0.0f;
|
||||
|
||||
@ -531,7 +523,7 @@ RMDEF float Vector3Distance(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Calculate angle between two vectors in XY and XZ
|
||||
RMDEF Vector2 Vector3Angle(Vector3 v1, Vector3 v2)
|
||||
RMAPI Vector2 Vector3Angle(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
Vector2 result = { 0 };
|
||||
|
||||
@ -546,7 +538,7 @@ RMDEF Vector2 Vector3Angle(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Negate provided vector (invert direction)
|
||||
RMDEF Vector3 Vector3Negate(Vector3 v)
|
||||
RMAPI Vector3 Vector3Negate(Vector3 v)
|
||||
{
|
||||
Vector3 result = { -v.x, -v.y, -v.z };
|
||||
|
||||
@ -554,7 +546,7 @@ RMDEF Vector3 Vector3Negate(Vector3 v)
|
||||
}
|
||||
|
||||
// Divide vector by vector
|
||||
RMDEF Vector3 Vector3Divide(Vector3 v1, Vector3 v2)
|
||||
RMAPI Vector3 Vector3Divide(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
Vector3 result = { v1.x/v2.x, v1.y/v2.y, v1.z/v2.z };
|
||||
|
||||
@ -562,7 +554,7 @@ RMDEF Vector3 Vector3Divide(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Normalize provided vector
|
||||
RMDEF Vector3 Vector3Normalize(Vector3 v)
|
||||
RMAPI Vector3 Vector3Normalize(Vector3 v)
|
||||
{
|
||||
Vector3 result = v;
|
||||
|
||||
@ -580,7 +572,7 @@ RMDEF Vector3 Vector3Normalize(Vector3 v)
|
||||
// Orthonormalize provided vectors
|
||||
// Makes vectors normalized and orthogonal to each other
|
||||
// Gram-Schmidt function implementation
|
||||
RMDEF void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2)
|
||||
RMAPI void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2)
|
||||
{
|
||||
float length = 0.0f;
|
||||
float ilength = 0.0f;
|
||||
@ -613,7 +605,7 @@ RMDEF void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2)
|
||||
}
|
||||
|
||||
// Transforms a Vector3 by a given Matrix
|
||||
RMDEF Vector3 Vector3Transform(Vector3 v, Matrix mat)
|
||||
RMAPI Vector3 Vector3Transform(Vector3 v, Matrix mat)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -629,7 +621,7 @@ RMDEF Vector3 Vector3Transform(Vector3 v, Matrix mat)
|
||||
}
|
||||
|
||||
// Transform a vector by quaternion rotation
|
||||
RMDEF Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q)
|
||||
RMAPI Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -641,7 +633,7 @@ RMDEF Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q)
|
||||
}
|
||||
|
||||
// Calculate linear interpolation between two vectors
|
||||
RMDEF Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount)
|
||||
RMAPI Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -653,7 +645,7 @@ RMDEF Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount)
|
||||
}
|
||||
|
||||
// Calculate reflected vector to normal
|
||||
RMDEF Vector3 Vector3Reflect(Vector3 v, Vector3 normal)
|
||||
RMAPI Vector3 Vector3Reflect(Vector3 v, Vector3 normal)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -671,7 +663,7 @@ RMDEF Vector3 Vector3Reflect(Vector3 v, Vector3 normal)
|
||||
}
|
||||
|
||||
// Get min value for each pair of components
|
||||
RMDEF Vector3 Vector3Min(Vector3 v1, Vector3 v2)
|
||||
RMAPI Vector3 Vector3Min(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -683,7 +675,7 @@ RMDEF Vector3 Vector3Min(Vector3 v1, Vector3 v2)
|
||||
}
|
||||
|
||||
// Get max value for each pair of components
|
||||
RMDEF Vector3 Vector3Max(Vector3 v1, Vector3 v2)
|
||||
RMAPI Vector3 Vector3Max(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -696,7 +688,7 @@ RMDEF Vector3 Vector3Max(Vector3 v1, Vector3 v2)
|
||||
|
||||
// Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c)
|
||||
// NOTE: Assumes P is on the plane of the triangle
|
||||
RMDEF Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)
|
||||
RMAPI Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -720,7 +712,7 @@ RMDEF Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)
|
||||
|
||||
// Projects a Vector3 from screen space into object space
|
||||
// NOTE: We are avoiding calling other raymath functions despite available
|
||||
RMDEF Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
|
||||
RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -803,7 +795,7 @@ RMDEF Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view)
|
||||
}
|
||||
|
||||
// Get Vector3 as float array
|
||||
RMDEF float3 Vector3ToFloatV(Vector3 v)
|
||||
RMAPI float3 Vector3ToFloatV(Vector3 v)
|
||||
{
|
||||
float3 buffer = { 0 };
|
||||
|
||||
@ -819,7 +811,7 @@ RMDEF float3 Vector3ToFloatV(Vector3 v)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Compute matrix determinant
|
||||
RMDEF float MatrixDeterminant(Matrix mat)
|
||||
RMAPI float MatrixDeterminant(Matrix mat)
|
||||
{
|
||||
float result = 0.0f;
|
||||
|
||||
@ -840,7 +832,7 @@ RMDEF float MatrixDeterminant(Matrix mat)
|
||||
}
|
||||
|
||||
// Get the trace of the matrix (sum of the values along the diagonal)
|
||||
RMDEF float MatrixTrace(Matrix mat)
|
||||
RMAPI float MatrixTrace(Matrix mat)
|
||||
{
|
||||
float result = (mat.m0 + mat.m5 + mat.m10 + mat.m15);
|
||||
|
||||
@ -848,7 +840,7 @@ RMDEF float MatrixTrace(Matrix mat)
|
||||
}
|
||||
|
||||
// Transposes provided matrix
|
||||
RMDEF Matrix MatrixTranspose(Matrix mat)
|
||||
RMAPI Matrix MatrixTranspose(Matrix mat)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -873,7 +865,7 @@ RMDEF Matrix MatrixTranspose(Matrix mat)
|
||||
}
|
||||
|
||||
// Invert provided matrix
|
||||
RMDEF Matrix MatrixInvert(Matrix mat)
|
||||
RMAPI Matrix MatrixInvert(Matrix mat)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -920,7 +912,7 @@ RMDEF Matrix MatrixInvert(Matrix mat)
|
||||
}
|
||||
|
||||
// Normalize provided matrix
|
||||
RMDEF Matrix MatrixNormalize(Matrix mat)
|
||||
RMAPI Matrix MatrixNormalize(Matrix mat)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -959,7 +951,7 @@ RMDEF Matrix MatrixNormalize(Matrix mat)
|
||||
}
|
||||
|
||||
// Get identity matrix
|
||||
RMDEF Matrix MatrixIdentity(void)
|
||||
RMAPI Matrix MatrixIdentity(void)
|
||||
{
|
||||
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
@ -970,7 +962,7 @@ RMDEF Matrix MatrixIdentity(void)
|
||||
}
|
||||
|
||||
// Add two matrices
|
||||
RMDEF Matrix MatrixAdd(Matrix left, Matrix right)
|
||||
RMAPI Matrix MatrixAdd(Matrix left, Matrix right)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -995,7 +987,7 @@ RMDEF Matrix MatrixAdd(Matrix left, Matrix right)
|
||||
}
|
||||
|
||||
// Subtract two matrices (left - right)
|
||||
RMDEF Matrix MatrixSubtract(Matrix left, Matrix right)
|
||||
RMAPI Matrix MatrixSubtract(Matrix left, Matrix right)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -1021,7 +1013,7 @@ RMDEF Matrix MatrixSubtract(Matrix left, Matrix right)
|
||||
|
||||
// Get two matrix multiplication
|
||||
// NOTE: When multiplying matrices... the order matters!
|
||||
RMDEF Matrix MatrixMultiply(Matrix left, Matrix right)
|
||||
RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -1046,7 +1038,7 @@ RMDEF Matrix MatrixMultiply(Matrix left, Matrix right)
|
||||
}
|
||||
|
||||
// Get translation matrix
|
||||
RMDEF Matrix MatrixTranslate(float x, float y, float z)
|
||||
RMAPI Matrix MatrixTranslate(float x, float y, float z)
|
||||
{
|
||||
Matrix result = { 1.0f, 0.0f, 0.0f, x,
|
||||
0.0f, 1.0f, 0.0f, y,
|
||||
@ -1058,7 +1050,7 @@ RMDEF Matrix MatrixTranslate(float x, float y, float z)
|
||||
|
||||
// Create rotation matrix from axis and angle
|
||||
// NOTE: Angle should be provided in radians
|
||||
RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
|
||||
RMAPI Matrix MatrixRotate(Vector3 axis, float angle)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -1102,7 +1094,7 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
|
||||
}
|
||||
|
||||
// Get x-rotation matrix (angle in radians)
|
||||
RMDEF Matrix MatrixRotateX(float angle)
|
||||
RMAPI Matrix MatrixRotateX(float angle)
|
||||
{
|
||||
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
@ -1121,7 +1113,7 @@ RMDEF Matrix MatrixRotateX(float angle)
|
||||
}
|
||||
|
||||
// Get y-rotation matrix (angle in radians)
|
||||
RMDEF Matrix MatrixRotateY(float angle)
|
||||
RMAPI Matrix MatrixRotateY(float angle)
|
||||
{
|
||||
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
@ -1140,7 +1132,7 @@ RMDEF Matrix MatrixRotateY(float angle)
|
||||
}
|
||||
|
||||
// Get z-rotation matrix (angle in radians)
|
||||
RMDEF Matrix MatrixRotateZ(float angle)
|
||||
RMAPI Matrix MatrixRotateZ(float angle)
|
||||
{
|
||||
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
@ -1160,7 +1152,7 @@ RMDEF Matrix MatrixRotateZ(float angle)
|
||||
|
||||
|
||||
// Get xyz-rotation matrix (angles in radians)
|
||||
RMDEF Matrix MatrixRotateXYZ(Vector3 ang)
|
||||
RMAPI Matrix MatrixRotateXYZ(Vector3 ang)
|
||||
{
|
||||
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
@ -1190,7 +1182,7 @@ RMDEF Matrix MatrixRotateXYZ(Vector3 ang)
|
||||
}
|
||||
|
||||
// Get zyx-rotation matrix (angles in radians)
|
||||
RMDEF Matrix MatrixRotateZYX(Vector3 ang)
|
||||
RMAPI Matrix MatrixRotateZYX(Vector3 ang)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -1225,7 +1217,7 @@ RMDEF Matrix MatrixRotateZYX(Vector3 ang)
|
||||
}
|
||||
|
||||
// Get scaling matrix
|
||||
RMDEF Matrix MatrixScale(float x, float y, float z)
|
||||
RMAPI Matrix MatrixScale(float x, float y, float z)
|
||||
{
|
||||
Matrix result = { x, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, y, 0.0f, 0.0f,
|
||||
@ -1236,7 +1228,7 @@ RMDEF Matrix MatrixScale(float x, float y, float z)
|
||||
}
|
||||
|
||||
// Get perspective projection matrix
|
||||
RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far)
|
||||
RMAPI Matrix MatrixFrustum(double left, double right, double bottom, double top, double near, double far)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -1269,7 +1261,7 @@ RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top,
|
||||
|
||||
// Get perspective projection matrix
|
||||
// NOTE: Angle should be provided in radians
|
||||
RMDEF Matrix MatrixPerspective(double fovy, double aspect, double near, double far)
|
||||
RMAPI Matrix MatrixPerspective(double fovy, double aspect, double near, double far)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -1295,7 +1287,7 @@ RMDEF Matrix MatrixPerspective(double fovy, double aspect, double near, double f
|
||||
}
|
||||
|
||||
// Get orthographic projection matrix
|
||||
RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far)
|
||||
RMAPI Matrix MatrixOrtho(double left, double right, double bottom, double top, double near, double far)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -1324,7 +1316,7 @@ RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, d
|
||||
}
|
||||
|
||||
// Get camera look-at matrix (view matrix)
|
||||
RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)
|
||||
RMAPI Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)
|
||||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
@ -1379,7 +1371,7 @@ RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)
|
||||
}
|
||||
|
||||
// Get float array of matrix data
|
||||
RMDEF float16 MatrixToFloatV(Matrix mat)
|
||||
RMAPI float16 MatrixToFloatV(Matrix mat)
|
||||
{
|
||||
float16 result = { 0 };
|
||||
|
||||
@ -1408,7 +1400,7 @@ RMDEF float16 MatrixToFloatV(Matrix mat)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Add two quaternions
|
||||
RMDEF Quaternion QuaternionAdd(Quaternion q1, Quaternion q2)
|
||||
RMAPI Quaternion QuaternionAdd(Quaternion q1, Quaternion q2)
|
||||
{
|
||||
Quaternion result = {q1.x + q2.x, q1.y + q2.y, q1.z + q2.z, q1.w + q2.w};
|
||||
|
||||
@ -1416,7 +1408,7 @@ RMDEF Quaternion QuaternionAdd(Quaternion q1, Quaternion q2)
|
||||
}
|
||||
|
||||
// Add quaternion and float value
|
||||
RMDEF Quaternion QuaternionAddValue(Quaternion q, float add)
|
||||
RMAPI Quaternion QuaternionAddValue(Quaternion q, float add)
|
||||
{
|
||||
Quaternion result = {q.x + add, q.y + add, q.z + add, q.w + add};
|
||||
|
||||
@ -1424,7 +1416,7 @@ RMDEF Quaternion QuaternionAddValue(Quaternion q, float add)
|
||||
}
|
||||
|
||||
// Subtract two quaternions
|
||||
RMDEF Quaternion QuaternionSubtract(Quaternion q1, Quaternion q2)
|
||||
RMAPI Quaternion QuaternionSubtract(Quaternion q1, Quaternion q2)
|
||||
{
|
||||
Quaternion result = {q1.x - q2.x, q1.y - q2.y, q1.z - q2.z, q1.w - q2.w};
|
||||
|
||||
@ -1432,7 +1424,7 @@ RMDEF Quaternion QuaternionSubtract(Quaternion q1, Quaternion q2)
|
||||
}
|
||||
|
||||
// Subtract quaternion and float value
|
||||
RMDEF Quaternion QuaternionSubtractValue(Quaternion q, float sub)
|
||||
RMAPI Quaternion QuaternionSubtractValue(Quaternion q, float sub)
|
||||
{
|
||||
Quaternion result = {q.x - sub, q.y - sub, q.z - sub, q.w - sub};
|
||||
|
||||
@ -1440,7 +1432,7 @@ RMDEF Quaternion QuaternionSubtractValue(Quaternion q, float sub)
|
||||
}
|
||||
|
||||
// Get identity quaternion
|
||||
RMDEF Quaternion QuaternionIdentity(void)
|
||||
RMAPI Quaternion QuaternionIdentity(void)
|
||||
{
|
||||
Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
@ -1448,7 +1440,7 @@ RMDEF Quaternion QuaternionIdentity(void)
|
||||
}
|
||||
|
||||
// Computes the length of a quaternion
|
||||
RMDEF float QuaternionLength(Quaternion q)
|
||||
RMAPI float QuaternionLength(Quaternion q)
|
||||
{
|
||||
float result = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);
|
||||
|
||||
@ -1456,7 +1448,7 @@ RMDEF float QuaternionLength(Quaternion q)
|
||||
}
|
||||
|
||||
// Normalize provided quaternion
|
||||
RMDEF Quaternion QuaternionNormalize(Quaternion q)
|
||||
RMAPI Quaternion QuaternionNormalize(Quaternion q)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1473,7 +1465,7 @@ RMDEF Quaternion QuaternionNormalize(Quaternion q)
|
||||
}
|
||||
|
||||
// Invert provided quaternion
|
||||
RMDEF Quaternion QuaternionInvert(Quaternion q)
|
||||
RMAPI Quaternion QuaternionInvert(Quaternion q)
|
||||
{
|
||||
Quaternion result = q;
|
||||
|
||||
@ -1494,7 +1486,7 @@ RMDEF Quaternion QuaternionInvert(Quaternion q)
|
||||
}
|
||||
|
||||
// Calculate two quaternion multiplication
|
||||
RMDEF Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2)
|
||||
RMAPI Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1510,7 +1502,7 @@ RMDEF Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2)
|
||||
}
|
||||
|
||||
// Scale quaternion by float value
|
||||
RMDEF Quaternion QuaternionScale(Quaternion q, float mul)
|
||||
RMAPI Quaternion QuaternionScale(Quaternion q, float mul)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1525,7 +1517,7 @@ RMDEF Quaternion QuaternionScale(Quaternion q, float mul)
|
||||
}
|
||||
|
||||
// Divide two quaternions
|
||||
RMDEF Quaternion QuaternionDivide(Quaternion q1, Quaternion q2)
|
||||
RMAPI Quaternion QuaternionDivide(Quaternion q1, Quaternion q2)
|
||||
{
|
||||
Quaternion result = { q1.x/q2.x, q1.y/q2.y, q1.z/q2.z, q1.w/q2.w };
|
||||
|
||||
@ -1533,7 +1525,7 @@ RMDEF Quaternion QuaternionDivide(Quaternion q1, Quaternion q2)
|
||||
}
|
||||
|
||||
// Calculate linear interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount)
|
||||
RMAPI Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1546,7 +1538,7 @@ RMDEF Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount)
|
||||
}
|
||||
|
||||
// Calculate slerp-optimized interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
RMAPI Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1571,7 +1563,7 @@ RMDEF Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
}
|
||||
|
||||
// Calculates spherical linear interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
RMAPI Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1613,7 +1605,7 @@ RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
}
|
||||
|
||||
// Calculate quaternion based on the rotation from one vector to another
|
||||
RMDEF Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)
|
||||
RMAPI Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1641,7 +1633,7 @@ RMDEF Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)
|
||||
}
|
||||
|
||||
// Get a quaternion for a given rotation matrix
|
||||
RMDEF Quaternion QuaternionFromMatrix(Matrix mat)
|
||||
RMAPI Quaternion QuaternionFromMatrix(Matrix mat)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1675,7 +1667,7 @@ RMDEF Quaternion QuaternionFromMatrix(Matrix mat)
|
||||
}
|
||||
|
||||
// Get a matrix for a given quaternion
|
||||
RMDEF Matrix QuaternionToMatrix(Quaternion q)
|
||||
RMAPI Matrix QuaternionToMatrix(Quaternion q)
|
||||
{
|
||||
Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
@ -1709,7 +1701,7 @@ RMDEF Matrix QuaternionToMatrix(Quaternion q)
|
||||
|
||||
// Get rotation quaternion for an angle and axis
|
||||
// NOTE: angle must be provided in radians
|
||||
RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
|
||||
RMAPI Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
|
||||
{
|
||||
Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
@ -1754,7 +1746,7 @@ RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
|
||||
}
|
||||
|
||||
// Get the rotation angle and axis for a given quaternion
|
||||
RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)
|
||||
RMAPI void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle)
|
||||
{
|
||||
if (fabs(q.w) > 1.0f)
|
||||
{
|
||||
@ -1792,7 +1784,7 @@ RMDEF void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle
|
||||
|
||||
// Get the quaternion equivalent to Euler angles
|
||||
// NOTE: Rotation order is ZYX
|
||||
RMDEF Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)
|
||||
RMAPI Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
@ -1813,7 +1805,7 @@ RMDEF Quaternion QuaternionFromEuler(float pitch, float yaw, float roll)
|
||||
|
||||
// Get the Euler angles equivalent to quaternion (roll, pitch, yaw)
|
||||
// NOTE: Angles are returned in a Vector3 struct in radians
|
||||
RMDEF Vector3 QuaternionToEuler(Quaternion q)
|
||||
RMAPI Vector3 QuaternionToEuler(Quaternion q)
|
||||
{
|
||||
Vector3 result = { 0 };
|
||||
|
||||
@ -1837,7 +1829,7 @@ RMDEF Vector3 QuaternionToEuler(Quaternion q)
|
||||
}
|
||||
|
||||
// Transform a quaternion given a transformation matrix
|
||||
RMDEF Quaternion QuaternionTransform(Quaternion q, Matrix mat)
|
||||
RMAPI Quaternion QuaternionTransform(Quaternion q, Matrix mat)
|
||||
{
|
||||
Quaternion result = { 0 };
|
||||
|
||||
|
71
src/rlgl.h
71
src/rlgl.h
@ -1,6 +1,6 @@
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* rlgl v4.0
|
||||
* rlgl v4.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
|
||||
*
|
||||
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0)
|
||||
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
|
||||
@ -34,11 +34,11 @@
|
||||
* If not defined, the library is in header only mode and can be included in other headers
|
||||
* or source files without problems. But only ONE file should hold the implementation.
|
||||
*
|
||||
* #define SUPPORT_RENDER_TEXTURES_HINT
|
||||
* #define RLGL_RENDER_TEXTURES_HINT
|
||||
* Enable framebuffer objects (fbo) support (enabled by default)
|
||||
* Some GPUs could not support them despite the OpenGL version
|
||||
*
|
||||
* #define SUPPORT_GL_DETAILS_INFO
|
||||
* #define RLGL_SHOW_GL_DETAILS_INFO
|
||||
* Show OpenGL extensions and capabilities detailed logs on init
|
||||
*
|
||||
* rlgl capabilities could be customized just defining some internal
|
||||
@ -103,17 +103,20 @@
|
||||
#ifndef RLGL_H
|
||||
#define RLGL_H
|
||||
|
||||
#define SUPPORT_RENDER_TEXTURES_HINT
|
||||
#define RLGL_VERSION "4.0"
|
||||
|
||||
// Function specifiers definition
|
||||
#ifndef RLAPI
|
||||
#define RLAPI // We are building or using rlgl as a static library (or Linux shared library)
|
||||
#define RLAPI // Functions defined as 'extern' by default (implicit specifiers)
|
||||
#endif
|
||||
|
||||
// Function specifiers in case library is build/used as a shared library (Windows)
|
||||
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
||||
#if defined(_WIN32)
|
||||
#if defined(BUILD_LIBTYPE_SHARED)
|
||||
#define RLAPI __declspec(dllexport) // We are building rlgl as a Win32 shared library (.dll)
|
||||
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
|
||||
#elif defined(USE_LIBTYPE_SHARED)
|
||||
#define RLAPI __declspec(dllimport) // We are using rlgl as a Win32 shared library (.dll)
|
||||
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -164,6 +167,10 @@
|
||||
#define GRAPHICS_API_OPENGL_33
|
||||
#endif
|
||||
|
||||
// Support framebuffer objects by default
|
||||
// NOTE: Some driver implementation do not support it, despite they should
|
||||
#define RLGL_RENDER_TEXTURES_HINT
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -173,41 +180,41 @@
|
||||
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
|
||||
// This is the maximum amount of elements (quads) per batch
|
||||
// NOTE: Be careful with text, every letter maps to a quad
|
||||
#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192
|
||||
#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192
|
||||
#endif
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
// We reduce memory sizes for embedded systems (RPI and HTML5)
|
||||
// NOTE: On HTML5 (emscripten) this is allocated on heap,
|
||||
// by default it's only 16MB!...just take care...
|
||||
#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 2048
|
||||
#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 2048
|
||||
#endif
|
||||
#endif
|
||||
#ifndef RL_DEFAULT_BATCH_BUFFERS
|
||||
#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||
#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering)
|
||||
#endif
|
||||
#ifndef RL_DEFAULT_BATCH_DRAWCALLS
|
||||
#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||
#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture)
|
||||
#endif
|
||||
#ifndef RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS
|
||||
#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
|
||||
#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
|
||||
#endif
|
||||
|
||||
// Internal Matrix stack
|
||||
#ifndef RL_MAX_MATRIX_STACK_SIZE
|
||||
#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of Matrix stack
|
||||
#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of Matrix stack
|
||||
#endif
|
||||
|
||||
// Shader limits
|
||||
#ifndef RL_MAX_SHADER_LOCATIONS
|
||||
#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||
#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||
#endif
|
||||
|
||||
// Projection matrix culling
|
||||
#ifndef RL_CULL_DISTANCE_NEAR
|
||||
#define RL_CULL_DISTANCE_NEAR 0.01 // Default near cull distance
|
||||
#define RL_CULL_DISTANCE_NEAR 0.01 // Default near cull distance
|
||||
#endif
|
||||
#ifndef RL_CULL_DISTANCE_FAR
|
||||
#define RL_CULL_DISTANCE_FAR 1000.0 // Default far cull distance
|
||||
#define RL_CULL_DISTANCE_FAR 1000.0 // Default far cull distance
|
||||
#endif
|
||||
|
||||
// Texture parameters (equivalent to OpenGL defines)
|
||||
@ -924,9 +931,9 @@ static PFNGLVERTEXATTRIBDIVISOREXTPROC glVertexAttribDivisor = NULL;
|
||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||
static void rlLoadShaderDefault(void); // Load default shader
|
||||
static void rlUnloadShaderDefault(void); // Unload default shader
|
||||
#if defined(SUPPORT_GL_DETAILS_INFO)
|
||||
#if defined(RLGL_SHOW_GL_DETAILS_INFO)
|
||||
static char *rlGetCompressedFormatName(int format); // Get compressed format official GL identifier name
|
||||
#endif // SUPPORT_GL_DETAILS_INFO
|
||||
#endif // RLGL_SHOW_GL_DETAILS_INFO
|
||||
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||
#if defined(GRAPHICS_API_OPENGL_11)
|
||||
static int rlGenTextureMipmapsData(unsigned char *data, int baseWidth, int baseHeight); // Generate mipmaps data on CPU side
|
||||
@ -1536,7 +1543,7 @@ void rlDisableShader(void)
|
||||
// Enable rendering to texture (fbo)
|
||||
void rlEnableFramebuffer(unsigned int id)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, id);
|
||||
#endif
|
||||
}
|
||||
@ -1544,7 +1551,7 @@ void rlEnableFramebuffer(unsigned int id)
|
||||
// Disable rendering to texture
|
||||
void rlDisableFramebuffer(void)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
#endif
|
||||
}
|
||||
@ -1553,7 +1560,7 @@ void rlDisableFramebuffer(void)
|
||||
// NOTE: One color buffer is always active by default
|
||||
void rlActiveDrawBuffers(int count)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) && defined(SUPPORT_RENDER_TEXTURES_HINT))
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) && defined(RLGL_RENDER_TEXTURES_HINT))
|
||||
// NOTE: Maximum number of draw buffers supported is implementation dependant,
|
||||
// it can be queried with glGet*() but it must be at least 8
|
||||
//GLint maxDrawBuffers = 0;
|
||||
@ -1873,7 +1880,7 @@ void rlLoadExtensions(void *loader)
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &numExt);
|
||||
TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt);
|
||||
|
||||
#if defined(SUPPORT_GL_DETAILS_INFO)
|
||||
#if defined(RLGL_SHOW_GL_DETAILS_INFO)
|
||||
// Get supported extensions list
|
||||
// WARNING: glGetStringi() not available on OpenGL 2.1
|
||||
char **extList = RL_MALLOC(numExt*sizeof(char *));
|
||||
@ -1927,7 +1934,7 @@ void rlLoadExtensions(void *loader)
|
||||
|
||||
TRACELOG(RL_LOG_INFO, "GL: Supported extensions count: %i", numExt);
|
||||
|
||||
#if defined(SUPPORT_GL_DETAILS_INFO)
|
||||
#if defined(RLGL_SHOW_GL_DETAILS_INFO)
|
||||
TRACELOG(RL_LOG_INFO, "GL: OpenGL extensions:");
|
||||
for (int i = 0; i < numExt; i++) TRACELOG(RL_LOG_INFO, " %s", extList[i]);
|
||||
#endif
|
||||
@ -2031,7 +2038,7 @@ void rlLoadExtensions(void *loader)
|
||||
#endif
|
||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &RLGL.ExtSupported.maxAnisotropyLevel);
|
||||
|
||||
#if defined(SUPPORT_GL_DETAILS_INFO)
|
||||
#if defined(RLGL_SHOW_GL_DETAILS_INFO)
|
||||
// Show some OpenGL GPU capabilities
|
||||
TRACELOG(RL_LOG_INFO, "GL: OpenGL capabilities:");
|
||||
GLint capability = 0;
|
||||
@ -2063,7 +2070,7 @@ void rlLoadExtensions(void *loader)
|
||||
glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &capability);
|
||||
TRACELOG(RL_LOG_INFO, " GL_MAX_UNIFORM_LOCATIONS: %i", capability);
|
||||
*/
|
||||
#else // SUPPORT_GL_DETAILS_INFO
|
||||
#else // RLGL_SHOW_GL_DETAILS_INFO
|
||||
|
||||
// Show some basic info about GL supported features
|
||||
#if defined(GRAPHICS_API_OPENGL_ES2)
|
||||
@ -2077,7 +2084,7 @@ void rlLoadExtensions(void *loader)
|
||||
if (RLGL.ExtSupported.texCompETC2) TRACELOG(RL_LOG_INFO, "GL: ETC2/EAC compressed textures supported");
|
||||
if (RLGL.ExtSupported.texCompPVRT) TRACELOG(RL_LOG_INFO, "GL: PVRT compressed textures supported");
|
||||
if (RLGL.ExtSupported.texCompASTC) TRACELOG(RL_LOG_INFO, "GL: ASTC compressed textures supported");
|
||||
#endif // SUPPORT_GL_DETAILS_INFO
|
||||
#endif // RLGL_SHOW_GL_DETAILS_INFO
|
||||
|
||||
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||
}
|
||||
@ -3092,7 +3099,7 @@ unsigned int rlLoadFramebuffer(int width, int height)
|
||||
{
|
||||
unsigned int fboId = 0;
|
||||
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT)
|
||||
glGenFramebuffers(1, &fboId); // Create the framebuffer object
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind any framebuffer
|
||||
#endif
|
||||
@ -3104,7 +3111,7 @@ unsigned int rlLoadFramebuffer(int width, int height)
|
||||
// NOTE: Attach type: 0-Color, 1-Depth renderbuffer, 2-Depth texture
|
||||
void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
|
||||
|
||||
switch (attachType)
|
||||
@ -3147,7 +3154,7 @@ bool rlFramebufferComplete(unsigned int id)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, id);
|
||||
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
@ -3178,7 +3185,7 @@ bool rlFramebufferComplete(unsigned int id)
|
||||
// NOTE: All attached textures/cubemaps/renderbuffers are also deleted
|
||||
void rlUnloadFramebuffer(unsigned int id)
|
||||
{
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT)
|
||||
|
||||
// Query depth attachment to automatically delete texture/renderbuffer
|
||||
int depthType = 0, depthId = 0;
|
||||
@ -4124,7 +4131,7 @@ static void rlUnloadShaderDefault(void)
|
||||
TRACELOG(RL_LOG_INFO, "SHADER: [ID %i] Default shader unloaded successfully", RLGL.State.defaultShaderId);
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GL_DETAILS_INFO)
|
||||
#if defined(RLGL_SHOW_GL_DETAILS_INFO)
|
||||
// Get compressed format official GL identifier name
|
||||
static char *rlGetCompressedFormatName(int format)
|
||||
{
|
||||
@ -4203,7 +4210,7 @@ static char *rlGetCompressedFormatName(int format)
|
||||
|
||||
return compName;
|
||||
}
|
||||
#endif // SUPPORT_GL_DETAILS_INFO
|
||||
#endif // RLGL_SHOW_GL_DETAILS_INFO
|
||||
|
||||
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user