move headerfile to root
This commit is contained in:
parent
65901389f1
commit
5c92f41869
64
raylib.h
64
raylib.h
|
|
@ -62,7 +62,7 @@
|
|||
* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2013-2026 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
|
|
@ -570,8 +570,7 @@ typedef enum {
|
|||
} TraceLogLevel;
|
||||
|
||||
// Keyboard keys (US keyboard layout)
|
||||
// NOTE: Use GetKeyPressed() to allow redefining
|
||||
// required keys for alternative layouts
|
||||
// NOTE: Use GetKeyPressed() to allow redefining required keys for alternative layouts
|
||||
typedef enum {
|
||||
KEY_NULL = 0, // Key: NULL, used for no key pressed
|
||||
// Alphanumeric keys
|
||||
|
|
@ -1075,47 +1074,41 @@ RLAPI Matrix GetCameraMatrix(Camera camera); // Get c
|
|||
RLAPI Matrix GetCameraMatrix2D(Camera2D camera); // Get camera 2d transform matrix
|
||||
|
||||
// Timing-related functions
|
||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
RLAPI float GetFrameTime(void); // Get time in seconds for last frame drawn (delta time)
|
||||
RLAPI double GetTime(void); // Get elapsed time in seconds since InitWindow()
|
||||
RLAPI int GetFPS(void); // Get current FPS
|
||||
RLAPI void SetTargetFPS(int fps); // Set target FPS (maximum)
|
||||
RLAPI float GetFrameTime(void); // Get time in seconds for last frame drawn (delta time)
|
||||
RLAPI double GetTime(void); // Get elapsed time in seconds since InitWindow()
|
||||
RLAPI int GetFPS(void); // Get current FPS
|
||||
|
||||
// Custom frame control functions
|
||||
// NOTE: Those functions are intended for advanced users that want full control over the frame processing
|
||||
// By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timing + PollInputEvents()
|
||||
// To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL
|
||||
RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing)
|
||||
RLAPI void PollInputEvents(void); // Register all input events
|
||||
RLAPI void WaitTime(double seconds); // Wait for some time (halt program execution)
|
||||
RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing)
|
||||
RLAPI void PollInputEvents(void); // Register all input events
|
||||
RLAPI void WaitTime(double seconds); // Wait for some time (halt program execution)
|
||||
|
||||
// Random values generation functions
|
||||
RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator
|
||||
RLAPI int GetRandomValue(int min, int max); // Get a random value between min and max (both included)
|
||||
RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator
|
||||
RLAPI int GetRandomValue(int min, int max); // Get a random value between min and max (both included)
|
||||
RLAPI int *LoadRandomSequence(unsigned int count, int min, int max); // Load random values sequence, no values repeated
|
||||
RLAPI void UnloadRandomSequence(int *sequence); // Unload random values sequence
|
||||
RLAPI void UnloadRandomSequence(int *sequence); // Unload random values sequence
|
||||
|
||||
// Misc. functions
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format)
|
||||
RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)
|
||||
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
|
||||
RLAPI void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (filename extension defines format)
|
||||
RLAPI void SetConfigFlags(unsigned int flags); // Setup init configuration flags (view FLAGS)
|
||||
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)
|
||||
|
||||
// NOTE: Following functions implemented in module [utils]
|
||||
//------------------------------------------------------------------
|
||||
RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
|
||||
RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level
|
||||
RLAPI void *MemAlloc(unsigned int size); // Internal memory allocator
|
||||
RLAPI void *MemRealloc(void *ptr, unsigned int size); // Internal memory reallocator
|
||||
RLAPI void MemFree(void *ptr); // Internal memory free
|
||||
// Logging system
|
||||
RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level
|
||||
RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
|
||||
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
|
||||
|
||||
// Set custom callbacks
|
||||
// WARNING: Callbacks setup is intended for advanced users
|
||||
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
|
||||
RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader
|
||||
RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver
|
||||
RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader
|
||||
RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver
|
||||
// Memory management, using internal allocators
|
||||
RLAPI void *MemAlloc(unsigned int size); // Internal memory allocator
|
||||
RLAPI void *MemRealloc(void *ptr, unsigned int size); // Internal memory reallocator
|
||||
RLAPI void MemFree(void *ptr); // Internal memory free
|
||||
|
||||
// Files management functions
|
||||
// File system management functions
|
||||
RLAPI unsigned char *LoadFileData(const char *fileName, int *dataSize); // Load file data as byte array (read)
|
||||
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
|
||||
RLAPI bool SaveFileData(const char *fileName, void *data, int dataSize); // Save data to file from byte array (write), returns true on success
|
||||
|
|
@ -1123,9 +1116,14 @@ RLAPI bool ExportDataAsCode(const unsigned char *data, int dataSize, const char
|
|||
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
|
||||
RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()
|
||||
RLAPI bool SaveFileText(const char *fileName, const char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
|
||||
//------------------------------------------------------------------
|
||||
|
||||
// File system functions
|
||||
// File access custom callbacks
|
||||
// WARNING: Callbacks setup is intended for advanced users
|
||||
RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader
|
||||
RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver
|
||||
RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader
|
||||
RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver
|
||||
|
||||
RLAPI int FileRename(const char *fileName, const char *fileRename); // Rename file (if exists)
|
||||
RLAPI int FileRemove(const char *fileName); // Remove file (if exists)
|
||||
RLAPI int FileCopy(const char *srcPath, const char *dstPath); // Copy file from one path to another, dstPath created if it doesn't exist
|
||||
|
|
|
|||
103
raymath.h
103
raymath.h
|
|
@ -19,20 +19,25 @@
|
|||
*
|
||||
* CONFIGURATION:
|
||||
* #define RAYMATH_IMPLEMENTATION
|
||||
* Generates the implementation of the library into the included file.
|
||||
* 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.
|
||||
* 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.
|
||||
* Define static inline functions code, so #include header suffices for use
|
||||
* This may use up lots of memory
|
||||
*
|
||||
* #define RAYMATH_DISABLE_CPP_OPERATORS
|
||||
* Disables C++ operator overloads for raymath types.
|
||||
*
|
||||
* #define RAYMATH_USE_SIMD_INTRINSICS
|
||||
* Try to enable SIMD intrinsics for MatrixMultiply()
|
||||
* Note that users enabling it must be aware of the target platform where application will
|
||||
* run to support the selected SIMD intrinsic, for now, only SSE is supported
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2015-2025 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2015-2026 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
|
|
@ -79,7 +84,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -170,6 +174,35 @@ typedef struct float16 {
|
|||
|
||||
#include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabsf()
|
||||
|
||||
#if defined(RAYMATH_USE_SIMD_INTRINSICS)
|
||||
// SIMD is used on the most costly raymath function MatrixMultiply()
|
||||
// NOTE: Only SSE intrinsics support implemented
|
||||
// TODO: Consider support for other SIMD instrinsics:
|
||||
// - SSEx, AVX, AVX2, FMA, NEON, RVV
|
||||
/*
|
||||
#if defined(__SSE4_2__)
|
||||
#include <nmmintrin.h>
|
||||
#define RAYMATH_SSE42_ENABLED
|
||||
#elif defined(__SSE4_1__)
|
||||
#include <smmintrin.h>
|
||||
#define RAYMATH_SSE41_ENABLED
|
||||
#elif defined(__SSSE3__)
|
||||
#include <tmmintrin.h>
|
||||
#define RAYMATH_SSSE3_ENABLED
|
||||
#elif defined(__SSE3__)
|
||||
#include <pmmintrin.h>
|
||||
#define RAYMATH_SSE3_ENABLED
|
||||
#elif defined(__SSE2__) || (defined(_M_AMD64) || defined(_M_X64)) // SSE2 x64
|
||||
#include <emmintrin.h>
|
||||
#define RAYMATH_SSE2_ENABLED
|
||||
#endif
|
||||
*/
|
||||
#if defined(__SSE__) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1))
|
||||
#include <xmmintrin.h>
|
||||
#define RAYMATH_SSE_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition - Utils math
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
@ -1648,6 +1681,63 @@ RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)
|
|||
{
|
||||
Matrix result = { 0 };
|
||||
|
||||
#if defined(RAYMATH_SSE_ENABLED)
|
||||
// Load left side and right side
|
||||
__m128 c0 = _mm_set_ps(right.m12, right.m8, right.m4, right.m0);
|
||||
__m128 c1 = _mm_set_ps(right.m13, right.m9, right.m5, right.m1);
|
||||
__m128 c2 = _mm_set_ps(right.m14, right.m10, right.m6, right.m2);
|
||||
__m128 c3 = _mm_set_ps(right.m15, right.m11, right.m7, right.m3);
|
||||
|
||||
// Transpose so c0..c3 become *rows* of the right matrix in semantic order
|
||||
_MM_TRANSPOSE4_PS(c0, c1, c2, c3);
|
||||
|
||||
float tmp[4] = { 0 };
|
||||
__m128 row;
|
||||
|
||||
// Row 0 of result: [m0, m1, m2, m3]
|
||||
row = _mm_mul_ps(_mm_set1_ps(left.m0), c0);
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m1), c1));
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m2), c2));
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m3), c3));
|
||||
_mm_storeu_ps(tmp, row);
|
||||
result.m0 = tmp[0];
|
||||
result.m1 = tmp[1];
|
||||
result.m2 = tmp[2];
|
||||
result.m3 = tmp[3];
|
||||
|
||||
// Row 1 of result: [m4, m5, m6, m7]
|
||||
row = _mm_mul_ps(_mm_set1_ps(left.m4), c0);
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m5), c1));
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m6), c2));
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m7), c3));
|
||||
_mm_storeu_ps(tmp, row);
|
||||
result.m4 = tmp[0];
|
||||
result.m5 = tmp[1];
|
||||
result.m6 = tmp[2];
|
||||
result.m7 = tmp[3];
|
||||
|
||||
// Row 2 of result: [m8, m9, m10, m11]
|
||||
row = _mm_mul_ps(_mm_set1_ps(left.m8), c0);
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m9), c1));
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m10), c2));
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m11), c3));
|
||||
_mm_storeu_ps(tmp, row);
|
||||
result.m8 = tmp[0];
|
||||
result.m9 = tmp[1];
|
||||
result.m10 = tmp[2];
|
||||
result.m11 = tmp[3];
|
||||
|
||||
// Row 3 of result: [m12, m13, m14, m15]
|
||||
row = _mm_mul_ps(_mm_set1_ps(left.m12), c0);
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m13), c1));
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m14), c2));
|
||||
row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m15), c3));
|
||||
_mm_storeu_ps(tmp, row);
|
||||
result.m12 = tmp[0];
|
||||
result.m13 = tmp[1];
|
||||
result.m14 = tmp[2];
|
||||
result.m15 = tmp[3];
|
||||
#else
|
||||
result.m0 = left.m0*right.m0 + left.m1*right.m4 + left.m2*right.m8 + left.m3*right.m12;
|
||||
result.m1 = left.m0*right.m1 + left.m1*right.m5 + left.m2*right.m9 + left.m3*right.m13;
|
||||
result.m2 = left.m0*right.m2 + left.m1*right.m6 + left.m2*right.m10 + left.m3*right.m14;
|
||||
|
|
@ -1664,6 +1754,7 @@ RMAPI Matrix MatrixMultiply(Matrix left, Matrix right)
|
|||
result.m13 = left.m12*right.m1 + left.m13*right.m5 + left.m14*right.m9 + left.m15*right.m13;
|
||||
result.m14 = left.m12*right.m2 + left.m13*right.m6 + left.m14*right.m10 + left.m15*right.m14;
|
||||
result.m15 = left.m12*right.m3 + left.m13*right.m7 + left.m14*right.m11 + left.m15*right.m15;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user