summaryrefslogtreecommitdiff
path: root/src/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c1424
1 files changed, 724 insertions, 700 deletions
diff --git a/src/core.c b/src/core.c
index a32b226..05af7c8 100644
--- a/src/core.c
+++ b/src/core.c
@@ -25,7 +25,7 @@ void unloadBuffer( Buffer *buffer ) {
}
/*
-## Core - Window
+## Core - Window-related functions
*/
/*
@@ -467,272 +467,210 @@ int lcoreGetClipboardText( lua_State *L ) {
}
/*
-## Core - Timing
+## Core - Cursor-related functions
*/
/*
-> RL.SetTargetFPS( int fps )
+> RL.ShowCursor()
-Set target FPS (maximum)
+Shows cursor
*/
-int lcoreSetTargetFPS( lua_State *L ) {
- int fps = luaL_checkinteger( L, 1 );
-
- SetTargetFPS( fps );
+int lcoreShowCursor( lua_State *L ) {
+ ShowCursor();
return 0;
}
/*
-> FPS = RL.GetFPS()
-
-Get current FPS
+> RL.HideCursor()
-- Success return int
+Hides cursor
*/
-int lcoreGetFPS( lua_State *L ) {
- lua_pushinteger( L, GetFPS() );
+int lcoreHideCursor( lua_State *L ) {
+ HideCursor();
- return 1;
+ return 0;
}
/*
-> delta = RL.GetFrameTime()
+> hidden = RL.IsCursorHidden()
-Get time in seconds for last frame drawn (Delta time)
+Check if cursor is not visible
-- Success return float
+- Success return bool
*/
-int lcoreGetFrameTime( lua_State *L ) {
- lua_pushnumber( L, GetFrameTime() );
+int lcoreIsCursorHidden( lua_State *L ) {
+ lua_pushboolean( L, IsCursorHidden() );
return 1;
}
/*
-> time = RL.GetTime()
-
-Get elapsed time in seconds since InitWindow()
+> RL.EnableCursor()
-- Success return float
+Enables cursor (unlock cursor)
*/
-int lcoreGetTime( lua_State *L ) {
- lua_pushnumber( L, GetTime() );
+int lcoreEnableCursor( lua_State *L ) {
+ EnableCursor();
- return 1;
+ return 0;
}
/*
-## Core - Misc
-*/
-
-/*
-> RL.TakeScreenshot( string fileName )
+> RL.DisableCursor()
-Takes a screenshot of current screen (filename extension defines format)
+Disables cursor (lock cursor)
*/
-int lcoreTakeScreenshot( lua_State *L ) {
- TakeScreenshot( luaL_checkstring( L, 1 ) );
+int lcoreDisableCursor( lua_State *L ) {
+ DisableCursor();
return 0;
}
/*
-> RL.SetConfigFlags( int flags )
+> onSreen = RL.IsCursorOnScreen()
-Setup init configuration flags (view FLAGS)
-*/
-int lcoreSetConfigFlags( lua_State *L ) {
- unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
+Check if cursor is on the screen
- SetConfigFlags( flag );
+- Success return bool
+*/
+int lcoreIsCursorOnScreen( lua_State *L ) {
+ lua_pushboolean( L, IsCursorOnScreen() );
- return 0;
+ return 1;
}
/*
-> RL.TraceLog( int logLevel, string text )
-
-Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
+## Core - Drawing-related functions
*/
-int lcoreTraceLog( lua_State *L ) {
- int logLevel = luaL_checkinteger( L, 1 );
-
- TraceLog( logLevel, "%s", luaL_checkstring( L, 2 ) );
-
- return 0;
-}
/*
-> RL.SetTraceLogLevel( int logLevel )
+> RL.ClearBackground( Color color )
-Set the current threshold (minimum) log level
+Set background color (framebuffer clear color)
*/
-int lcoreSetTraceLogLevel( lua_State *L ) {
- int logLevel = luaL_checkinteger( L, 1 );
+int lcoreClearBackground( lua_State *L ) {
+ Color color = uluaGetColor( L, 1 );
- SetTraceLogLevel( logLevel );
+ ClearBackground( color );
return 0;
}
/*
-> RL.SetLogLevelInvalid( int logLevel )
+> RL.BeginDrawing()
-Set the log level for bad function calls and invalid data formats.
+Setup canvas (framebuffer) to start drawing
*/
-int lcoreSetLogLevelInvalid( lua_State *L ) {
- state->logLevelInvalid = luaL_checkinteger( L, 1 );
+int lcoreBeginDrawing( lua_State *L ) {
+ BeginDrawing();
return 0;
}
/*
-> logLevel = RL.GetLogLevelInvalid()
-
-Get the log level for bad function calls and invalid data formats.
-
-- Success return int
-*/
-int lcoreGetLogLevelInvalid( lua_State *L ) {
- lua_pushinteger( L, state->logLevelInvalid );
-
- return 1;
-}
-
-/*
-> RL.OpenURL( string url )
+> RL.EndDrawing()
-Open URL with default system browser (If available)
+End canvas drawing and swap buffers (double buffering)
*/
-int lcoreOpenURL( lua_State *L ) {
- OpenURL( luaL_checkstring( L, 1 ) );
+int lcoreEndDrawing( lua_State *L ) {
+ EndDrawing();
return 0;
}
/*
-> enabled = RL.IsGCUnloadEnabled()
-
-Check if Lua garbage collection is set to unload object data
-
-- Success return bool
-*/
-int lcoreIsGCUnloadEnabled( lua_State *L ) {
- lua_pushboolean( L, state->gcUnload );
-
- return 1;
-}
+> RL.BeginMode2D( camera2D camera )
-/*
-## Core - Cursor
+Begin 2D mode with custom camera (2D)
*/
+int lcoreBeginMode2D( lua_State *L ) {
+ Camera2D *camera = uluaGetCamera2D( L, 1 );
-/*
-> RL.ShowCursor()
-
-Shows cursor
-*/
-int lcoreShowCursor( lua_State *L ) {
- ShowCursor();
+ BeginMode2D( *camera );
return 0;
}
/*
-> RL.HideCursor()
+> RL.EndMode2D()
-Hides cursor
+Ends 2D mode with custom camera
*/
-int lcoreHideCursor( lua_State *L ) {
- HideCursor();
+int lcoreEndMode2D( lua_State *L ) {
+ EndMode2D();
return 0;
}
/*
-> hidden = RL.IsCursorHidden()
-
-Check if cursor is not visible
+> RL.BeginMode3D( camera3D camera )
-- Success return bool
+Begin 3D mode with custom camera (3D)
*/
-int lcoreIsCursorHidden( lua_State *L ) {
- lua_pushboolean( L, IsCursorHidden() );
-
- return 1;
-}
-
-/*
-> RL.EnableCursor()
+int lcoreBeginMode3D( lua_State *L ) {
+ Camera3D *camera = uluaGetCamera3D( L, 1 );
-Enables cursor (unlock cursor)
-*/
-int lcoreEnableCursor( lua_State *L ) {
- EnableCursor();
+ BeginMode3D( *camera );
return 0;
}
/*
-> RL.DisableCursor()
+> RL.EndMode3D()
-Disables cursor (lock cursor)
+Ends 3D mode and returns to default 2D orthographic mode
*/
-int lcoreDisableCursor( lua_State *L ) {
- DisableCursor();
+int lcoreEndMode3D( lua_State *L ) {
+ EndMode3D();
return 0;
}
/*
-> onSreen = RL.IsCursorOnScreen()
-
-Check if cursor is on the screen
+> RL.BeginTextureMode( RenderTexture target )
-- Success return bool
+Begin drawing to render texture
*/
-int lcoreIsCursorOnScreen( lua_State *L ) {
- lua_pushboolean( L, IsCursorOnScreen() );
+int lcoreBeginTextureMode( lua_State *L ) {
+ RenderTexture *renderTexture = uluaGetRenderTexture( L, 1 );
- return 1;
-}
+ BeginTextureMode( *renderTexture );
-/*
-## Core - Drawing
-*/
+ return 0;
+}
/*
-> RL.ClearBackground( Color color )
+> RL.EndTextureMode()
-Set background color (framebuffer clear color)
+Ends drawing to render texture
*/
-int lcoreClearBackground( lua_State *L ) {
- Color color = uluaGetColor( L, 1 );
-
- ClearBackground( color );
+int lcoreEndTextureMode( lua_State *L ) {
+ EndTextureMode();
return 0;
}
/*
-> RL.BeginDrawing()
+> RL.BeginShaderMode( Shader shader )
-Setup canvas (framebuffer) to start drawing
+Begin custom shader drawing
*/
-int lcoreBeginDrawing( lua_State *L ) {
- BeginDrawing();
+int lcoreBeginShaderMode( lua_State *L ) {
+ Shader *shader = uluaGetShader( L, 1 );
+
+ BeginShaderMode( *shader );
return 0;
}
/*
-> RL.EndDrawing()
+> RL.EndShaderMode()
-End canvas drawing and swap buffers (double buffering)
+End custom shader drawing (use default shader)
*/
-int lcoreEndDrawing( lua_State *L ) {
- EndDrawing();
+int lcoreEndShaderMode( lua_State *L ) {
+ EndShaderMode();
return 0;
}
@@ -786,7 +724,7 @@ int lcoreEndScissorMode( lua_State *L ) {
}
/*
-## Core - Shader
+## Core - Shader management functions
*/
/*
@@ -854,30 +792,6 @@ int lcoreIsShaderReady( lua_State *L ) {
}
/*
-> RL.BeginShaderMode( Shader shader )
-
-Begin custom shader drawing
-*/
-int lcoreBeginShaderMode( lua_State *L ) {
- Shader *shader = uluaGetShader( L, 1 );
-
- BeginShaderMode( *shader );
-
- return 0;
-}
-
-/*
-> RL.EndShaderMode()
-
-End custom shader drawing (use default shader)
-*/
-int lcoreEndShaderMode( lua_State *L ) {
- EndShaderMode();
-
- return 0;
-}
-
-/*
> location = RL.GetShaderLocation( Shader shader, string uniformName )
Get shader uniform location
@@ -1067,7 +981,637 @@ int lcoreUnloadShader( lua_State *L ) {
}
/*
-## Core - Input-related Keyboard
+## Core - Screen-space-related functions
+*/
+
+/*
+> ray = RL.GetMouseRay( Vector2 mousePosition, Camera3D camera )
+
+Get a ray trace from mouse position
+
+- Success return Ray
+*/
+int lcoreGetMouseRay( lua_State *L ) {
+ Vector2 mousePosition = uluaGetVector2( L, 1 );
+ Camera3D *camera = uluaGetCamera3D( L, 2 );
+
+ uluaPushRay( L, GetMouseRay( mousePosition, *camera ) );
+
+ return 1;
+}
+
+/*
+> matrix = RL.GetCameraMatrix( Camera3D camera )
+
+Get camera transform matrix (view matrix)
+
+- Success return Matrix
+*/
+int lcoreGetCameraMatrix( lua_State *L ) {
+ Camera3D *camera = uluaGetCamera3D( L, 1 );
+
+ uluaPushMatrix( L, GetCameraMatrix( *camera ) );
+
+ return 1;
+}
+
+/*
+> matrix = RL.GetCameraMatrix2D( Camera2D camera )
+
+Get camera 2d transform matrix
+
+- Success return Matrix
+*/
+int lcoreGetCameraMatrix2D( lua_State *L ) {
+ Camera2D *camera = uluaGetCamera2D( L, 1 );
+
+ uluaPushMatrix( L, GetCameraMatrix2D( *camera ) );
+
+ return 1;
+}
+
+/*
+> position = RL.GetWorldToScreen( Vector3 position, Camera3D camera )
+
+Get the screen space position for a 3d world space position
+
+- Success return Vector2
+*/
+int lcoreGetWorldToScreen( lua_State *L ) {
+ Vector3 position = uluaGetVector3( L, 1 );
+ Camera3D *camera = uluaGetCamera3D( L, 2 );
+
+ uluaPushVector2( L, GetWorldToScreen( position, *camera ) );
+
+ return 1;
+}
+
+/*
+> position = RL.GetWorldToScreenEx( Vector3 position, Camera3D camera, Vector2 size )
+
+Get size position for a 3d world space position
+
+- Success return Vector2
+*/
+int lcoreGetWorldToScreenEx( lua_State *L ) {
+ Vector3 position = uluaGetVector3( L, 1 );
+ Camera3D *camera = uluaGetCamera3D( L, 2 );
+ Vector2 size = uluaGetVector2( L, 3 );
+
+ uluaPushVector2( L, GetWorldToScreenEx( position, *camera, size.x, size.y ) );
+
+ return 1;
+}
+
+/*
+> position = RL.GetWorldToScreen2D( Vector2 position, Camera2D camera )
+
+Get the screen space position for a 2d camera world space position
+
+- Success return Vector2
+*/
+int lcoreGetWorldToScreen2D( lua_State *L ) {
+ Vector2 position = uluaGetVector2( L, 1 );
+ Camera2D *camera = uluaGetCamera2D( L, 2 );
+
+ uluaPushVector2( L, GetWorldToScreen2D( position, *camera ) );
+
+ return 1;
+}
+
+/*
+> position = RL.GetScreenToWorld2D( Vector2 position, Camera2D camera )
+
+Get the world space position for a 2d camera screen space position
+
+- Success return Vector2
+*/
+int lcoreGetScreenToWorld2D( lua_State *L ) {
+ Vector2 position = uluaGetVector2( L, 1 );
+ Camera2D *camera = uluaGetCamera2D( L, 2 );
+
+ uluaPushVector2( L, GetScreenToWorld2D( position, *camera ) );
+
+ return 1;
+}
+
+/*
+## Core - Timing-related functions
+*/
+
+/*
+> RL.SetTargetFPS( int fps )
+
+Set target FPS (maximum)
+*/
+int lcoreSetTargetFPS( lua_State *L ) {
+ int fps = luaL_checkinteger( L, 1 );
+
+ SetTargetFPS( fps );
+
+ return 0;
+}
+
+/*
+> FPS = RL.GetFPS()
+
+Get current FPS
+
+- Success return int
+*/
+int lcoreGetFPS( lua_State *L ) {
+ lua_pushinteger( L, GetFPS() );
+
+ return 1;
+}
+
+/*
+> delta = RL.GetFrameTime()
+
+Get time in seconds for last frame drawn (Delta time)
+
+- Success return float
+*/
+int lcoreGetFrameTime( lua_State *L ) {
+ lua_pushnumber( L, GetFrameTime() );
+
+ return 1;
+}
+
+/*
+> time = RL.GetTime()
+
+Get elapsed time in seconds since InitWindow()
+
+- Success return float
+*/
+int lcoreGetTime( lua_State *L ) {
+ lua_pushnumber( L, GetTime() );
+
+ return 1;
+}
+
+/*
+## Core - Misc
+*/
+
+/*
+> RL.TakeScreenshot( string fileName )
+
+Takes a screenshot of current screen (filename extension defines format)
+*/
+int lcoreTakeScreenshot( lua_State *L ) {
+ TakeScreenshot( luaL_checkstring( L, 1 ) );
+
+ return 0;
+}
+
+/*
+> RL.SetConfigFlags( int flags )
+
+Setup init configuration flags (view FLAGS)
+*/
+int lcoreSetConfigFlags( lua_State *L ) {
+ unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
+
+ SetConfigFlags( flag );
+
+ return 0;
+}
+
+/*
+> RL.TraceLog( int logLevel, string text )
+
+Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
+*/
+int lcoreTraceLog( lua_State *L ) {
+ int logLevel = luaL_checkinteger( L, 1 );
+
+ TraceLog( logLevel, "%s", luaL_checkstring( L, 2 ) );
+
+ return 0;
+}
+
+/*
+> RL.SetTraceLogLevel( int logLevel )
+
+Set the current threshold (minimum) log level
+*/
+int lcoreSetTraceLogLevel( lua_State *L ) {
+ int logLevel = luaL_checkinteger( L, 1 );
+
+ SetTraceLogLevel( logLevel );
+
+ return 0;
+}
+
+/*
+> RL.SetLogLevelInvalid( int logLevel )
+
+Set the log level for bad function calls and invalid data formats.
+*/
+int lcoreSetLogLevelInvalid( lua_State *L ) {
+ state->logLevelInvalid = luaL_checkinteger( L, 1 );
+
+ return 0;
+}
+
+/*
+> logLevel = RL.GetLogLevelInvalid()
+
+Get the log level for bad function calls and invalid data formats.
+
+- Success return int
+*/
+int lcoreGetLogLevelInvalid( lua_State *L ) {
+ lua_pushinteger( L, state->logLevelInvalid );
+
+ return 1;
+}
+
+/*
+> RL.OpenURL( string url )
+
+Open URL with default system browser (If available)
+*/
+int lcoreOpenURL( lua_State *L ) {
+ OpenURL( luaL_checkstring( L, 1 ) );
+
+ return 0;
+}
+
+/*
+> enabled = RL.IsGCUnloadEnabled()
+
+Check if Lua garbage collection is set to unload object data
+
+- Success return bool
+*/
+int lcoreIsGCUnloadEnabled( lua_State *L ) {
+ lua_pushboolean( L, state->gcUnload );
+
+ return 1;
+}
+
+/*
+## Core - Files management functions
+*/
+
+/*
+> path = RL.GetBasePath()
+
+Return game directory (where main.lua is located)
+
+- Success return string
+*/
+int lcoreGetBasePath( lua_State *L ) {
+ lua_pushstring( L, state->exePath );
+
+ return 1;
+}
+
+/*
+> fileExists = RL.FileExists( string fileName )
+
+Check if file exists
+
+- Success return bool
+*/
+int lcoreFileExists( lua_State *L ) {
+ lua_pushboolean( L, FileExists( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> dirExists = RL.DirectoryExists( string dirPath )
+
+Check if a directory path exists
+
+- Success return bool
+*/
+int lcoreDirectoryExists( lua_State *L ) {
+ lua_pushboolean( L, DirectoryExists( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> hasFileExtension = RL.IsFileExtension( string fileName, string ext )
+
+Check file extension (Including point: .png, .wav)
+
+- Success return bool
+*/
+int lcoreIsFileExtension( lua_State *L ) {
+ lua_pushboolean( L, IsFileExtension( luaL_checkstring( L, 1 ), luaL_checkstring( L, 2 ) ) );
+
+ return 1;
+}
+
+/*
+> length = RL.GetFileLength( string fileName )
+
+Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
+
+- Success return int
+*/
+int lcoreGetFileLength( lua_State *L ) {
+ lua_pushinteger( L, GetFileLength( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> extension = RL.GetFileExtension( string fileName )
+
+Get pointer to extension for a filename string (Includes dot: '.png')
+
+- Success return string
+*/
+int lcoreGetFileExtension( lua_State *L ) {
+ lua_pushstring( L, GetFileExtension( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> fileName = RL.GetFileName( string filePath )
+
+Get pointer to filename for a path string
+
+- Success return string
+*/
+int lcoreGetFileName( lua_State *L ) {
+ lua_pushstring( L, GetFileName( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> fileName = RL.GetFileNameWithoutExt( string filePath )
+
+Get filename string without extension (Uses static string)
+
+- Success return string
+*/
+int lcoreGetFileNameWithoutExt( lua_State *L ) {
+ lua_pushstring( L, GetFileNameWithoutExt( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> filePath = RL.GetDirectoryPath( string filePath )
+
+Get full path for a given fileName with path (Uses static string)
+
+- Success return string
+*/
+int lcoreGetDirectoryPath( lua_State *L ) {
+ lua_pushstring( L, GetDirectoryPath( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> directory = RL.GetPrevDirectoryPath( string dirPath )
+
+Get previous directory path for a given path (Uses static string)
+
+- Success return string
+*/
+int lcoreGetPrevDirectoryPath( lua_State *L ) {
+ lua_pushstring( L, GetPrevDirectoryPath( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> directory = RL.GetWorkingDirectory()
+
+Get current working directory (Uses static string)
+
+- Success return string
+*/
+int lcoreGetWorkingDirectory( lua_State *L ) {
+ lua_pushstring( L, GetWorkingDirectory() );
+
+ return 1;
+}
+
+/*
+> fileNames = RL.LoadDirectoryFiles( string dirPath )
+
+Load directory filepaths
+
+- Success return string{}
+*/
+int lcoreLoadDirectoryFiles( lua_State *L ) {
+ FilePathList files = LoadDirectoryFiles( luaL_checkstring( L, 1 ) );
+
+ lua_createtable( L, files.count, 0 );
+
+ for ( int i = 0; i < files.count; ++i ) {
+ lua_pushstring( L, files.paths[i] );
+ lua_rawseti( L, -2, i+1 );
+ }
+ UnloadDirectoryFiles( files );
+
+ return 1;
+}
+
+/*
+> fileNames = RL.LoadDirectoryFilesEx( string basePath, string filter, bool scanSubdirs )
+
+Load directory filepaths with extension filtering and recursive directory scan
+
+- Success return string{}
+*/
+int lcoreLoadDirectoryFilesEx( lua_State *L ) {
+ bool scanSubdirs = uluaGetBoolean( L, 3 );
+
+ FilePathList files = LoadDirectoryFilesEx( luaL_checkstring( L, 1 ), luaL_checkstring( L, 2 ), scanSubdirs );
+
+ lua_createtable( L, files.count, 0 );
+
+ for ( int i = 0; i < files.count; ++i ) {
+ lua_pushstring( L, files.paths[i] );
+ lua_rawseti( L, -2, i+1 );
+ }
+ UnloadDirectoryFiles( files );
+
+ return 1;
+}
+
+/*
+> success = RL.ChangeDirectory( string directory )
+
+Change working directory, return true on success
+
+- Success return bool
+*/
+int lcoreChangeDirectory( lua_State *L ) {
+ lua_pushboolean( L, ChangeDirectory( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> isFile = RL.IsPathFile( string path )
+
+Check if a given path is a file or a directory
+
+- Success return bool
+*/
+int lcoreIsPathFile( lua_State *L ) {
+ lua_pushboolean( L, IsPathFile( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> iSFileDropped = RL.IsFileDropped()
+
+Check if a file has been dropped into window
+
+- Success return bool
+*/
+int lcoreIsFileDropped( lua_State *L ) {
+ lua_pushboolean( L, IsFileDropped() );
+
+ return 1;
+}
+
+/*
+> files = RL.LoadDroppedFiles()
+
+Load dropped filepaths
+
+- Success return string{}
+*/
+int lcoreLoadDroppedFiles( lua_State *L ) {
+ FilePathList files = LoadDroppedFiles();
+
+ lua_createtable( L, files.count, 0 );
+
+ for ( int i = 0; i < files.count; ++i ) {
+ lua_pushstring( L, files.paths[i] );
+ lua_rawseti( L, -2, i+1 );
+ }
+ UnloadDroppedFiles( files );
+
+ return 1;
+}
+
+/*
+> time = RL.GetFileModTime( string fileName )
+
+Get file modification time (Last write time)
+
+- Success return int
+*/
+int lcoreGetFileModTime( lua_State *L ) {
+ lua_pushinteger( L, GetFileModTime( luaL_checkstring( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+## Core - Compression/Encoding functionality
+*/
+
+/*
+> compData = RL.CompressData( Buffer buffer )
+
+Compress data (DEFLATE algorithm)
+
+- Success return Buffer
+*/
+int lcoreCompressData( lua_State *L ) {
+ Buffer *inBuffer = uluaGetBuffer( L, 1 );
+ Buffer outBuffer = {
+ .size = 0,
+ .type = inBuffer->type
+ };
+ unsigned char *compData = CompressData( inBuffer->data, inBuffer->size, (int*)&outBuffer.size );
+
+ outBuffer.data = malloc( outBuffer.size );
+ memcpy( outBuffer.data, compData, outBuffer.size );
+ uluaPushBuffer( L, outBuffer );
+
+ free( compData );
+
+ return 1;
+}
+
+/*
+> decompData = RL.DecompressData( Buffer compData )
+
+Decompress data (DEFLATE algorithm).
+
+- Success Buffer
+*/
+int lcoreDecompressData( lua_State *L ) {
+ Buffer *inBuffer = uluaGetBuffer( L, 1 );
+ Buffer outBuffer = {
+ .size = 0,
+ .type = inBuffer->type
+ };
+ unsigned char *data = DecompressData( inBuffer->data, inBuffer->size, (int*)&outBuffer.size );
+
+ outBuffer.data = malloc( outBuffer.size );
+ memcpy( outBuffer.data, data, outBuffer.size );
+ uluaPushBuffer( L, outBuffer );
+
+ free( data );
+
+ return 1;
+}
+
+/*
+> encodedData, outputSize = RL.EncodeDataBase64( string data )
+
+Encode data to Base64 string
+
+- Success return string, int
+*/
+int lcoreEncodeDataBase64( lua_State *L ) {
+ int dataSize = 0;
+ const char *string = luaL_checklstring( L, 1, (size_t*)&dataSize );
+
+ int outputSize = 0;
+ char *compData = EncodeDataBase64( string, dataSize, &outputSize );
+
+ lua_pushstring( L, compData );
+ lua_pushinteger( L, outputSize );
+
+ free( compData );
+
+ return 2;
+}
+
+/*
+> decodedData, outputSize = RL.DecodeDataBase64( string data )
+
+Decode Base64 string data
+
+- Success return string, int
+*/
+int lcoreDecodeDataBase64( lua_State *L ) {
+ int outputSize = 0;
+ unsigned char *decodedData = DecodeDataBase64( luaL_checkstring( L, 1 ), &outputSize );
+
+ lua_pushstring( L, decodedData );
+ lua_pushinteger( L, outputSize );
+
+ free( decodedData );
+
+ return 2;
+}
+
+/*
+## Core - Input-related functions: keyboard
*/
/*
@@ -1220,7 +1764,7 @@ int lcoreGetKeyScancode( lua_State *L ) {
}
/*
-## Core - Input-related Gamepad
+## Core - Input-related functions: gamepads
*/
/*
@@ -1333,7 +1877,7 @@ int lcoreGetGamepadName( lua_State *L ) {
}
/*
-## Core - Input-related Mouse
+## Core - Input-related functions: mouse
*/
/*
@@ -1488,7 +2032,7 @@ int lcoreSetMouseCursor( lua_State *L ) {
}
/*
-## Core - Input-related Touch
+## Core - Input-related functions: touch
*/
/*
@@ -1535,7 +2079,7 @@ int lcoreGetTouchPointCount( lua_State *L ) {
}
/*
-## Core - Input-related Gestures
+## Core - Input-related functions: gestures
*/
/*
@@ -1645,364 +2189,7 @@ int lcoreGetGesturePinchAngle( lua_State *L ) {
}
/*
-## Core - File
-*/
-
-/*
-> path = RL.GetBasePath()
-
-Return game directory (where main.lua is located)
-
-- Success return string
-*/
-int lcoreGetBasePath( lua_State *L ) {
- lua_pushstring( L, state->exePath );
-
- return 1;
-}
-
-/*
-> fileExists = RL.FileExists( string fileName )
-
-Check if file exists
-
-- Success return bool
-*/
-int lcoreFileExists( lua_State *L ) {
- lua_pushboolean( L, FileExists( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> dirExists = RL.DirectoryExists( string dirPath )
-
-Check if a directory path exists
-
-- Success return bool
-*/
-int lcoreDirectoryExists( lua_State *L ) {
- lua_pushboolean( L, DirectoryExists( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> hasFileExtension = RL.IsFileExtension( string fileName, string ext )
-
-Check file extension (Including point: .png, .wav)
-
-- Success return bool
-*/
-int lcoreIsFileExtension( lua_State *L ) {
- lua_pushboolean( L, IsFileExtension( luaL_checkstring( L, 1 ), luaL_checkstring( L, 2 ) ) );
-
- return 1;
-}
-
-/*
-> length = RL.GetFileLength( string fileName )
-
-Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
-
-- Success return int
-*/
-int lcoreGetFileLength( lua_State *L ) {
- lua_pushinteger( L, GetFileLength( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> extension = RL.GetFileExtension( string fileName )
-
-Get pointer to extension for a filename string (Includes dot: '.png')
-
-- Success return string
-*/
-int lcoreGetFileExtension( lua_State *L ) {
- lua_pushstring( L, GetFileExtension( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> fileName = RL.GetFileName( string filePath )
-
-Get pointer to filename for a path string
-
-- Success return string
-*/
-int lcoreGetFileName( lua_State *L ) {
- lua_pushstring( L, GetFileName( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> fileName = RL.GetFileNameWithoutExt( string filePath )
-
-Get filename string without extension (Uses static string)
-
-- Success return string
-*/
-int lcoreGetFileNameWithoutExt( lua_State *L ) {
- lua_pushstring( L, GetFileNameWithoutExt( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> filePath = RL.GetDirectoryPath( string filePath )
-
-Get full path for a given fileName with path (Uses static string)
-
-- Success return string
-*/
-int lcoreGetDirectoryPath( lua_State *L ) {
- lua_pushstring( L, GetDirectoryPath( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> directory = RL.GetPrevDirectoryPath( string dirPath )
-
-Get previous directory path for a given path (Uses static string)
-
-- Success return string
-*/
-int lcoreGetPrevDirectoryPath( lua_State *L ) {
- lua_pushstring( L, GetPrevDirectoryPath( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> directory = RL.GetWorkingDirectory()
-
-Get current working directory (Uses static string)
-
-- Success return string
-*/
-int lcoreGetWorkingDirectory( lua_State *L ) {
- lua_pushstring( L, GetWorkingDirectory() );
-
- return 1;
-}
-
-/*
-> fileNames = RL.LoadDirectoryFiles( string dirPath )
-
-Load directory filepaths
-
-- Success return string{}
-*/
-int lcoreLoadDirectoryFiles( lua_State *L ) {
- FilePathList files = LoadDirectoryFiles( luaL_checkstring( L, 1 ) );
-
- lua_createtable( L, files.count, 0 );
-
- for ( int i = 0; i < files.count; ++i ) {
- lua_pushstring( L, files.paths[i] );
- lua_rawseti( L, -2, i+1 );
- }
- UnloadDirectoryFiles( files );
-
- return 1;
-}
-
-/*
-> fileNames = RL.LoadDirectoryFilesEx( string basePath, string filter, bool scanSubdirs )
-
-Load directory filepaths with extension filtering and recursive directory scan
-
-- Success return string{}
-*/
-int lcoreLoadDirectoryFilesEx( lua_State *L ) {
- bool scanSubdirs = uluaGetBoolean( L, 3 );
-
- FilePathList files = LoadDirectoryFilesEx( luaL_checkstring( L, 1 ), luaL_checkstring( L, 2 ), scanSubdirs );
-
- lua_createtable( L, files.count, 0 );
-
- for ( int i = 0; i < files.count; ++i ) {
- lua_pushstring( L, files.paths[i] );
- lua_rawseti( L, -2, i+1 );
- }
- UnloadDirectoryFiles( files );
-
- return 1;
-}
-
-/*
-> success = RL.ChangeDirectory( string directory )
-
-Change working directory, return true on success
-
-- Success return bool
-*/
-int lcoreChangeDirectory( lua_State *L ) {
- lua_pushboolean( L, ChangeDirectory( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> isFile = RL.IsPathFile( string path )
-
-Check if a given path is a file or a directory
-
-- Success return bool
-*/
-int lcoreIsPathFile( lua_State *L ) {
- lua_pushboolean( L, IsPathFile( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-> iSFileDropped = RL.IsFileDropped()
-
-Check if a file has been dropped into window
-
-- Success return bool
-*/
-int lcoreIsFileDropped( lua_State *L ) {
- lua_pushboolean( L, IsFileDropped() );
-
- return 1;
-}
-
-/*
-> files = RL.LoadDroppedFiles()
-
-Load dropped filepaths
-
-- Success return string{}
-*/
-int lcoreLoadDroppedFiles( lua_State *L ) {
- FilePathList files = LoadDroppedFiles();
-
- lua_createtable( L, files.count, 0 );
-
- for ( int i = 0; i < files.count; ++i ) {
- lua_pushstring( L, files.paths[i] );
- lua_rawseti( L, -2, i+1 );
- }
- UnloadDroppedFiles( files );
-
- return 1;
-}
-
-/*
-> time = RL.GetFileModTime( string fileName )
-
-Get file modification time (Last write time)
-
-- Success return int
-*/
-int lcoreGetFileModTime( lua_State *L ) {
- lua_pushinteger( L, GetFileModTime( luaL_checkstring( L, 1 ) ) );
-
- return 1;
-}
-
-/*
-## Core - Compression/Encoding functionality
-*/
-
-/*
-> compData = RL.CompressData( Buffer buffer )
-
-Compress data (DEFLATE algorithm)
-
-- Success return Buffer
-*/
-int lcoreCompressData( lua_State *L ) {
- Buffer *inBuffer = uluaGetBuffer( L, 1 );
- Buffer outBuffer = {
- .size = 0,
- .type = inBuffer->type
- };
- unsigned char *compData = CompressData( inBuffer->data, inBuffer->size, (int*)&outBuffer.size );
-
- outBuffer.data = malloc( outBuffer.size );
- memcpy( outBuffer.data, compData, outBuffer.size );
- uluaPushBuffer( L, outBuffer );
-
- free( compData );
-
- return 1;
-}
-
-/*
-> decompData = RL.DecompressData( Buffer compData )
-
-Decompress data (DEFLATE algorithm).
-
-- Success Buffer
-*/
-int lcoreDecompressData( lua_State *L ) {
- Buffer *inBuffer = uluaGetBuffer( L, 1 );
- Buffer outBuffer = {
- .size = 0,
- .type = inBuffer->type
- };
- unsigned char *data = DecompressData( inBuffer->data, inBuffer->size, (int*)&outBuffer.size );
-
- outBuffer.data = malloc( outBuffer.size );
- memcpy( outBuffer.data, data, outBuffer.size );
- uluaPushBuffer( L, outBuffer );
-
- free( data );
-
- return 1;
-}
-
-/*
-> encodedData, outputSize = RL.EncodeDataBase64( string data )
-
-Encode data to Base64 string
-
-- Success return string, int
-*/
-int lcoreEncodeDataBase64( lua_State *L ) {
- int dataSize = 0;
- const char *string = luaL_checklstring( L, 1, (size_t*)&dataSize );
-
- int outputSize = 0;
- char *compData = EncodeDataBase64( string, dataSize, &outputSize );
-
- lua_pushstring( L, compData );
- lua_pushinteger( L, outputSize );
-
- free( compData );
-
- return 2;
-}
-
-/*
-> decodedData, outputSize = RL.DecodeDataBase64( string data )
-
-Decode Base64 string data
-
-- Success return string, int
-*/
-int lcoreDecodeDataBase64( lua_State *L ) {
- int outputSize = 0;
- unsigned char *decodedData = DecodeDataBase64( luaL_checkstring( L, 1 ), &outputSize );
-
- lua_pushstring( L, decodedData );
- lua_pushinteger( L, outputSize );
-
- free( decodedData );
-
- return 2;
-}
-
-/*
-## Core - Camera2D
+## Core - Camera2D System functions
*/
/*
@@ -2026,30 +2213,6 @@ int lcoreCreateCamera2D( lua_State *L ) {
}
/*
-> RL.BeginMode2D( camera2D camera )
-
-Begin 2D mode with custom camera (2D)
-*/
-int lcoreBeginMode2D( lua_State *L ) {
- Camera2D *camera = uluaGetCamera2D( L, 1 );
-
- BeginMode2D( *camera );
-
- return 0;
-}
-
-/*
-> RL.EndMode2D()
-
-Ends 2D mode with custom camera
-*/
-int lcoreEndMode2D( lua_State *L ) {
- EndMode2D();
-
- return 0;
-}
-
-/*
> RL.SetCamera2DTarget( camera2D camera, Vector2 target )
Set camera target (rotation and zoom origin)
@@ -2163,7 +2326,7 @@ int lcoreGetCamera2DZoom( lua_State *L ) {
}
/*
-## Core - Camera3D
+## Core - Camera3D System functions
*/
/*
@@ -2188,30 +2351,6 @@ int lcoreCreateCamera3D( lua_State *L ) {
}
/*
-> RL.BeginMode3D( camera3D camera )
-
-Begin 3D mode with custom camera (3D)
-*/
-int lcoreBeginMode3D( lua_State *L ) {
- Camera3D *camera = uluaGetCamera3D( L, 1 );
-
- BeginMode3D( *camera );
-
- return 0;
-}
-
-/*
-> RL.EndMode3D()
-
-Ends 3D mode and returns to default 2D orthographic mode
-*/
-int lcoreEndMode3D( lua_State *L ) {
- EndMode3D();
-
- return 0;
-}
-
-/*
> RL.SetCamera3DPosition( camera3D camera, Vector3 position )
Set camera position (Remember to call "RL.UpdateCamera3D()" to apply changes)
@@ -2577,122 +2716,7 @@ int lcoreUpdateCamera3DPro( lua_State *L ) {
}
/*
-## Core - Screen-space
-*/
-
-/*
-> ray = RL.GetMouseRay( Vector2 mousePosition, Camera3D camera )
-
-Get a ray trace from mouse position
-
-- Success return Ray
-*/
-int lcoreGetMouseRay( lua_State *L ) {
- Vector2 mousePosition = uluaGetVector2( L, 1 );
- Camera3D *camera = uluaGetCamera3D( L, 2 );
-
- uluaPushRay( L, GetMouseRay( mousePosition, *camera ) );
-
- return 1;
-}
-
-/*
-> matrix = RL.GetCameraMatrix( Camera3D camera )
-
-Get camera transform matrix (view matrix)
-
-- Success return Matrix
-*/
-int lcoreGetCameraMatrix( lua_State *L ) {
- Camera3D *camera = uluaGetCamera3D( L, 1 );
-
- uluaPushMatrix( L, GetCameraMatrix( *camera ) );
-
- return 1;
-}
-
-/*
-> matrix = RL.GetCameraMatrix2D( Camera2D camera )
-
-Get camera 2d transform matrix
-
-- Success return Matrix
-*/
-int lcoreGetCameraMatrix2D( lua_State *L ) {
- Camera2D *camera = uluaGetCamera2D( L, 1 );
-
- uluaPushMatrix( L, GetCameraMatrix2D( *camera ) );
-
- return 1;
-}
-
-/*
-> position = RL.GetWorldToScreen( Vector3 position, Camera3D camera )
-
-Get the screen space position for a 3d world space position
-
-- Success return Vector2
-*/
-int lcoreGetWorldToScreen( lua_State *L ) {
- Vector3 position = uluaGetVector3( L, 1 );
- Camera3D *camera = uluaGetCamera3D( L, 2 );
-
- uluaPushVector2( L, GetWorldToScreen( position, *camera ) );
-
- return 1;
-}
-
-/*
-> position = RL.GetWorldToScreenEx( Vector3 position, Camera3D camera, Vector2 size )
-
-Get size position for a 3d world space position
-
-- Success return Vector2
-*/
-int lcoreGetWorldToScreenEx( lua_State *L ) {
- Vector3 position = uluaGetVector3( L, 1 );
- Camera3D *camera = uluaGetCamera3D( L, 2 );
- Vector2 size = uluaGetVector2( L, 3 );
-
- uluaPushVector2( L, GetWorldToScreenEx( position, *camera, size.x, size.y ) );
-
- return 1;
-}
-
-/*
-> position = RL.GetWorldToScreen2D( Vector2 position, Camera2D camera )
-
-Get the screen space position for a 2d camera world space position
-
-- Success return Vector2
-*/
-int lcoreGetWorldToScreen2D( lua_State *L ) {
- Vector2 position = uluaGetVector2( L, 1 );
- Camera2D *camera = uluaGetCamera2D( L, 2 );
-
- uluaPushVector2( L, GetWorldToScreen2D( position, *camera ) );
-
- return 1;
-}
-
-/*
-> position = RL.GetScreenToWorld2D( Vector2 position, Camera2D camera )
-
-Get the world space position for a 2d camera screen space position
-
-- Success return Vector2
-*/
-int lcoreGetScreenToWorld2D( lua_State *L ) {
- Vector2 position = uluaGetVector2( L, 1 );
- Camera2D *camera = uluaGetCamera2D( L, 2 );
-
- uluaPushVector2( L, GetScreenToWorld2D( position, *camera ) );
-
- return 1;
-}
-
-/*
-## Core - Buffer
+## Core - Buffer management functions
*/
/*