Initial changes for Raylib 5.0 and some missing functions.
This commit is contained in:
76
src/audio.c
76
src/audio.c
@@ -7,6 +7,41 @@
|
||||
## Audio - Audio device management functions
|
||||
*/
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -20,6 +55,19 @@ int laudioSetMasterVolume( lua_State *L ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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
|
||||
*/
|
||||
@@ -94,6 +142,21 @@ int laudioLoadSoundFromWave( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -135,6 +198,19 @@ int laudioUnloadSound( lua_State *L ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
|
||||
516
src/core.c
516
src/core.c
@@ -28,6 +28,17 @@ void unloadBuffer( Buffer *buffer ) {
|
||||
## Core - Window-related functions
|
||||
*/
|
||||
|
||||
/*
|
||||
> 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()
|
||||
|
||||
@@ -107,154 +118,18 @@ int lcoreIsWindowFocused( lua_State *L ) {
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowMonitor( int monitor )
|
||||
> resized = RL.IsWindowResized()
|
||||
|
||||
Set monitor for the current window (fullscreen mode)
|
||||
Check if window has been resized from last frame
|
||||
|
||||
- Success return bool
|
||||
*/
|
||||
int lcoreSetWindowMonitor( lua_State *L ) {
|
||||
int monitor = luaL_checkinteger( L, 1 );
|
||||
|
||||
SetWindowMonitor( monitor );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowPosition( Vector2 pos )
|
||||
|
||||
Set window position on screen
|
||||
*/
|
||||
int lcoreSetWindowPosition( lua_State *L ) {
|
||||
Vector2 pos = uluaGetVector2( L, 1 );
|
||||
|
||||
SetWindowPosition( pos.x, pos.y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowSize( Vector2 size )
|
||||
|
||||
Set window dimensions
|
||||
*/
|
||||
int lcoreSetWindowSize( lua_State *L ) {
|
||||
Vector2 size = uluaGetVector2( L, 1 );
|
||||
|
||||
SetWindowSize( (int)size.x, (int)size.y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowOpacity( float opacity )
|
||||
|
||||
Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
int lcoreSetWindowOpacity( lua_State *L ) {
|
||||
float opacity = luaL_checknumber( L, 1 );
|
||||
|
||||
SetWindowOpacity( opacity );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> windowHandle = RL.GetWindowHandle()
|
||||
|
||||
Get native window handle. Return as lightuserdata
|
||||
|
||||
- Success return lightuserdata
|
||||
*/
|
||||
int lcoreGetWindowHandle( lua_State *L ) {
|
||||
lua_pushlightuserdata( L, GetWindowHandle() );
|
||||
int lcoreIsWindowResized( lua_State *L ) {
|
||||
lua_pushboolean( L, IsWindowResized() );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowMinSize( Vector2 size )
|
||||
|
||||
Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
||||
*/
|
||||
int lcoreSetWindowMinSize( lua_State *L ) {
|
||||
Vector2 size = uluaGetVector2( L, 1 );
|
||||
|
||||
SetWindowMinSize( (int)size.x, (int)size.y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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;
|
||||
}
|
||||
|
||||
/*
|
||||
> position = RL.GetWindowPosition()
|
||||
|
||||
Get window position on monitor
|
||||
|
||||
- Success return Vector2
|
||||
*/
|
||||
int lcoreGetWindowPosition( lua_State *L ) {
|
||||
uluaPushVector2( L, GetWindowPosition() );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> size = RL.GetScreenSize()
|
||||
|
||||
Get screen size
|
||||
|
||||
- Success return Vector2
|
||||
*/
|
||||
int lcoreGetScreenSize( lua_State *L ) {
|
||||
Vector2 size = (Vector2){ GetScreenWidth(), GetScreenHeight() };
|
||||
uluaPushVector2( L, size );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowState( int flag )
|
||||
|
||||
Set window configuration state using flags (FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE...)
|
||||
*/
|
||||
int lcoreSetWindowState( lua_State *L ) {
|
||||
unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
|
||||
|
||||
SetWindowState( flag );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> state = RL.IsWindowState( int flag )
|
||||
|
||||
@@ -270,6 +145,19 @@ int lcoreIsWindowState( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowState( int flag )
|
||||
|
||||
Set window configuration state using flags (FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE...)
|
||||
*/
|
||||
int lcoreSetWindowState( lua_State *L ) {
|
||||
unsigned int flag = (unsigned int)luaL_checkinteger( L, 1 );
|
||||
|
||||
SetWindowState( flag );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> resized = RL.ClearWindowState( int flag )
|
||||
|
||||
@@ -286,16 +174,58 @@ int lcoreClearWindowState( lua_State *L ) {
|
||||
}
|
||||
|
||||
/*
|
||||
> resized = RL.IsWindowResized()
|
||||
> RL.ToggleFullscreen()
|
||||
|
||||
Check if window has been resized from last frame
|
||||
|
||||
- Success return bool
|
||||
Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
int lcoreIsWindowResized( lua_State *L ) {
|
||||
lua_pushboolean( L, IsWindowResized() );
|
||||
int lcoreToggleFullscreen( lua_State *L ) {
|
||||
ToggleFullscreen();
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.ToggleBorderlessWindowed()
|
||||
|
||||
Toggle window state: borderless windowed (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
int lcoreToggleBorderlessWindowed( lua_State *L ) {
|
||||
ToggleBorderlessWindowed();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.MaximizeWindow()
|
||||
|
||||
Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
int lcoreMaximizeWindow( lua_State *L ) {
|
||||
MaximizeWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.MinimizeWindow()
|
||||
|
||||
Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
int lcoreMinimizeWindow( lua_State *L ) {
|
||||
MinimizeWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.RestoreWindow()
|
||||
|
||||
Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
int lcoreRestoreWindow( lua_State *L ) {
|
||||
RestoreWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -338,7 +268,7 @@ int lcoreSetWindowIcons( lua_State *L ) {
|
||||
/*
|
||||
> RL.SetWindowTitle( string title )
|
||||
|
||||
Set title for window (Only PLATFORM_DESKTOP)
|
||||
Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB)
|
||||
*/
|
||||
int lcoreSetWindowTitle( lua_State *L ) {
|
||||
SetWindowTitle( luaL_checkstring( L, 1 ) );
|
||||
@@ -346,6 +276,136 @@ int lcoreSetWindowTitle( lua_State *L ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowPosition( Vector2 pos )
|
||||
|
||||
Set window position on screen
|
||||
*/
|
||||
int lcoreSetWindowPosition( lua_State *L ) {
|
||||
Vector2 pos = uluaGetVector2( L, 1 );
|
||||
|
||||
SetWindowPosition( pos.x, pos.y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowMonitor( int monitor )
|
||||
|
||||
Set monitor for the current window
|
||||
*/
|
||||
int lcoreSetWindowMonitor( lua_State *L ) {
|
||||
int monitor = luaL_checkinteger( L, 1 );
|
||||
|
||||
SetWindowMonitor( monitor );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowMinSize( Vector2 size )
|
||||
|
||||
Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
||||
*/
|
||||
int lcoreSetWindowMinSize( lua_State *L ) {
|
||||
Vector2 size = uluaGetVector2( L, 1 );
|
||||
|
||||
SetWindowMinSize( (int)size.x, (int)size.y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowMaxSize( Vector2 size )
|
||||
|
||||
Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)
|
||||
*/
|
||||
int lcoreSetWindowMaxSize( lua_State *L ) {
|
||||
Vector2 size = uluaGetVector2( L, 1 );
|
||||
|
||||
SetWindowMaxSize( (int)size.x, (int)size.y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowSize( Vector2 size )
|
||||
|
||||
Set window dimensions
|
||||
*/
|
||||
int lcoreSetWindowSize( lua_State *L ) {
|
||||
Vector2 size = uluaGetVector2( L, 1 );
|
||||
|
||||
SetWindowSize( (int)size.x, (int)size.y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowOpacity( float opacity )
|
||||
|
||||
Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
int lcoreSetWindowOpacity( lua_State *L ) {
|
||||
float opacity = luaL_checknumber( L, 1 );
|
||||
|
||||
SetWindowOpacity( opacity );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.SetWindowFocused()
|
||||
|
||||
Set window focused (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
int lcoreSetWindowFocused( lua_State *L ) {
|
||||
SetWindowFocused();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> windowHandle = RL.GetWindowHandle()
|
||||
|
||||
Get native window handle. Return as lightuserdata
|
||||
|
||||
- Success return lightuserdata
|
||||
*/
|
||||
int lcoreGetWindowHandle( lua_State *L ) {
|
||||
lua_pushlightuserdata( L, GetWindowHandle() );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> size = RL.GetScreenSize()
|
||||
|
||||
Get screen size
|
||||
|
||||
- Success return Vector2
|
||||
*/
|
||||
int lcoreGetScreenSize( lua_State *L ) {
|
||||
Vector2 size = (Vector2){ GetScreenWidth(), GetScreenHeight() };
|
||||
uluaPushVector2( L, size );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
> count = RL.GetMonitorCount()
|
||||
|
||||
@@ -372,6 +432,37 @@ int lcoreGetCurrentMonitor( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -403,6 +494,19 @@ int lcoreGetMonitorRefreshRate( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> position = RL.GetWindowPosition()
|
||||
|
||||
Get window position on monitor
|
||||
|
||||
- Success return Vector2
|
||||
*/
|
||||
int lcoreGetWindowPosition( lua_State *L ) {
|
||||
uluaPushVector2( L, GetWindowPosition() );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> dpi = RL.GetWindowScaleDPI()
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
@@ -431,17 +535,6 @@ int lcoreGetMonitorName( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -1151,6 +1244,63 @@ int lcoreGetTime( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## 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 ) );
|
||||
@@ -1411,6 +1561,19 @@ int lcoreGetWorkingDirectory( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -1793,6 +1956,21 @@ int lcoreIsGamepadAvailable( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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( "IsWindowState", lcoreIsWindowState );
|
||||
assingGlobalFunction( "ClearWindowState", lcoreClearWindowState );
|
||||
assingGlobalFunction( "IsWindowResized", lcoreIsWindowResized );
|
||||
assingGlobalFunction( "IsWindowState", lcoreIsWindowState );
|
||||
assingGlobalFunction( "SetWindowState", lcoreSetWindowState );
|
||||
assingGlobalFunction( "ClearWindowState", lcoreClearWindowState );
|
||||
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. */
|
||||
|
||||
67
src/shapes.c
67
src/shapes.c
@@ -54,57 +54,6 @@ int lshapesDrawLine( lua_State *L ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -130,6 +79,22 @@ int lshapesDrawLineStrip( lua_State *L ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
29
src/text.c
29
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;
|
||||
}
|
||||
@@ -460,6 +460,17 @@ int ltextDrawTextBoxedTinted( lua_State *L ) {
|
||||
## Text - Text font info functions
|
||||
*/
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
|
||||
@@ -53,6 +53,22 @@ int ltexturesLoadImageRaw( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -162,6 +178,27 @@ int ltexturesExportImage( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -197,35 +234,19 @@ 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 ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> image = RL.GenImageGradientH( Vector2 size, Color left, Color right )
|
||||
|
||||
Generate image: horizontal gradient
|
||||
|
||||
- Success return Image
|
||||
*/
|
||||
int ltexturesGenImageGradientH( lua_State *L ) {
|
||||
Vector2 size = uluaGetVector2( L, 1 );
|
||||
Color left = uluaGetColor( L, 2 );
|
||||
Color right = uluaGetColor( L, 3 );
|
||||
|
||||
uluaPushImage( L, GenImageGradientH( (int)size.x, (int)size.y, left, right ) );
|
||||
uluaPushImage( L, GenImageGradientLinear( (int)size.x, (int)size.y, direction, start, end ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -248,6 +269,24 @@ int ltexturesGenImageGradientRadial( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> image = RL.GenImageGradientSquare( Vector2 size, float density, Color inner, Color outer )
|
||||
|
||||
Generate image: square gradient
|
||||
|
||||
- Success return Image
|
||||
*/
|
||||
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, GenImageGradientSquare( (int)size.x, (int)size.y, density, inner, outer ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> image = RL.GenImageChecked( Vector2 size, Vector2 checks, Color col1, Color col2 )
|
||||
|
||||
@@ -592,6 +631,20 @@ int ltexturesImageFlipHorizontal( lua_State *L ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user