More window related functions.

This commit is contained in:
jussi
2022-03-31 12:58:50 +03:00
parent f5b723519f
commit a3c28c0001
5 changed files with 359 additions and 1 deletions

117
API.md
View File

@@ -702,6 +702,54 @@ int id. ModelAnimations
---
> state = RL_IsWindowReady()
Check if window has been initialized successfully
- Success return bool
---
> state = RL_IsWindowFullscreen()
Check if window is currently fullscreen
- Success return bool
---
> state = RL_IsWindowHidden()
Check if window is currently hidden ( only PLATFORM_DESKTOP )
- Success return bool
---
> state = RL_IsWindowMinimized()
Check if window is currently minimized ( only PLATFORM_DESKTOP )
- Success return bool
---
> state = RL_IsWindowMaximized()
Check if window is currently maximized ( only PLATFORM_DESKTOP )
- Success return bool
---
> state = RL_IsWindowFocused()
Check if window is currently focused ( only PLATFORM_DESKTOP )
- Success return bool
---
> success = RL_SetWindowMonitor( int monitor )
Set monitor for the current window (fullscreen mode)
@@ -729,6 +777,15 @@ Set window dimensions
---
> success = RL_SetWindowMinSize( Vector2 size )
Set window minimum dimensions ( for FLAG_WINDOW_RESIZABLE )
- Failure return false
- Success return true
---
> position = RL_GetMonitorPosition( int monitor )
Get specified monitor position
@@ -823,12 +880,72 @@ Get number of connected monitors
---
> monitor = RL_GetCurrentMonitor()
Get current connected monitor
- Success return int
---
> size = RL_GetMonitorPhysicalSize( int monitor )
Get specified monitor physical size in millimetres
- Failure return false
- Success return Vector2
---
> size = RL_GetMonitorRefreshRate( int monitor )
Get specified monitor refresh rate
- Failure return false
- Success return int
---
> scale = RL_GetWindowScaleDPI()
Get window scale DPI factor
- Success return Vector2
---
> name = RL_GetMonitorName( int monitor )
Get the human-readable, UTF-8 encoded name of the monitor
- Failure return false
- Success return string
---
> RL_CloseWindow()
Close window and unload OpenGL context and free all resources
---
> success = RL_SetClipboardText( string text )
Set clipboard text content
- Failure return false
- Success return true
---
> text = RL_GetClipboardText()
Get clipboard text content
- Success return string
---
## Core - Timing
---

View File

@@ -5,7 +5,6 @@ Backlog {
* More and better examples
* Core
* Clipboard
* Screen-space-related
* Files drop
* Text

View File

@@ -3,9 +3,16 @@
/* Validators. */
bool validCamera3D( size_t id );
/* Window. */
int lcoreIsWindowReady( lua_State *L );
int lcoreIsWindowFullscreen( lua_State *L );
int lcoreIsWindowHidden( lua_State *L );
int lcoreIsWindowMinimized( lua_State *L );
int lcoreIsWindowMaximized( lua_State *L );
int lcoreIsWindowFocused( lua_State *L );
int lcoreSetWindowMonitor( lua_State *L );
int lcoreSetWindowPosition( lua_State *L );
int lcoreSetWindowSize( lua_State *L );
int lcoreSetWindowMinSize( lua_State *L );
int lcoreGetMonitorPosition( lua_State *L );
int lcoreGetMonitorSize( lua_State *L );
int lcoreGetWindowPosition( lua_State *L );
@@ -17,7 +24,14 @@ int lcoreIsWindowResized( lua_State *L );
int lcoreSetWindowIcon( lua_State *L );
int lcoreSetWindowTitle( lua_State *L );
int lcoreGetMonitorCount( lua_State *L );
int lcoreGetCurrentMonitor( lua_State *L );
int lcoreGetMonitorPhysicalSize( lua_State *L );
int lcoreGetMonitorRefreshRate( lua_State *L );
int lcoreGetWindowScaleDPI( lua_State *L );
int lcoreGetMonitorName( lua_State *L );
int lcoreCloseWindow( lua_State *L );
int lcoreSetClipboardText( lua_State *L );
int lcoreGetClipboardText( lua_State *L );
/* Timing. */
int lcoreSetTargetFPS( lua_State *L );
int lcoreGetFrameTime( lua_State *L );

View File

@@ -58,6 +58,84 @@ static inline bool validShader( size_t id ) {
## Core - Window
*/
/*
> state = RL_IsWindowReady()
Check if window has been initialized successfully
- Success return bool
*/
int lcoreIsWindowReady( lua_State *L ) {
lua_pushboolean( L, IsWindowReady() );
return 1;
}
/*
> state = RL_IsWindowFullscreen()
Check if window is currently fullscreen
- Success return bool
*/
int lcoreIsWindowFullscreen( lua_State *L ) {
lua_pushboolean( L, IsWindowFullscreen() );
return 1;
}
/*
> state = RL_IsWindowHidden()
Check if window is currently hidden ( only PLATFORM_DESKTOP )
- Success return bool
*/
int lcoreIsWindowHidden( lua_State *L ) {
lua_pushboolean( L, IsWindowHidden() );
return 1;
}
/*
> state = RL_IsWindowMinimized()
Check if window is currently minimized ( only PLATFORM_DESKTOP )
- Success return bool
*/
int lcoreIsWindowMinimized( lua_State *L ) {
lua_pushboolean( L, IsWindowMinimized() );
return 1;
}
/*
> state = RL_IsWindowMaximized()
Check if window is currently maximized ( only PLATFORM_DESKTOP )
- Success return bool
*/
int lcoreIsWindowMaximized( lua_State *L ) {
lua_pushboolean( L, IsWindowMaximized() );
return 1;
}
/*
> state = RL_IsWindowFocused()
Check if window is currently focused ( only PLATFORM_DESKTOP )
- Success return bool
*/
int lcoreIsWindowFocused( lua_State *L ) {
lua_pushboolean( L, IsWindowFocused() );
return 1;
}
/*
> success = RL_SetWindowMonitor( int monitor )
@@ -119,6 +197,27 @@ int lcoreSetWindowSize( lua_State *L ) {
return 1;
}
/*
> success = RL_SetWindowMinSize( Vector2 size )
Set window minimum dimensions ( for FLAG_WINDOW_RESIZABLE )
- Failure return false
- Success return true
*/
int lcoreSetWindowMinSize( lua_State *L ) {
if ( !lua_istable( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetWindowMinSize( Vector2 size )" );
lua_pushboolean( L, false );
return 1;
}
Vector2 size = uluaGetVector2( L );
SetWindowMinSize( (int)size.x, (int)size.y );
lua_pushboolean( L, true );
return 1;
}
/*
> position = RL_GetMonitorPosition( int monitor )
@@ -313,6 +412,90 @@ int lcoreGetMonitorCount( lua_State *L ) {
return 1;
}
/*
> monitor = RL_GetCurrentMonitor()
Get current connected monitor
- Success return int
*/
int lcoreGetCurrentMonitor( lua_State *L ) {
lua_pushinteger( L, GetCurrentMonitor() );
return 1;
}
/*
> size = RL_GetMonitorPhysicalSize( int monitor )
Get specified monitor physical size in millimetres
- Failure return false
- Success return Vector2
*/
int lcoreGetMonitorPhysicalSize( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetMonitorPhysicalSize( int monitor )" );
lua_pushboolean( L, false );
return 1;
}
int monitor = lua_tointeger( L, -1 );
Vector2 size = { GetMonitorPhysicalWidth( monitor ), GetMonitorPhysicalHeight( monitor ) };
uluaPushVector2( L, size );
return 1;
}
/*
> size = RL_GetMonitorRefreshRate( int monitor )
Get specified monitor refresh rate
- Failure return false
- Success return int
*/
int lcoreGetMonitorRefreshRate( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetMonitorRefreshRate( int monitor )" );
lua_pushboolean( L, false );
return 1;
}
lua_pushinteger( L, GetMonitorRefreshRate( lua_tointeger( L, -1 ) ) );
return 1;
}
/*
> scale = RL_GetWindowScaleDPI()
Get window scale DPI factor
- Success return Vector2
*/
int lcoreGetWindowScaleDPI( lua_State *L ) {
uluaPushVector2( L, GetWindowScaleDPI() );
return 1;
}
/*
> name = RL_GetMonitorName( int monitor )
Get the human-readable, UTF-8 encoded name of the monitor
- Failure return false
- Success return string
*/
int lcoreGetMonitorName( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetMonitorName( int monitor )" );
lua_pushboolean( L, false );
return 1;
}
lua_pushstring( L, GetMonitorName( lua_tointeger( L, -1 ) ) );
return 1;
}
/*
> RL_CloseWindow()
@@ -324,6 +507,37 @@ int lcoreCloseWindow( lua_State *L ) {
return 0;
}
/*
> success = RL_SetClipboardText( string text )
Set clipboard text content
- Failure return false
- Success return true
*/
int lcoreSetClipboardText( lua_State *L ) {
if ( !lua_isstring( L, -1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetClipboardText( string text )" );
lua_pushboolean( L, false );
return 1;
}
SetClipboardText( lua_tostring( L, -1 ) );
lua_pushboolean( L, true );
return 1;
}
/*
> text = RL_GetClipboardText()
Get clipboard text content
- Success return string
*/
int lcoreGetClipboardText( lua_State *L ) {
lua_pushstring( L, GetClipboardText() );
return 1;
}
/*
## Core - Timing
*/

View File

@@ -472,9 +472,16 @@ void luaRegister() {
/* Core. */
/* Window. */
lua_register( L, "RL_IsWindowReady", lcoreIsWindowReady );
lua_register( L, "RL_IsWindowFullscreen", lcoreIsWindowFullscreen );
lua_register( L, "RL_IsWindowHidden", lcoreIsWindowHidden );
lua_register( L, "RL_IsWindowMinimized", lcoreIsWindowMinimized );
lua_register( L, "RL_IsWindowMaximized", lcoreIsWindowMaximized );
lua_register( L, "RL_IsWindowFocused", lcoreIsWindowFocused );
lua_register( L, "RL_SetWindowMonitor", lcoreSetWindowMonitor );
lua_register( L, "RL_SetWindowPosition", lcoreSetWindowPosition );
lua_register( L, "RL_SetWindowSize", lcoreSetWindowSize );
lua_register( L, "RL_SetWindowMinSize", lcoreSetWindowMinSize );
lua_register( L, "RL_GetMonitorPosition", lcoreGetMonitorPosition );
lua_register( L, "RL_GetMonitorSize", lcoreGetMonitorSize );
lua_register( L, "RL_GetWindowPosition", lcoreGetWindowPosition );
@@ -486,7 +493,14 @@ void luaRegister() {
lua_register( L, "RL_SetWindowIcon", lcoreSetWindowIcon );
lua_register( L, "RL_SetWindowTitle", lcoreSetWindowTitle );
lua_register( L, "RL_GetMonitorCount", lcoreGetMonitorCount );
lua_register( L, "RL_GetCurrentMonitor", lcoreGetCurrentMonitor );
lua_register( L, "RL_GetMonitorPhysicalSize", lcoreGetMonitorPhysicalSize );
lua_register( L, "RL_GetMonitorRefreshRate", lcoreGetMonitorRefreshRate );
lua_register( L, "RL_GetWindowScaleDPI", lcoreGetWindowScaleDPI );
lua_register( L, "RL_GetMonitorName", lcoreGetMonitorName );
lua_register( L, "RL_CloseWindow", lcoreCloseWindow );
lua_register( L, "RL_SetClipboardText", lcoreSetClipboardText );
lua_register( L, "RL_GetClipboardText", lcoreGetClipboardText );
/* Timing. */
lua_register( L, "RL_SetTargetFPS", lcoreSetTargetFPS );
lua_register( L, "RL_GetFrameTime", lcoreGetFrameTime );