summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--changelog3
-rw-r--r--devnotes1
-rw-r--r--include/lrlgl.h12
-rw-r--r--lib/.gitignore4
-rw-r--r--src/lua_core.c10
-rw-r--r--src/rlgl.c165
7 files changed, 190 insertions, 7 deletions
diff --git a/README.md b/README.md
index 2fc5fe1..5f7cdc7 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ Application needs 'main.lua' or 'main' file as entry point. ReiLua executable wi
Example of basic "main.lua" file that will show basic windows with text.
-```
+```Lua
local textColor = RL.BLACK
local textPos = { 192, 200 }
diff --git a/changelog b/changelog
index b31f25e..3d7f71b 100644
--- a/changelog
+++ b/changelog
@@ -34,6 +34,7 @@ KEY CHANGES:
- ADDED: rlgl Shader state.
- ADDED: RL.event function with input events.
- ADDED: Window events.
+ - ADDED: rlgl Matrix state management.
Detailed changes:
- FIXED: uluaGetRay was looking for integers instead of tables
@@ -103,7 +104,7 @@ Detailed changes:
- FIXED: isValidRenderTexture checks that it is TEXTURE_TYPE_RENDER_TEXTURE
- FIXED: isValidTexture on CreateMaterial
- CHANGED: Renamed start, end arguments to a, b to avoid using Lua keyword "end" in argument names
- - ADDED: Argumets stored in "RL.arg" array
+ - ADDED: Arguments stored in "RL.arg" array
------------------------------------------------------------------------
Release: ReiLua version 0.4.0 Using Raylib 4.2
diff --git a/devnotes b/devnotes
index 314427e..c9644b1 100644
--- a/devnotes
+++ b/devnotes
@@ -1,7 +1,6 @@
Current {
* rlgl
* Vertex buffers management
- * Matrix state management
* Shaders management
* Compute shader management
}
diff --git a/include/lrlgl.h b/include/lrlgl.h
index 40df95c..7ca2740 100644
--- a/include/lrlgl.h
+++ b/include/lrlgl.h
@@ -95,4 +95,14 @@ int lrlglUnloadTexture( lua_State *L );
int lrlglLoadFramebuffer( lua_State *L );
int lrlglFramebufferAttach( lua_State *L );
int lrlglFramebufferComplete( lua_State *L );
-int lrlglUnloadFramebuffer( lua_State *L ); \ No newline at end of file
+int lrlglUnloadFramebuffer( lua_State *L );
+/* Matrix state management */
+int lrlglGetMatrixModelview( lua_State *L );
+int lrlglGetMatrixProjection( lua_State *L );
+int lrlglGetMatrixTransform( lua_State *L );
+int lrlglGetMatrixProjectionStereo( lua_State *L );
+int lrlglGetMatrixViewOffsetStereo( lua_State *L );
+int lrlglSetMatrixProjection( lua_State *L );
+int lrlglSetMatrixModelview( lua_State *L );
+int lrlglSetMatrixProjectionStereo( lua_State *L );
+int lrlglSetMatrixViewOffsetStereo( lua_State *L );
diff --git a/lib/.gitignore b/lib/.gitignore
index f59ec20..7c5d27d 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -1 +1,3 @@
-* \ No newline at end of file
+libraylib.a
+liblua.a
+libluajit.a
diff --git a/src/lua_core.c b/src/lua_core.c
index c254a9d..f8b25bb 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1957,6 +1957,16 @@ void luaRegister() {
assingGlobalFunction( "rlFramebufferAttach", lrlglFramebufferAttach );
assingGlobalFunction( "rlFramebufferComplete", lrlglFramebufferComplete );
assingGlobalFunction( "rlUnloadFramebuffer", lrlglUnloadFramebuffer );
+ /* Matrix state management. */
+ assingGlobalFunction( "rlGetMatrixModelview", lrlglGetMatrixModelview );
+ assingGlobalFunction( "rlGetMatrixProjection", lrlglGetMatrixProjection );
+ assingGlobalFunction( "rlGetMatrixTransform", lrlglGetMatrixTransform );
+ assingGlobalFunction( "rlGetMatrixProjectionStereo", lrlglGetMatrixProjectionStereo );
+ assingGlobalFunction( "rlGetMatrixViewOffsetStereo", lrlglGetMatrixViewOffsetStereo );
+ assingGlobalFunction( "rlSetMatrixProjection", lrlglSetMatrixProjection );
+ assingGlobalFunction( "rlSetMatrixModelview", lrlglSetMatrixModelview );
+ assingGlobalFunction( "rlSetMatrixProjectionStereo", lrlglSetMatrixProjectionStereo );
+ assingGlobalFunction( "rlSetMatrixViewOffsetStereo", lrlglSetMatrixViewOffsetStereo );
/* OpenGL */
/* Framebuffer management. */
diff --git a/src/rlgl.c b/src/rlgl.c
index 06425ff..b369047 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -1579,7 +1579,7 @@ Delete framebuffer from GPU
int lrlglUnloadFramebuffer( lua_State *L ) {
if ( !lua_isnumber( L, 1 ) ) {
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadFramebuffer( int id )" );
- lua_pushboolean( L, false );
+ lua_pushnil( L );
return 1;
}
unsigned int id = lua_tointeger( L, 1 );
@@ -1588,4 +1588,165 @@ int lrlglUnloadFramebuffer( lua_State *L ) {
lua_pushboolean( L, true );
return 1;
-} \ No newline at end of file
+}
+
+/*
+## RLGL - Matrix state management
+*/
+
+/*
+> modelview = RL.rlGetMatrixModelview()
+
+Get internal modelview matrix
+
+- Success return Matrix
+*/
+int lrlglGetMatrixModelview( lua_State *L ) {
+ uluaPushMatrix( L, rlGetMatrixModelview() );
+
+ return 1;
+}
+
+/*
+> projection = RL.rlGetMatrixProjection()
+
+Get internal projection matrix
+
+- Success return Matrix
+*/
+int lrlglGetMatrixProjection( lua_State *L ) {
+ uluaPushMatrix( L, rlGetMatrixProjection() );
+
+ return 1;
+}
+
+/*
+> transform = RL.rlGetMatrixTransform()
+
+Get internal accumulated transform matrix
+
+- Success return Matrix
+*/
+int lrlglGetMatrixTransform( lua_State *L ) {
+ uluaPushMatrix( L, rlGetMatrixTransform() );
+
+ return 1;
+}
+
+/*
+> projection = RL.rlGetMatrixProjectionStereo( int eye )
+
+Get internal projection matrix for stereo render (selected eye)
+
+- Failure return false
+- Success return Matrix
+*/
+int lrlglGetMatrixProjectionStereo( lua_State *L ) {
+ if ( !lua_isnumber( L, 1 ) ) {
+ TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlGetMatrixProjectionStereo( int eye )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ uluaPushMatrix( L, rlGetMatrixProjectionStereo( lua_tointeger( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> viewOffset = RL.rlGetMatrixViewOffsetStereo( int eye )
+
+Get internal view offset matrix for stereo render (selected eye)
+
+- Failure return false
+- Success return Matrix
+*/
+int lrlglGetMatrixViewOffsetStereo( lua_State *L ) {
+ if ( !lua_isnumber( L, 1 ) ) {
+ TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlGetMatrixViewOffsetStereo( int eye )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ uluaPushMatrix( L, rlGetMatrixViewOffsetStereo( lua_tointeger( L, 1 ) ) );
+
+ return 1;
+}
+
+/*
+> success = RL.rlSetMatrixProjection( Matrix proj )
+
+Set a custom projection matrix (replaces internal projection matrix)
+
+- Failure return false
+- Success return true
+*/
+int lrlglSetMatrixProjection( lua_State *L ) {
+ if ( !lua_istable( L, 1 ) ) {
+ TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixProjection( Matrix proj )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ rlSetMatrixProjection( uluaGetMatrixIndex( L, 1 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> success = RL.rlSetMatrixModelview( Matrix view )
+
+Set a custom modelview matrix (replaces internal modelview matrix)
+
+- Failure return false
+- Success return true
+*/
+int lrlglSetMatrixModelview( lua_State *L ) {
+ if ( !lua_istable( L, 1 ) ) {
+ TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixModelview( Matrix view )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ rlSetMatrixModelview( uluaGetMatrixIndex( L, 1 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> success = RL.rlSetMatrixProjectionStereo( Matrix right, Matrix left )
+
+Set eyes projection matrices for stereo rendering
+
+- Failure return false
+- Success return true
+*/
+int lrlglSetMatrixProjectionStereo( lua_State *L ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
+ TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixModelview( Matrix right, Matrix left )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ rlSetMatrixProjectionStereo( uluaGetMatrixIndex( L, 1 ), uluaGetMatrixIndex( L, 2 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}
+
+/*
+> success = RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left )
+
+Set eyes view offsets matrices for stereo rendering
+
+- Failure return false
+- Success return true
+*/
+int lrlglSetMatrixViewOffsetStereo( lua_State *L ) {
+ if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) {
+ TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ rlSetMatrixViewOffsetStereo( uluaGetMatrixIndex( L, 1 ), uluaGetMatrixIndex( L, 2 ) );
+ lua_pushboolean( L, true );
+
+ return 1;
+}