From 870e3a46a6fcdbd5b264406984d232874f138ea3 Mon Sep 17 00:00:00 2001 From: jussi Date: Mon, 15 May 2023 14:18:58 +0300 Subject: More rlgl General render state functions. Fixed rlgl function prefix to rl. --- src/lua_core.c | 20 +++++++-- src/rlgl.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lua_core.c b/src/lua_core.c index 1caf1c7..5b51114 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -498,6 +498,9 @@ void defineGlobals() { assignGlobalInt( RL_OPENGL_33, "RL_OPENGL_33" ); assignGlobalInt( RL_OPENGL_43, "RL_OPENGL_43" ); assignGlobalInt( RL_OPENGL_ES_20, "RL_OPENGL_ES_20" ); + /* rlCullMode */ + assignGlobalInt( RL_CULL_FACE_FRONT, "RL_CULL_FACE_FRONT" ); + assignGlobalInt( RL_CULL_FACE_BACK, "RL_CULL_FACE_BACK" ); /* OpenGL */ assignGlobalInt( GL_COLOR_BUFFER_BIT, "GL_COLOR_BUFFER_BIT" ); assignGlobalInt( GL_DEPTH_BUFFER_BIT, "GL_DEPTH_BUFFER_BIT" ); @@ -1355,10 +1358,21 @@ void luaRegister() { /* RLGL */ /* General render state. */ - assingGlobalFunction( "rlglSetLineWidth", lrlglSetLineWidth ); - assingGlobalFunction( "rlglGetLineWidth", lrlglGetLineWidth ); + assingGlobalFunction( "rlEnableColorBlend", lrlglEnableColorBlend ); + assingGlobalFunction( "rlDisableColorBlend", lrlglDisableColorBlend ); + assingGlobalFunction( "rlEnableDepthTest", lrlglEnableDepthTest ); + assingGlobalFunction( "rlDisableDepthTest", lrlglDisableDepthTest ); + assingGlobalFunction( "rlEnableDepthMask", lrlglEnableDepthMask ); + assingGlobalFunction( "rlDisableDepthMask", lrlglDisableDepthMask ); + assingGlobalFunction( "rlEnableBackfaceCulling", lrlglEnableBackfaceCulling ); + assingGlobalFunction( "rlDisableBackfaceCulling", lrlglDisableBackfaceCulling ); + assingGlobalFunction( "rlSetCullFace", lrlglSetCullFace ); + assingGlobalFunction( "rlSetLineWidth", lrlglSetLineWidth ); + assingGlobalFunction( "rlGetLineWidth", lrlglGetLineWidth ); + assingGlobalFunction( "rlEnableSmoothLines", lrlglEnableSmoothLines ); + assingGlobalFunction( "rlDisableSmoothLines", lrlglDisableSmoothLines ); /* Initialization functions. */ - assingGlobalFunction( "rlglGetVersion", lrlglGetVersion ); + assingGlobalFunction( "rlGetVersion", lrlglGetVersion ); /* OpenGL */ /* Framebuffer management. */ diff --git a/src/rlgl.c b/src/rlgl.c index 00e42db..afe2e26 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -7,6 +7,114 @@ ## RLGL - General render state */ +/* +> RL.rlEnableColorBlend() + +Enable color blending +*/ +int lrlglEnableColorBlend( lua_State *L ) { + rlEnableColorBlend(); + + return 0; +} + +/* +> RL.rlDisableColorBlend() + +Disable color blending +*/ +int lrlglDisableColorBlend( lua_State *L ) { + rlDisableColorBlend(); + + return 0; +} + +/* +> RL.rlEnableDepthTest() + +Enable depth test +*/ +int lrlglEnableDepthTest( lua_State *L ) { + rlEnableDepthTest(); + + return 0; +} + +/* +> RL.rlDisableDepthTest() + +Disable depth test +*/ +int lrlglDisableDepthTest( lua_State *L ) { + rlDisableDepthTest(); + + return 0; +} + +/* +> RL.rlEnableDepthMask() + +Enable depth write +*/ +int lrlglEnableDepthMask( lua_State *L ) { + rlEnableDepthMask(); + + return 0; +} + +/* +> RL.rlDisableDepthMask() + +Disable depth write +*/ +int lrlglDisableDepthMask( lua_State *L ) { + rlDisableDepthMask(); + + return 0; +} + +/* +> RL.rlEnableBackfaceCulling() + +Enable backface culling +*/ +int lrlglEnableBackfaceCulling( lua_State *L ) { + rlEnableBackfaceCulling(); + + return 0; +} + +/* +> RL.rlDisableBackfaceCulling() + +Disable backface culling +*/ +int lrlglDisableBackfaceCulling( lua_State *L ) { + rlDisableBackfaceCulling(); + + return 0; +} + +/* +> success = RL.rlSetCullFace( int mode ) + +Set face culling mode + +- Failure return false +- Success return true +*/ +int lrlglSetCullFace( lua_State *L ) { + if ( !lua_isnumber( L, 1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlSetCullFace( int mode )" ); + lua_pushboolean( L, false ); + return 1; + } + rlSetCullFace( lua_tointeger( L, 1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + /* > success = RL.rlSetLineWidth( float width ) @@ -40,6 +148,28 @@ int lrlglGetLineWidth( lua_State *L ) { return 1; } +/* +> RL.rlEnableSmoothLines() + +Enable line aliasing +*/ +int lrlglEnableSmoothLines( lua_State *L ) { + rlEnableSmoothLines(); + + return 0; +} + +/* +> RL.rlDisableSmoothLines() + +Disable line aliasing +*/ +int lrlglDisableSmoothLines( lua_State *L ) { + rlDisableSmoothLines(); + + return 0; +} + /* ## RLGL - Initialization functions */ -- cgit v1.2.3