summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2023-10-22 22:13:27 +0300
committerjussi2023-10-22 22:13:27 +0300
commit6915f3e27c7a2f4ed8c90909a9aa9cb8906d1c00 (patch)
tree1353262eb323eba14b886daf9510ca02060b74da /src
parent95be0403e69b3047a0375cf965dedca0ad876409 (diff)
downloadreilua-enhanced-6915f3e27c7a2f4ed8c90909a9aa9cb8906d1c00.tar.gz
reilua-enhanced-6915f3e27c7a2f4ed8c90909a9aa9cb8906d1c00.tar.bz2
reilua-enhanced-6915f3e27c7a2f4ed8c90909a9aa9cb8906d1c00.zip
rlgl Matrix state management.
Diffstat (limited to 'src')
-rw-r--r--src/lua_core.c10
-rw-r--r--src/rlgl.c165
2 files changed, 173 insertions, 2 deletions
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;
+}