2828* - Android (ARM, ARM64)
2929* > PLATFORM_DESKTOP_WIN32 (Native Win32):
3030* - Windows (Win32, Win64)
31+ * > PLATFORM_MEMORY
32+ * - Memory framebuffer output, using software renderer, no OS required
3133* CONFIGURATION:
3234* #define SUPPORT_DEFAULT_FONT (default)
3335* Default font is loaded on window initialization to be available for the user to render simple text
9294//----------------------------------------------------------------------------------
9395#if (defined(__linux__ ) || defined(PLATFORM_WEB ) || defined(PLATFORM_WEB_RGFW )) && (_XOPEN_SOURCE < 500 )
9496 #undef _XOPEN_SOURCE
95- #define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without gnu ext.
97+ #define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without GNU extensions
9698#endif
9799
98100#if (defined(__linux__ ) || defined(PLATFORM_WEB ) || defined(PLATFORM_WEB_RGFW )) && (_POSIX_C_SOURCE < 199309L )
99101 #undef _POSIX_C_SOURCE
100- #define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
102+ #define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without GNU extensions
101103#endif
102104
103105#include "raylib.h" // Declares module functions
115117#include <time.h> // Required for: time() [Used in InitTimer()]
116118#include <math.h> // Required for: tan() [Used in BeginMode3D()], atan2f() [Used in LoadVrStereoConfig()]
117119
120+ #if defined(PLATFORM_MEMORY )
121+ #define SW_GL_FRAMEBUFFER_COPY_BGRA false
122+ #endif
118123#define RLGL_IMPLEMENTATION
119124#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
120125
155160 #define MAX_PATH 260
156161 #endif
157162
158- struct HINSTANCE__ ;
159- #if defined(__cplusplus )
160- extern "C" {
161- #endif
162- __declspec(dllimport ) unsigned long __stdcall GetModuleFileNameA (struct HINSTANCE__ * hModule , char * lpFilename , unsigned long nSize );
163- __declspec(dllimport ) unsigned long __stdcall GetModuleFileNameW (struct HINSTANCE__ * hModule , wchar_t * lpFilename , unsigned long nSize );
164- __declspec(dllimport ) int __stdcall WideCharToMultiByte (unsigned int cp , unsigned long flags , const wchar_t * widestr , int cchwide , char * str , int cbmb , const char * defchar , int * used_default );
165- __declspec(dllimport ) unsigned int __stdcall timeBeginPeriod (unsigned int uPeriod );
166- __declspec(dllimport ) unsigned int __stdcall timeEndPeriod (unsigned int uPeriod );
167- #if defined(__cplusplus )
168- }
169- #endif
163+ struct HINSTANCE__ ;
164+ #if defined(__cplusplus )
165+ extern "C" {
166+ #endif
167+ __declspec(dllimport ) unsigned long __stdcall GetModuleFileNameA (struct HINSTANCE__ * hModule , char * lpFilename , unsigned long nSize );
168+ __declspec(dllimport ) unsigned long __stdcall GetModuleFileNameW (struct HINSTANCE__ * hModule , wchar_t * lpFilename , unsigned long nSize );
169+ __declspec(dllimport ) int __stdcall WideCharToMultiByte (unsigned int cp , unsigned long flags , const wchar_t * widestr , int cchwide , char * str , int cbmb , const char * defchar , int * used_default );
170+ __declspec(dllimport ) unsigned int __stdcall timeBeginPeriod (unsigned int uPeriod );
171+ __declspec(dllimport ) unsigned int __stdcall timeEndPeriod (unsigned int uPeriod );
172+ #if defined(__cplusplus )
173+ }
174+ #endif
170175#elif defined(__linux__)
171176 #include <unistd.h>
172177#elif defined(__FreeBSD__)
@@ -314,7 +319,8 @@ typedef struct CoreData {
314319 char currentKeyState [MAX_KEYBOARD_KEYS ]; // Registers current frame key state
315320 char previousKeyState [MAX_KEYBOARD_KEYS ]; // Registers previous frame key state
316321
317- // NOTE: Since key press logic involves comparing prev vs cur key state, we need to handle key repeats specially
322+ // NOTE: Since key press logic involves comparing previous vs currrent key state,
323+ // key repeats needs to be handled specially
318324 char keyRepeatInFrame [MAX_KEYBOARD_KEYS ]; // Registers key repeats for current frame
319325
320326 int keyPressedQueue [MAX_KEY_PRESSED_QUEUE ]; // Input keys queue
@@ -547,6 +553,8 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab
547553 #include "platforms/rcore_drm.c"
548554#elif defined(PLATFORM_ANDROID )
549555 #include "platforms/rcore_android.c"
556+ #elif defined(PLATFORM_MEMORY )
557+ #include "platforms/rcore_memory.c"
550558#else
551559 // TODO: Include your custom platform backend!
552560 // i.e software rendering backend or console backend!
@@ -621,6 +629,8 @@ void InitWindow(int width, int height, const char *title)
621629 TRACELOG (LOG_INFO , "Platform backend: NATIVE DRM" );
622630#elif defined(PLATFORM_ANDROID )
623631 TRACELOG (LOG_INFO , "Platform backend: ANDROID" );
632+ #elif defined(PLATFORM_MEMORY )
633+ TRACELOG (LOG_INFO , "Platform backend: MEMORY (No OS)" );
624634#else
625635 // TODO: Include your custom platform backend!
626636 // i.e software rendering backend or console backend!
@@ -2233,13 +2243,15 @@ const char *GetApplicationDirectory(void)
22332243
22342244#if defined(_WIN32 )
22352245 int len = 0 ;
2236- #if defined(UNICODE )
2246+
2247+ #if defined(UNICODE )
22372248 unsigned short widePath [MAX_PATH ];
22382249 len = GetModuleFileNameW (NULL , (wchar_t * )widePath , MAX_PATH );
22392250 len = WideCharToMultiByte (0 , 0 , (wchar_t * )widePath , len , appDir , MAX_PATH , NULL , NULL );
2240- #else
2251+ #else
22412252 len = GetModuleFileNameA (NULL , appDir , MAX_PATH );
2242- #endif
2253+ #endif
2254+
22432255 if (len > 0 )
22442256 {
22452257 for (int i = len ; i >= 0 ; -- i )
@@ -2256,8 +2268,9 @@ const char *GetApplicationDirectory(void)
22562268 appDir [0 ] = '.' ;
22572269 appDir [1 ] = '\\' ;
22582270 }
2259-
2271+
22602272#elif defined(__linux__ )
2273+
22612274 unsigned int size = sizeof (appDir );
22622275 ssize_t len = readlink ("/proc/self/exe" , appDir , size );
22632276
@@ -2277,7 +2290,9 @@ const char *GetApplicationDirectory(void)
22772290 appDir [0 ] = '.' ;
22782291 appDir [1 ] = '/' ;
22792292 }
2293+
22802294#elif defined(__APPLE__ )
2295+
22812296 uint32_t size = sizeof (appDir );
22822297
22832298 if (_NSGetExecutablePath (appDir , & size ) == 0 )
@@ -2297,8 +2312,11 @@ const char *GetApplicationDirectory(void)
22972312 appDir [0 ] = '.' ;
22982313 appDir [1 ] = '/' ;
22992314 }
2315+
23002316#elif defined(__FreeBSD__ )
2301- size_t size = sizeof (appDir );
2317+
2318+ size_t size = sizeof (appD
2319+ ir );
23022320 int mib [4 ] = {CTL_KERN , KERN_PROC , KERN_PROC_PATHNAME , -1 };
23032321
23042322 if (sysctl (mib , 4 , appDir , & size , NULL , 0 ) == 0 )
@@ -2318,7 +2336,6 @@ const char *GetApplicationDirectory(void)
23182336 appDir [0 ] = '.' ;
23192337 appDir [1 ] = '/' ;
23202338 }
2321-
23222339#endif
23232340
23242341 return appDir ;
@@ -3748,20 +3765,20 @@ void InitTimer(void)
37483765 // High resolutions can also prevent the CPU power management system from entering power-saving modes
37493766 // Setting a higher resolution does not improve the accuracy of the high-resolution performance counter
37503767#if defined(_WIN32 ) && defined(SUPPORT_WINMM_HIGHRES_TIMER ) && !defined(SUPPORT_BUSY_WAIT_LOOP ) && !defined(PLATFORM_DESKTOP_SDL )
3751- timeBeginPeriod (1 ); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
3768+ timeBeginPeriod (1 ); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
37523769#endif
37533770
37543771#if defined(__linux__ ) || defined(__FreeBSD__ ) || defined(__OpenBSD__ ) || defined(__EMSCRIPTEN__ )
37553772 struct timespec now = { 0 };
37563773
3757- if (clock_gettime (CLOCK_MONOTONIC , & now ) == 0 ) // Success
3774+ if (clock_gettime (CLOCK_MONOTONIC , & now ) == 0 ) // Success
37583775 {
37593776 CORE .Time .base = (unsigned long long int )now .tv_sec * 1000000000LLU + (unsigned long long int )now .tv_nsec ;
37603777 }
37613778 else TRACELOG (LOG_WARNING , "TIMER: Hi-resolution timer not available" );
37623779#endif
37633780
3764- CORE .Time .previous = GetTime (); // Get time as double
3781+ CORE .Time .previous = GetTime (); // Get time as double
37653782}
37663783
37673784// Set viewport for a provided width and height
@@ -3887,6 +3904,7 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
38873904 if ((strcmp (dp -> d_name , "." ) != 0 ) &&
38883905 (strcmp (dp -> d_name , ".." ) != 0 ))
38893906 {
3907+ // Construct new path from our base path
38903908 #if defined(_WIN32 )
38913909 int pathLength = snprintf (path , MAX_FILEPATH_LENGTH - 1 , "%s\\%s" , basePath , dp -> d_name );
38923910 #else
0 commit comments