summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2022-03-31 12:58:50 +0300
committerjussi2022-03-31 12:58:50 +0300
commita3c28c00016fb2a2bd13b36e7269c69b0529c6a4 (patch)
tree03b1520eb2d3d0717bd584dd290e9720db2d950c
parentf5b723519f8dd9358db15ac5f366f6646905715f (diff)
downloadreilua-enhanced-a3c28c00016fb2a2bd13b36e7269c69b0529c6a4.tar.gz
reilua-enhanced-a3c28c00016fb2a2bd13b36e7269c69b0529c6a4.tar.bz2
reilua-enhanced-a3c28c00016fb2a2bd13b36e7269c69b0529c6a4.zip
More window related functions.
-rw-r--r--API.md117
-rw-r--r--devnotes1
-rw-r--r--include/core.h14
-rw-r--r--src/core.c214
-rw-r--r--src/lua_core.c14
5 files changed, 359 insertions, 1 deletions
diff --git a/API.md b/API.md
index 82f5599..2664d48 100644
--- a/API.md
+++ b/API.md
@@ -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
---
diff --git a/devnotes b/devnotes
index ba74197..afb4022 100644
--- a/devnotes
+++ b/devnotes
@@ -5,7 +5,6 @@ Backlog {
* More and better examples
* Core
- * Clipboard
* Screen-space-related
* Files drop
* Text
diff --git a/include/core.h b/include/core.h
index 0602300..c443542 100644
--- a/include/core.h
+++ b/include/core.h
@@ -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 );
diff --git a/src/core.c b/src/core.c
index ef8cfed..8f67c34 100644
--- a/src/core.c
+++ b/src/core.c
@@ -59,6 +59,84 @@ static inline bool validShader( size_t id ) {
*/
/*
+> 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 )
Set monitor for the current window (fullscreen mode)
@@ -120,6 +198,27 @@ int lcoreSetWindowSize( lua_State *L ) {
}
/*
+> 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 )
Get specified monitor position
@@ -314,6 +413,90 @@ int lcoreGetMonitorCount( lua_State *L ) {
}
/*
+> 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()
Close window and unload OpenGL context and free all resources
@@ -325,6 +508,37 @@ int lcoreCloseWindow( lua_State *L ) {
}
/*
+> 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
*/
diff --git a/src/lua_core.c b/src/lua_core.c
index aeeec9c..4cfbafd 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -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 );