summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio.c76
-rw-r--r--src/core.c454
-rw-r--r--src/lua_core.c58
-rw-r--r--src/shapes.c67
-rw-r--r--src/state.c1
-rw-r--r--src/text.c29
-rw-r--r--src/textures.c85
7 files changed, 537 insertions, 233 deletions
diff --git a/src/audio.c b/src/audio.c
index 0b793b2..ef466cb 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -8,6 +8,41 @@
*/
/*
+> RL.InitAudioDevice()
+
+Initialize audio device and context
+*/
+int laudioInitAudioDevice( lua_State *L ) {
+ InitAudioDevice();
+
+ return 0;
+}
+
+/*
+> RL.CloseAudioDevice()
+
+Close the audio device and context
+*/
+int laudioCloseAudioDevice( lua_State *L ) {
+ CloseAudioDevice();
+
+ return 0;
+}
+
+/*
+> isReady = RL.IsAudioDeviceReady()
+
+Check if audio device has been initialized successfully
+
+- Success return bool
+*/
+int laudioIsAudioDeviceReady( lua_State *L ) {
+ lua_pushboolean( L, IsAudioDeviceReady() );
+
+ return 1;
+}
+
+/*
> RL.SetMasterVolume( float volume )
Set master volume (listener)
@@ -21,6 +56,19 @@ int laudioSetMasterVolume( lua_State *L ) {
}
/*
+> isReady = RL.GetMasterVolume()
+
+Get master volume (listener)
+
+- Success return float
+*/
+int laudioGetMasterVolume( lua_State *L ) {
+ lua_pushnumber( L, GetMasterVolume() );
+
+ return 1;
+}
+
+/*
## Audio - Wave/Sound loading/unloading functions
*/
@@ -95,6 +143,21 @@ int laudioLoadSoundFromWave( lua_State *L ) {
}
/*
+> sound = RL.LoadSoundAlias( Sound source )
+
+Create a new sound that shares the same sample data as the source sound, does not own the sound data
+
+- Success return Sound
+*/
+int laudioLoadSoundAlias( lua_State *L ) {
+ Sound *source = uluaGetSound( L, 1 );
+
+ uluaPushSound( L, LoadSoundAlias( *source ) );
+
+ return 1;
+}
+
+/*
> isReady = RL.IsSoundReady( Sound sound )
Checks if a sound is ready
@@ -136,6 +199,19 @@ int laudioUnloadSound( lua_State *L ) {
}
/*
+> RL.UnloadSoundAlias( Sound alias )
+
+Unload a sound alias (does not deallocate sample data)
+*/
+int laudioUnloadSoundAlias( lua_State *L ) {
+ Sound *alias = uluaGetSound( L, 1 );
+
+ UnloadSoundAlias( *alias );
+
+ return 0;
+}
+
+/*
> success = RL.ExportWave( Wave wave, string fileName )
Export wave data to file, returns true on success
diff --git a/src/core.c b/src/core.c
index 4271e68..2ad6bf8 100644
--- a/src/core.c
+++ b/src/core.c
@@ -29,6 +29,17 @@ void unloadBuffer( Buffer *buffer ) {
*/
/*
+> RL.CloseWindow()
+
+Close window and unload OpenGL context and free all resources
+*/
+int lcoreCloseWindow( lua_State *L ) {
+ state->run = false;
+
+ return 0;
+}
+
+/*
> state = RL.IsWindowReady()
Check if window has been initialized successfully
@@ -107,243 +118,292 @@ int lcoreIsWindowFocused( lua_State *L ) {
}
/*
-> RL.SetWindowMonitor( int monitor )
+> resized = RL.IsWindowResized()
-Set monitor for the current window (fullscreen mode)
-*/
-int lcoreSetWindowMonitor( lua_State *L ) {
- int monitor = luaL_checkinteger( L, 1 );
+Check if window has been resized from last frame
- SetWindowMonitor( monitor );
+- Success return bool
+*/
+int lcoreIsWindowResized( lua_State *L ) {
+ lua_pushboolean( L, IsWindowResized() );
- return 0;
+ return 1;
}
/*
-> RL.SetWindowPosition( Vector2 pos )
+> state = RL.IsWindowState( int flag )
-Set window position on screen
+Check if one specific window flag is enabled (FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE...)
+
+- Success return bool
*/
-int lcoreSetWindowPosition( lua_State *L ) {
- Vector2 pos = uluaGetVector2( L, 1 );
+int lcoreIsWindowState( lua_State *L ) {
+ unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
- SetWindowPosition( pos.x, pos.y );
+ lua_pushboolean( L, IsWindowState( flag ) );
- return 0;
+ return 1;
}
/*
-> RL.SetWindowSize( Vector2 size )
+> RL.SetWindowState( int flag )
-Set window dimensions
+Set window configuration state using flags (FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE...)
*/
-int lcoreSetWindowSize( lua_State *L ) {
- Vector2 size = uluaGetVector2( L, 1 );
+int lcoreSetWindowState( lua_State *L ) {
+ unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
- SetWindowSize( (int)size.x, (int)size.y );
+ SetWindowState( flag );
return 0;
}
/*
-> RL.SetWindowOpacity( float opacity )
+> resized = RL.ClearWindowState( int flag )
-Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
+Clear window configuration state flags (FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE...)
+
+- Success return bool
*/
-int lcoreSetWindowOpacity( lua_State *L ) {
- float opacity = luaL_checknumber( L, 1 );
+int lcoreClearWindowState( lua_State *L ) {
+ unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
- SetWindowOpacity( opacity );
+ ClearWindowState( flag );
- return 0;
+ return 1;
}
/*
-> windowHandle = RL.GetWindowHandle()
+> RL.ToggleFullscreen()
-Get native window handle. Return as lightuserdata
+Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
+*/
+int lcoreToggleFullscreen( lua_State *L ) {
+ ToggleFullscreen();
-- Success return lightuserdata
+ return 0;
+}
+
+/*
+> RL.ToggleBorderlessWindowed()
+
+Toggle window state: borderless windowed (only PLATFORM_DESKTOP)
*/
-int lcoreGetWindowHandle( lua_State *L ) {
- lua_pushlightuserdata( L, GetWindowHandle() );
+int lcoreToggleBorderlessWindowed( lua_State *L ) {
+ ToggleBorderlessWindowed();
- return 1;
+ return 0;
}
/*
-> RL.SetWindowMinSize( Vector2 size )
+> RL.MaximizeWindow()
-Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
+Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
*/
-int lcoreSetWindowMinSize( lua_State *L ) {
- Vector2 size = uluaGetVector2( L, 1 );
+int lcoreMaximizeWindow( lua_State *L ) {
+ MaximizeWindow();
- SetWindowMinSize( (int)size.x, (int)size.y );
+ return 0;
+}
+
+/*
+> RL.MinimizeWindow()
+
+Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
+*/
+int lcoreMinimizeWindow( lua_State *L ) {
+ MinimizeWindow();
return 0;
}
/*
-> position = RL.GetMonitorPosition( int monitor )
+> RL.RestoreWindow()
-Get specified monitor position
+Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
+*/
+int lcoreRestoreWindow( lua_State *L ) {
+ RestoreWindow();
-- Success return Vector2
+ return 0;
+}
+
+/*
+> RL.SetWindowIcon( Image image )
+
+Set icon for window (Only PLATFORM_DESKTOP)
*/
-int lcoreGetMonitorPosition( lua_State *L ) {
- int monitor = luaL_checkinteger( L, 1 );
+int lcoreSetWindowIcon( lua_State *L ) {
+ Image *image = uluaGetImage( L, 1 );
- uluaPushVector2( L, GetMonitorPosition( monitor ) );
+ SetWindowIcon( *image );
- return 1;
+ return 0;
}
/*
-> size = RL.GetMonitorSize( int monitor )
-
-Get specified monitor size
+> RL.SetWindowIcons( Image{} images )
-- Success return Vector2
+Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
*/
-int lcoreGetMonitorSize( lua_State *L ) {
- int monitor = luaL_checkinteger( L, 1 );
+int lcoreSetWindowIcons( lua_State *L ) {
+ int count = uluaGetTableLen( L, 1 );
+ Image images[ count ];
- Vector2 size = (Vector2){ GetMonitorWidth( monitor ), GetMonitorHeight( monitor ) };
- uluaPushVector2( L, size );
+ int t = 1;
+ int i = 0;
+ lua_pushnil( L );
- return 1;
+ while ( lua_next( L, t ) != 0 ) {
+ images[i] = *uluaGetImage( L, lua_gettop( L ) );
+
+ i++;
+ lua_pop( L, 1 );
+ }
+ SetWindowIcons( images, count );
+
+ return 0;
}
/*
-> position = RL.GetWindowPosition()
-
-Get window position on monitor
+> RL.SetWindowTitle( string title )
-- Success return Vector2
+Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
*/
-int lcoreGetWindowPosition( lua_State *L ) {
- uluaPushVector2( L, GetWindowPosition() );
+int lcoreSetWindowTitle( lua_State *L ) {
+ SetWindowTitle( luaL_checkstring( L, 1 ) );
- return 1;
+ return 0;
}
/*
-> size = RL.GetScreenSize()
-
-Get screen size
+> RL.SetWindowPosition( Vector2 pos )
-- Success return Vector2
+Set window position on screen
*/
-int lcoreGetScreenSize( lua_State *L ) {
- Vector2 size = (Vector2){ GetScreenWidth(), GetScreenHeight() };
- uluaPushVector2( L, size );
+int lcoreSetWindowPosition( lua_State *L ) {
+ Vector2 pos = uluaGetVector2( L, 1 );
- return 1;
+ SetWindowPosition( pos.x, pos.y );
+
+ return 0;
}
/*
-> RL.SetWindowState( int flag )
+> RL.SetWindowMonitor( int monitor )
-Set window configuration state using flags (FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE...)
+Set monitor for the current window
*/
-int lcoreSetWindowState( lua_State *L ) {
- unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
+int lcoreSetWindowMonitor( lua_State *L ) {
+ int monitor = luaL_checkinteger( L, 1 );
- SetWindowState( flag );
+ SetWindowMonitor( monitor );
return 0;
}
/*
-> state = RL.IsWindowState( int flag )
-
-Check if one specific window flag is enabled (FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE...)
+> RL.SetWindowMinSize( Vector2 size )
-- Success return bool
+Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
*/
-int lcoreIsWindowState( lua_State *L ) {
- unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
+int lcoreSetWindowMinSize( lua_State *L ) {
+ Vector2 size = uluaGetVector2( L, 1 );
- lua_pushboolean( L, IsWindowState( flag ) );
+ SetWindowMinSize( (int)size.x, (int)size.y );
- return 1;
+ return 0;
}
/*
-> resized = RL.ClearWindowState( int flag )
-
-Clear window configuration state flags (FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE...)
+> RL.SetWindowMaxSize( Vector2 size )
-- Success return bool
+Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)
*/
-int lcoreClearWindowState( lua_State *L ) {
- unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
+int lcoreSetWindowMaxSize( lua_State *L ) {
+ Vector2 size = uluaGetVector2( L, 1 );
- ClearWindowState( flag );
+ SetWindowMaxSize( (int)size.x, (int)size.y );
- return 1;
+ return 0;
}
/*
-> resized = RL.IsWindowResized()
-
-Check if window has been resized from last frame
+> RL.SetWindowSize( Vector2 size )
-- Success return bool
+Set window dimensions
*/
-int lcoreIsWindowResized( lua_State *L ) {
- lua_pushboolean( L, IsWindowResized() );
+int lcoreSetWindowSize( lua_State *L ) {
+ Vector2 size = uluaGetVector2( L, 1 );
- return 1;
+ SetWindowSize( (int)size.x, (int)size.y );
+
+ return 0;
}
/*
-> RL.SetWindowIcon( Image image )
+> RL.SetWindowOpacity( float opacity )
-Set icon for window (Only PLATFORM_DESKTOP)
+Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
*/
-int lcoreSetWindowIcon( lua_State *L ) {
- Image *image = uluaGetImage( L, 1 );
+int lcoreSetWindowOpacity( lua_State *L ) {
+ float opacity = luaL_checknumber( L, 1 );
- SetWindowIcon( *image );
+ SetWindowOpacity( opacity );
return 0;
}
/*
-> RL.SetWindowIcons( Image{} images )
+> RL.SetWindowFocused()
-Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
+Set window focused (only PLATFORM_DESKTOP)
*/
-int lcoreSetWindowIcons( lua_State *L ) {
- int count = uluaGetTableLen( L, 1 );
- Image images[ count ];
+int lcoreSetWindowFocused( lua_State *L ) {
+ SetWindowFocused();
- int t = 1;
- int i = 0;
- lua_pushnil( L );
+ return 0;
+}
- while ( lua_next( L, t ) != 0 ) {
- images[i] = *uluaGetImage( L, lua_gettop( L ) );
+/*
+> windowHandle = RL.GetWindowHandle()
- i++;
- lua_pop( L, 1 );
- }
- SetWindowIcons( images, count );
+Get native window handle. Return as lightuserdata
- return 0;
+- Success return lightuserdata
+*/
+int lcoreGetWindowHandle( lua_State *L ) {
+ lua_pushlightuserdata( L, GetWindowHandle() );
+
+ return 1;
}
/*
-> RL.SetWindowTitle( string title )
+> size = RL.GetScreenSize()
+
+Get screen size
-Set title for window (Only PLATFORM_DESKTOP)
+- Success return Vector2
*/
-int lcoreSetWindowTitle( lua_State *L ) {
- SetWindowTitle( luaL_checkstring( L, 1 ) );
+int lcoreGetScreenSize( lua_State *L ) {
+ Vector2 size = (Vector2){ GetScreenWidth(), GetScreenHeight() };
+ uluaPushVector2( L, size );
- return 0;
+ return 1;
+}
+
+/*
+> size = RL.GetRenderSize()
+
+Get render size
+
+- Success return Vector2
+*/
+int lcoreGetRenderSize( lua_State *L ) {
+ Vector2 size = (Vector2){ GetRenderWidth(), GetRenderHeight() };
+ uluaPushVector2( L, size );
+
+ return 1;
}
/*
@@ -373,6 +433,37 @@ int lcoreGetCurrentMonitor( lua_State *L ) {
}
/*
+> position = RL.GetMonitorPosition( int monitor )
+
+Get specified monitor position
+
+- Success return Vector2
+*/
+int lcoreGetMonitorPosition( lua_State *L ) {
+ int monitor = luaL_checkinteger( L, 1 );
+
+ uluaPushVector2( L, GetMonitorPosition( monitor ) );
+
+ return 1;
+}
+
+/*
+> size = RL.GetMonitorSize( int monitor )
+
+Get specified monitor size
+
+- Success return Vector2
+*/
+int lcoreGetMonitorSize( lua_State *L ) {
+ int monitor = luaL_checkinteger( L, 1 );
+
+ Vector2 size = (Vector2){ GetMonitorWidth( monitor ), GetMonitorHeight( monitor ) };
+ uluaPushVector2( L, size );
+
+ return 1;
+}
+
+/*
> size = RL.GetMonitorPhysicalSize( int monitor )
Get specified monitor physical size in millimetres
@@ -404,6 +495,19 @@ int lcoreGetMonitorRefreshRate( lua_State *L ) {
}
/*
+> position = RL.GetWindowPosition()
+
+Get window position on monitor
+
+- Success return Vector2
+*/
+int lcoreGetWindowPosition( lua_State *L ) {
+ uluaPushVector2( L, GetWindowPosition() );
+
+ return 1;
+}
+
+/*
> dpi = RL.GetWindowScaleDPI()
Get window scale DPI factor
@@ -419,7 +523,7 @@ int lcoreGetWindowScaleDPI( lua_State *L ) {
/*
> name = RL.GetMonitorName( int monitor )
-Get the human-readable, UTF-8 encoded name of the monitor
+Get the human-readable, UTF-8 encoded name of the specified monitor
- Success return string
*/
@@ -432,17 +536,6 @@ int lcoreGetMonitorName( lua_State *L ) {
}
/*
-> RL.CloseWindow()
-
-Close window and unload OpenGL context and free all resources
-*/
-int lcoreCloseWindow( lua_State *L ) {
- state->run = false;
-
- return 0;
-}
-
-/*
> RL.SetClipboardText( string text )
Set clipboard text content
@@ -1152,6 +1245,63 @@ int lcoreGetTime( lua_State *L ) {
}
/*
+## Core - Random values generation functions
+*/
+
+/*
+> RL.SetRandomSeed( int seed )
+
+Set the seed for the random number generator
+*/
+int lcoreSetRandomSeed( lua_State *L ) {
+ unsigned int seed = (unsigned int)luaL_checkinteger( L, 1 );
+
+ SetRandomSeed( seed );
+
+ return 0;
+}
+
+/*
+> time = RL.GetRandomValue( int min, int max )
+
+Get a random value between min and max (both included)
+
+- Success return int
+*/
+int lcoreGetRandomValue( lua_State *L ) {
+ int min = luaL_checkinteger( L, 1 );
+ int max = luaL_checkinteger( L, 2 );
+
+ lua_pushinteger( L, GetRandomValue( min, max ) );
+
+ return 1;
+}
+
+/*
+> sequence = RL.GetRandomValue( int count, int min, int max )
+
+Load random values sequence, no values repeated
+
+- Success return int{}
+*/
+int lcoreLoadRandomSequence( lua_State *L ) {
+ unsigned int count = luaL_checkinteger( L, 1 );
+ int min = luaL_checkinteger( L, 1 );
+ int max = luaL_checkinteger( L, 2 );
+
+ int *sequence = LoadRandomSequence( count, min, max );
+ lua_createtable( L, count, 0 );
+
+ for ( int i = 0; i < count; i++ ) {
+ lua_pushinteger( L, sequence[i] );
+ lua_rawseti( L, -2, i + 1 );
+ }
+ UnloadRandomSequence( sequence );
+
+ return 1;
+}
+
+/*
## Core - Misc
*/
@@ -1232,7 +1382,7 @@ int lcoreGetLogLevelInvalid( lua_State *L ) {
/*
> RL.OpenURL( string url )
-Open URL with default system browser (If available)
+Open URL with default system browser (if available)
*/
int lcoreOpenURL( lua_State *L ) {
OpenURL( luaL_checkstring( L, 1 ) );
@@ -1412,6 +1562,19 @@ int lcoreGetWorkingDirectory( lua_State *L ) {
}
/*
+> directory = RL.GetApplicationDirectory()
+
+Get the directory of the running application (uses static string)
+
+- Success return string
+*/
+int lcoreGetApplicationDirectory( lua_State *L ) {
+ lua_pushstring( L, GetApplicationDirectory() );
+
+ return 1;
+}
+
+/*
> fileNames = RL.LoadDirectoryFiles( string dirPath )
Load directory filepaths
@@ -1794,6 +1957,21 @@ int lcoreIsGamepadAvailable( lua_State *L ) {
}
/*
+> name = RL.GetGamepadName( int gamepad )
+
+Return gamepad internal name id
+
+- Success return string
+*/
+int lcoreGetGamepadName( lua_State *L ) {
+ int gamepad = luaL_checkinteger( L, 1 );
+
+ lua_pushstring( L, GetGamepadName( gamepad ) );
+
+ return 1;
+}
+
+/*
> pressed = RL.IsGamepadButtonPressed( int gamepad, int button )
Detect if a gamepad button has been pressed once
@@ -1873,16 +2051,16 @@ int lcoreGetGamepadAxisMovement( lua_State *L ) {
}
/*
-> name = RL.GetGamepadName( int gamepad )
+> result = RL.SetGamepadMappings( string mappings )
-Return gamepad internal name id
+Set internal gamepad mappings (SDL_GameControllerDB)
-- Success return string
+- Success return int
*/
-int lcoreGetGamepadName( lua_State *L ) {
- int gamepad = luaL_checkinteger( L, 1 );
+int lcoreSetGamepadMappings( lua_State *L ) {
+ const char *mappings = luaL_checkstring( L, 1 );
- lua_pushstring( L, GetGamepadName( gamepad ) );
+ lua_pushnumber( L, SetGamepadMappings( mappings ) );
return 1;
}
diff --git a/src/lua_core.c b/src/lua_core.c
index fe9d8c7..40bb0c4 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1522,36 +1522,44 @@ void luaRegister() {
/* Core. */
/* Window-related functions. */
+ assingGlobalFunction( "CloseWindow", lcoreCloseWindow );
assingGlobalFunction( "IsWindowReady", lcoreIsWindowReady );
assingGlobalFunction( "IsWindowFullscreen", lcoreIsWindowFullscreen );
assingGlobalFunction( "IsWindowHidden", lcoreIsWindowHidden );
assingGlobalFunction( "IsWindowMinimized", lcoreIsWindowMinimized );
assingGlobalFunction( "IsWindowMaximized", lcoreIsWindowMaximized );
assingGlobalFunction( "IsWindowFocused", lcoreIsWindowFocused );
- assingGlobalFunction( "SetWindowMonitor", lcoreSetWindowMonitor );
- assingGlobalFunction( "SetWindowPosition", lcoreSetWindowPosition );
- assingGlobalFunction( "SetWindowSize", lcoreSetWindowSize );
- assingGlobalFunction( "SetWindowOpacity", lcoreSetWindowOpacity );
- assingGlobalFunction( "GetWindowHandle", lcoreGetWindowHandle );
- assingGlobalFunction( "SetWindowMinSize", lcoreSetWindowMinSize );
- assingGlobalFunction( "GetMonitorPosition", lcoreGetMonitorPosition );
- assingGlobalFunction( "GetMonitorSize", lcoreGetMonitorSize );
- assingGlobalFunction( "GetWindowPosition", lcoreGetWindowPosition );
- assingGlobalFunction( "GetScreenSize", lcoreGetScreenSize );
- assingGlobalFunction( "SetWindowState", lcoreSetWindowState );
+ assingGlobalFunction( "IsWindowResized", lcoreIsWindowResized );
assingGlobalFunction( "IsWindowState", lcoreIsWindowState );
+ assingGlobalFunction( "SetWindowState", lcoreSetWindowState );
assingGlobalFunction( "ClearWindowState", lcoreClearWindowState );
- assingGlobalFunction( "IsWindowResized", lcoreIsWindowResized );
+ assingGlobalFunction( "ToggleFullscreen", lcoreToggleFullscreen );
+ assingGlobalFunction( "ToggleBorderlessWindowed", lcoreToggleBorderlessWindowed );
+ assingGlobalFunction( "MaximizeWindow", lcoreMaximizeWindow );
+ assingGlobalFunction( "MinimizeWindow", lcoreMinimizeWindow );
+ assingGlobalFunction( "RestoreWindow", lcoreRestoreWindow );
assingGlobalFunction( "SetWindowIcon", lcoreSetWindowIcon );
assingGlobalFunction( "SetWindowIcons", lcoreSetWindowIcons );
assingGlobalFunction( "SetWindowTitle", lcoreSetWindowTitle );
+ assingGlobalFunction( "SetWindowPosition", lcoreSetWindowPosition );
+ assingGlobalFunction( "SetWindowMonitor", lcoreSetWindowMonitor );
+ assingGlobalFunction( "SetWindowMinSize", lcoreSetWindowMinSize );
+ assingGlobalFunction( "SetWindowMaxSize", lcoreSetWindowMaxSize );
+ assingGlobalFunction( "SetWindowSize", lcoreSetWindowSize );
+ assingGlobalFunction( "SetWindowOpacity", lcoreSetWindowOpacity );
+ assingGlobalFunction( "SetWindowFocused", lcoreSetWindowFocused );
+ assingGlobalFunction( "GetWindowHandle", lcoreGetWindowHandle );
+ assingGlobalFunction( "GetScreenSize", lcoreGetScreenSize );
+ assingGlobalFunction( "GetRenderSize", lcoreGetRenderSize );
assingGlobalFunction( "GetMonitorCount", lcoreGetMonitorCount );
assingGlobalFunction( "GetCurrentMonitor", lcoreGetCurrentMonitor );
+ assingGlobalFunction( "GetMonitorPosition", lcoreGetMonitorPosition );
+ assingGlobalFunction( "GetMonitorSize", lcoreGetMonitorSize );
assingGlobalFunction( "GetMonitorPhysicalSize", lcoreGetMonitorPhysicalSize );
assingGlobalFunction( "GetMonitorRefreshRate", lcoreGetMonitorRefreshRate );
+ assingGlobalFunction( "GetWindowPosition", lcoreGetWindowPosition );
assingGlobalFunction( "GetWindowScaleDPI", lcoreGetWindowScaleDPI );
assingGlobalFunction( "GetMonitorName", lcoreGetMonitorName );
- assingGlobalFunction( "CloseWindow", lcoreCloseWindow );
assingGlobalFunction( "SetClipboardText", lcoreSetClipboardText );
assingGlobalFunction( "GetClipboardText", lcoreGetClipboardText );
/* Cursor-related functions. */
@@ -1603,6 +1611,10 @@ void luaRegister() {
assingGlobalFunction( "GetFPS", lcoreGetFPS );
assingGlobalFunction( "GetFrameTime", lcoreGetFrameTime );
assingGlobalFunction( "GetTime", lcoreGetTime );
+ /* Random values generation functions. */
+ assingGlobalFunction( "SetRandomSeed", lcoreSetRandomSeed );
+ assingGlobalFunction( "GetRandomValue", lcoreGetRandomValue );
+ assingGlobalFunction( "LoadRandomSequence", lcoreLoadRandomSequence );
/* Misc. functions. */
assingGlobalFunction( "TakeScreenshot", lcoreTakeScreenshot );
assingGlobalFunction( "SetConfigFlags", lcoreSetConfigFlags );
@@ -1625,6 +1637,7 @@ void luaRegister() {
assingGlobalFunction( "GetDirectoryPath", lcoreGetDirectoryPath );
assingGlobalFunction( "GetPrevDirectoryPath", lcoreGetPrevDirectoryPath );
assingGlobalFunction( "GetWorkingDirectory", lcoreGetWorkingDirectory );
+ assingGlobalFunction( "GetApplicationDirectory", lcoreGetApplicationDirectory );
assingGlobalFunction( "LoadDirectoryFiles", lcoreLoadDirectoryFiles );
assingGlobalFunction( "LoadDirectoryFilesEx", lcoreLoadDirectoryFilesEx );
assingGlobalFunction( "ChangeDirectory", lcoreChangeDirectory );
@@ -1649,12 +1662,13 @@ void luaRegister() {
assingGlobalFunction( "GetKeyScancode", lcoreGetKeyScancode );
/* Input-related functions: gamepads. */
assingGlobalFunction( "IsGamepadAvailable", lcoreIsGamepadAvailable );
+ assingGlobalFunction( "GetGamepadName", lcoreGetGamepadName );
assingGlobalFunction( "IsGamepadButtonPressed", lcoreIsGamepadButtonPressed );
assingGlobalFunction( "IsGamepadButtonDown", lcoreIsGamepadButtonDown );
assingGlobalFunction( "IsGamepadButtonReleased", lcoreIsGamepadButtonReleased );
assingGlobalFunction( "GetGamepadAxisCount", lcoreGetGamepadAxisCount );
assingGlobalFunction( "GetGamepadAxisMovement", lcoreGetGamepadAxisMovement );
- assingGlobalFunction( "GetGamepadName", lcoreGetGamepadName );
+ assingGlobalFunction( "SetGamepadMappings", lcoreSetGamepadMappings );
/* Input-related functions: mouse. */
assingGlobalFunction( "IsMouseButtonPressed", lcoreIsMouseButtonPressed );
assingGlobalFunction( "IsMouseButtonDown", lcoreIsMouseButtonDown );
@@ -1731,8 +1745,6 @@ void luaRegister() {
assingGlobalFunction( "DrawPixel", lshapesDrawPixel );
assingGlobalFunction( "DrawLine", lshapesDrawLine );
assingGlobalFunction( "DrawLineBezier", lshapesDrawLineBezier );
- assingGlobalFunction( "DrawLineBezierQuad", lshapesDrawLineBezierQuad );
- assingGlobalFunction( "DrawLineBezierCubic", lshapesDrawLineBezierCubic );
assingGlobalFunction( "DrawLineStrip", lshapesDrawLineStrip );
assingGlobalFunction( "DrawCircle", lshapesDrawCircle );
assingGlobalFunction( "DrawCircleSector", lshapesDrawCircleSector );
@@ -1775,6 +1787,7 @@ void luaRegister() {
/* Image loading functions. */
assingGlobalFunction( "LoadImage", ltexturesLoadImage );
assingGlobalFunction( "LoadImageRaw", ltexturesLoadImageRaw );
+ assingGlobalFunction( "LoadImageSvg", ltexturesLoadImageSvg );
assingGlobalFunction( "LoadImageAnim", ltexturesLoadImageAnim );
assingGlobalFunction( "LoadImageFromMemory", ltexturesLoadImageFromMemory );
assingGlobalFunction( "LoadImageFromTexture", ltexturesLoadImageFromTexture );
@@ -1782,12 +1795,13 @@ void luaRegister() {
assingGlobalFunction( "IsImageReady", ltextureIsImageReady );
assingGlobalFunction( "UnloadImage", ltextureUnloadImage );
assingGlobalFunction( "ExportImage", ltexturesExportImage );
+ assingGlobalFunction( "ExportImageToMemory", ltexturesExportImageToMemory );
assingGlobalFunction( "ExportImageAsCode", ltexturesExportImageAsCode );
/* Image generation functions. */
assingGlobalFunction( "GenImageColor", ltexturesGenImageColor );
- assingGlobalFunction( "GenImageGradientV", ltexturesGenImageGradientV );
- assingGlobalFunction( "GenImageGradientH", ltexturesGenImageGradientH );
+ assingGlobalFunction( "GenImageGradientLinear", ltexturesGenImageGradientLinear );
assingGlobalFunction( "GenImageGradientRadial", ltexturesGenImageGradientRadial );
+ assingGlobalFunction( "GenImageGradientSquare", ltexturesGenImageGradientSquare );
assingGlobalFunction( "GenImageChecked", ltexturesGenImageChecked );
assingGlobalFunction( "GenImageWhiteNoise", ltexturesGenImageWhiteNoise );
assingGlobalFunction( "GenImagePerlinNoise", ltexturesGenImagePerlinNoise );
@@ -1812,6 +1826,7 @@ void luaRegister() {
assingGlobalFunction( "ImageDither", ltexturesImageDither );
assingGlobalFunction( "ImageFlipVertical", ltexturesImageFlipVertical );
assingGlobalFunction( "ImageFlipHorizontal", ltexturesImageFlipHorizontal );
+ assingGlobalFunction( "ImageRotate", ltexturesImageRotate );
assingGlobalFunction( "ImageRotateCW", ltexturesImageRotateCW );
assingGlobalFunction( "ImageRotateCCW", ltexturesImageRotateCCW );
assingGlobalFunction( "ImageColorTint", ltexturesImageColorTint );
@@ -1995,6 +2010,7 @@ void luaRegister() {
assingGlobalFunction( "DrawTextBoxed", ltextDrawTextBoxed );
assingGlobalFunction( "DrawTextBoxedTinted", ltextDrawTextBoxedTinted );
/* Text font info functions. */
+ assingGlobalFunction( "SetTextLineSpacing", ltextSetTextLineSpacing );
assingGlobalFunction( "MeasureText", ltextMeasureText );
assingGlobalFunction( "GetGlyphIndex", ltextGetGlyphIndex );
assingGlobalFunction( "GetGlyphInfo", ltextGetGlyphInfo );
@@ -2006,15 +2022,21 @@ void luaRegister() {
/* Audio. */
/* Audio device management functions. */
+ assingGlobalFunction( "InitAudioDevice", laudioInitAudioDevice );
+ assingGlobalFunction( "CloseAudioDevice", laudioCloseAudioDevice );
+ assingGlobalFunction( "IsAudioDeviceReady", laudioIsAudioDeviceReady );
assingGlobalFunction( "SetMasterVolume", laudioSetMasterVolume );
+ assingGlobalFunction( "GetMasterVolume", laudioGetMasterVolume );
/* Wave/Sound loading/unloading functions. */
assingGlobalFunction( "LoadSound", laudioLoadSound );
assingGlobalFunction( "LoadWave", laudioLoadWave );
assingGlobalFunction( "IsWaveReady", laudioIsWaveReady );
assingGlobalFunction( "LoadSoundFromWave", laudioLoadSoundFromWave );
+ assingGlobalFunction( "LoadSoundAlias", laudioLoadSoundAlias );
assingGlobalFunction( "IsSoundReady", laudioIsSoundReady );
assingGlobalFunction( "UnloadWave", laudioUnloadWave );
assingGlobalFunction( "UnloadSound", laudioUnloadSound );
+ assingGlobalFunction( "UnloadSoundAlias", laudioUnloadSoundAlias );
assingGlobalFunction( "ExportWave", laudioExportWave );
assingGlobalFunction( "ExportWaveAsCode", laudioExportWaveAsCode );
/* Wave/Sound management functions. */
diff --git a/src/shapes.c b/src/shapes.c
index c68504c..80e5f05 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -55,57 +55,6 @@ int lshapesDrawLine( lua_State *L ) {
}
/*
-> RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )
-
-Draw a line using cubic-bezier curves in-out
-*/
-int lshapesDrawLineBezier( lua_State *L ) {
- Vector2 startPos = uluaGetVector2( L, 1 );
- Vector2 endPos = uluaGetVector2( L, 2 );
- float thickness = luaL_checknumber( L, 3 );
- Color color = uluaGetColor( L, 4 );
-
- DrawLineBezier( startPos, endPos, thickness, color );
-
- return 0;
-}
-
-/*
-> RL.DrawLineBezierQuad( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color )
-
-Draw line using quadratic bezier curves with a control point
-*/
-int lshapesDrawLineBezierQuad( lua_State *L ) {
- Vector2 startPos = uluaGetVector2( L, 1 );
- Vector2 endPos = uluaGetVector2( L, 2 );
- Vector2 controlPos = uluaGetVector2( L, 3 );
- float thickness = luaL_checknumber( L, 4 );
- Color color = uluaGetColor( L, 5 );
-
- DrawLineBezierQuad( startPos, endPos, controlPos, thickness, color );
-
- return 0;
-}
-
-/*
-> RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color )
-
-Draw line using quadratic bezier curves with a control point
-*/
-int lshapesDrawLineBezierCubic( lua_State *L ) {
- Vector2 startPos = uluaGetVector2( L, 1 );
- Vector2 endPos = uluaGetVector2( L, 2 );
- Vector2 startControlPos = uluaGetVector2( L, 3 );
- Vector2 endControlPos = uluaGetVector2( L, 4 );
- float thickness = luaL_checknumber( L, 5 );
- Color color = uluaGetColor( L, 6 );
-
- DrawLineBezierCubic( startPos, endPos, startControlPos, endControlPos, thickness, color );
-
- return 0;
-}
-
-/*
> RL.DrawLineStrip( Vector2{} points, Color color )
Draw lines sequence
@@ -131,6 +80,22 @@ int lshapesDrawLineStrip( lua_State *L ) {
}
/*
+> RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )
+
+Draw a line using cubic-bezier curves in-out
+*/
+int lshapesDrawLineBezier( lua_State *L ) {
+ Vector2 startPos = uluaGetVector2( L, 1 );
+ Vector2 endPos = uluaGetVector2( L, 2 );
+ float thickness = luaL_checknumber( L, 3 );
+ Color color = uluaGetColor( L, 4 );
+
+ DrawLineBezier( startPos, endPos, thickness, color );
+
+ return 0;
+}
+
+/*
> RL.DrawCircle( Vector2 center, float radius, Color color )
Draw a color-filled circle
diff --git a/src/state.c b/src/state.c
index b2de3d9..6b93037 100644
--- a/src/state.c
+++ b/src/state.c
@@ -26,7 +26,6 @@ bool stateInit( int argn, const char **argc, const char *exePath ) {
state->run = false;
}
if ( state->run ) {
- InitAudioDevice();
state->run = luaInit( argn, argc );
}
state->defaultFont = GetFontDefault();
diff --git a/src/text.c b/src/text.c
index af7b02f..a6e0241 100644
--- a/src/text.c
+++ b/src/text.c
@@ -193,9 +193,9 @@ int ltextLoadFont( lua_State *L ) {
}
/*
-> font = RL.LoadFontEx( string fileName, int fontSize, int{} fontChars )
+> font = RL.LoadFontEx( string fileName, int fontSize, int{} codepoints )
-Load font from file with extended parameters, use NULL for fontChars to load the default character set
+Load font from file with extended parameters, use NULL for codepoints to load the default character set
- Failure return nil
- Success return Font
@@ -205,20 +205,20 @@ int ltextLoadFontEx( lua_State *L ) {
if ( FileExists( luaL_checkstring( L, 1 ) ) ) {
if ( lua_istable( L, 3 ) ) {
- int glyphCount = uluaGetTableLen( L, 3 );
- int fontChars[ glyphCount ];
+ int codepointCount = uluaGetTableLen( L, 3 );
+ int codepoints[ codepointCount ];
int t = 3;
int i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
- fontChars[i] = lua_tointeger( L, -1 );
+ codepoints[i] = lua_tointeger( L, -1 );
i++;
lua_pop( L, 1 );
}
- uluaPushFont( L, LoadFontEx( lua_tostring( L, 1 ), fontSize, fontChars, glyphCount ) );
+ uluaPushFont( L, LoadFontEx( lua_tostring( L, 1 ), fontSize, codepoints, codepointCount ) );
return 1;
}
@@ -374,8 +374,8 @@ int ltextDrawTextCodepoints( lua_State *L ) {
float spacing = luaL_checknumber( L, 5 );
Color tint = uluaGetColor( L, 6 );
- int count = uluaGetTableLen( L, 2 );
- int codepoints[ count ];
+ int codepointCount = uluaGetTableLen( L, 2 );
+ int codepoints[ codepointCount ];
int t = 2;
int i = 0;
@@ -387,7 +387,7 @@ int ltextDrawTextCodepoints( lua_State *L ) {
i++;
lua_pop( L, 1 );
}
- DrawTextCodepoints( *font, codepoints, count, position, fontSize, spacing, tint );
+ DrawTextCodepoints( *font, codepoints, codepointCount, position, fontSize, spacing, tint );
return 0;
}
@@ -461,6 +461,17 @@ int ltextDrawTextBoxedTinted( lua_State *L ) {
*/
/*
+> size = RL.SetTextLineSpacing( int spacing )
+
+Set vertical line spacing when drawing with line-breaks
+*/
+int ltextSetTextLineSpacing( lua_State *L ) {
+ int spacing = luaL_checkinteger( L, 1 );
+
+ SetTextLineSpacing( spacing );
+}
+
+/*
> size = RL.MeasureText( Font font, string text, float fontSize, float spacing )
Measure string size for Font
diff --git a/src/textures.c b/src/textures.c
index 008aa14..ef1e76e 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -54,6 +54,22 @@ int ltexturesLoadImageRaw( lua_State *L ) {
}
/*
+> image = RL.LoadImageSvg( string fileNameOrString, Vector2 size )
+
+Load image from SVG file data or string with specified size
+
+- Success return Image
+*/
+int ltexturesLoadImageSvg( lua_State *L ) {
+ const char *fileNameOrString = luaL_checkstring( L, 1 );
+ Vector2 size = uluaGetVector2( L, 2 );
+
+ uluaPushImage( L, LoadImageSvg( fileNameOrString, (int)size.x, (int)size.y ) );
+
+ return 1;
+}
+
+/*
> image, frameCount = RL.LoadImageAnim( string fileName )
Load image sequence from file (frames appended to image.data). All frames are returned in RGBA format
@@ -163,6 +179,27 @@ int ltexturesExportImage( lua_State *L ) {
}
/*
+> buffer = RL.ExportImageToMemory( Image image, string fileType )
+
+Export image to memory buffer
+
+- Success return Buffer
+*/
+int ltexturesExportImageToMemory( lua_State *L ) {
+ Image *image = uluaGetImage( L, 1 );
+ const char *fileType = luaL_checkstring( L, 2 );
+
+ Buffer buffer = {
+ .type = BUFFER_UNSIGNED_CHAR
+ };
+ buffer.data = ExportImageToMemory( *image, fileType, (int*)&buffer.size );
+
+ uluaPushBuffer( L, buffer );
+
+ return 1;
+}
+
+/*
> success = RL.ExportImageAsCode( Image image, string fileName )
Export image as code file defining an array of bytes, returns true on success
@@ -197,53 +234,55 @@ int ltexturesGenImageColor( lua_State *L ) {
}
/*
-> image = RL.GenImageGradientV( Vector2 size, Color top, Color bottom )
+> image = RL.GenImageGradientLinear( Vector2 size, int direction, Color a, Color b )
-Generate image: vertical gradient
+Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient
- Success return Image
*/
-int ltexturesGenImageGradientV( lua_State *L ) {
+int ltexturesGenImageGradientLinear( lua_State *L ) {
Vector2 size = uluaGetVector2( L, 1 );
- Color top = uluaGetColor( L, 2 );
- Color bottom = uluaGetColor( L, 3 );
+ int direction = luaL_checkinteger( L, 2 );
+ Color start = uluaGetColor( L, 3 );
+ Color end = uluaGetColor( L, 4 );
- uluaPushImage( L, GenImageGradientV( (int)size.x, (int)size.y, top, bottom ) );
+ uluaPushImage( L, GenImageGradientLinear( (int)size.x, (int)size.y, direction, start, end ) );
return 1;
}
/*
-> image = RL.GenImageGradientH( Vector2 size, Color left, Color right )
+> image = RL.GenImageGradientRadial( Vector2 size, float density, Color inner, Color outer )
-Generate image: horizontal gradient
+Generate image: radial gradient
- Success return Image
*/
-int ltexturesGenImageGradientH( lua_State *L ) {
+int ltexturesGenImageGradientRadial( lua_State *L ) {
Vector2 size = uluaGetVector2( L, 1 );
- Color left = uluaGetColor( L, 2 );
- Color right = uluaGetColor( L, 3 );
+ float density = luaL_checknumber( L, 2 );
+ Color inner = uluaGetColor( L, 3 );
+ Color outer = uluaGetColor( L, 4 );
- uluaPushImage( L, GenImageGradientH( (int)size.x, (int)size.y, left, right ) );
+ uluaPushImage( L, GenImageGradientRadial( (int)size.x, (int)size.y, density, inner, outer ) );
return 1;
}
/*
-> image = RL.GenImageGradientRadial( Vector2 size, float density, Color inner, Color outer )
+> image = RL.GenImageGradientSquare( Vector2 size, float density, Color inner, Color outer )
-Generate image: radial gradient
+Generate image: square gradient
- Success return Image
*/
-int ltexturesGenImageGradientRadial( lua_State *L ) {
+int ltexturesGenImageGradientSquare( lua_State *L ) {
Vector2 size = uluaGetVector2( L, 1 );
float density = luaL_checknumber( L, 2 );
Color inner = uluaGetColor( L, 3 );
Color outer = uluaGetColor( L, 4 );
- uluaPushImage( L, GenImageGradientRadial( (int)size.x, (int)size.y, density, inner, outer ) );
+ uluaPushImage( L, GenImageGradientSquare( (int)size.x, (int)size.y, density, inner, outer ) );
return 1;
}
@@ -593,6 +632,20 @@ int ltexturesImageFlipHorizontal( lua_State *L ) {
}
/*
+> RL.ImageRotate( Image image, int degrees )
+
+Rotate image by input angle in degrees (-359 to 359)
+*/
+int ltexturesImageRotate( lua_State *L ) {
+ Image *image = uluaGetImage( L, 1 );
+ int degrees = luaL_checkinteger( L, 2 );
+
+ ImageRotate( image, degrees );
+
+ return 0;
+}
+
+/*
> RL.ImageRotateCW( Image image )
Rotate image clockwise 90deg