From d351b7b025f95983e49afaecb2fafef7802996a0 Mon Sep 17 00:00:00 2001 From: jussi Date: Tue, 31 Oct 2023 12:21:25 +0200 Subject: More RLGL Initialization functions. --- src/lua_core.c | 7 +++++ src/rlgl.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/state.c | 1 + 3 files changed, 106 insertions(+) (limited to 'src') diff --git a/src/lua_core.c b/src/lua_core.c index cd53c83..cb91583 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -2257,6 +2257,13 @@ void luaRegister() { assingGlobalFunction( "rlSetBlendFactorsSeparate", lrlglSetBlendFactorsSeparate ); /* Initialization functions. */ assingGlobalFunction( "rlGetVersion", lrlglGetVersion ); + assingGlobalFunction( "rlSetFramebufferWidth", lrlglSetFramebufferWidth ); + assingGlobalFunction( "rlGetFramebufferWidth", lrlglGetFramebufferWidth ); + assingGlobalFunction( "rlSetFramebufferHeight", lrlglSetFramebufferHeight ); + assingGlobalFunction( "rlGetFramebufferHeight", lrlglGetFramebufferHeight ); + assingGlobalFunction( "rlGetTextureIdDefault", lrlglGetTextureIdDefault ); + assingGlobalFunction( "rlGetShaderIdDefault", lrlglGetShaderIdDefault ); + assingGlobalFunction( "rlGetShaderLocsDefault", lrlglGetShaderLocsDefault ); /* Render batch management. */ assingGlobalFunction( "rlDrawRenderBatchActive", lrlglDrawRenderBatchActive ); assingGlobalFunction( "rlCheckRenderBatchLimit", lrlglCheckRenderBatchLimit ); diff --git a/src/rlgl.c b/src/rlgl.c index 5855f60..2dc1b37 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -864,6 +864,104 @@ int lrlglGetVersion( lua_State *L ) { return 1; } +/* +> version = RL.rlSetFramebufferWidth( int width ) + +Set current framebuffer width +*/ +int lrlglSetFramebufferWidth( lua_State *L ) { + int width = luaL_checkinteger( L, 1 ); + + rlSetFramebufferWidth( width ); + + return 0; +} + +/* +> width = RL.rlGetFramebufferWidth() + +Get default framebuffer width + +- Success return int +*/ +int lrlglGetFramebufferWidth( lua_State *L ) { + lua_pushinteger( L, rlGetFramebufferWidth() ); + + return 1; +} + +/* +> version = RL.rlSetFramebufferHeight( int height ) + +Set current framebuffer height +*/ +int lrlglSetFramebufferHeight( lua_State *L ) { + int height = luaL_checkinteger( L, 1 ); + + rlSetFramebufferWidth( height ); + + return 0; +} + +/* +> height = RL.rlGetFramebufferHeight() + +Get default framebuffer height + +- Success return int +*/ +int lrlglGetFramebufferHeight( lua_State *L ) { + lua_pushinteger( L, rlGetFramebufferHeight() ); + + return 1; +} + +/* +> id = RL.rlGetTextureIdDefault() + +Get default texture id + +- Success return int +*/ +int lrlglGetTextureIdDefault( lua_State *L ) { + lua_pushinteger( L, rlGetTextureIdDefault() ); + + return 1; +} + +/* +> id = RL.rlGetShaderIdDefault() + +Get default shader id + +- Success return int +*/ +int lrlglGetShaderIdDefault( lua_State *L ) { + lua_pushinteger( L, rlGetShaderIdDefault() ); + + return 1; +} + +/* +> locations = RL.rlGetShaderLocsDefault() + +Get default shader locations + +- Success return int{} +*/ +int lrlglGetShaderLocsDefault( lua_State *L ) { + int *locs = rlGetShaderLocsDefault(); + + lua_createtable( L, RL_MAX_SHADER_LOCATIONS, 0 ); + + for ( int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++ ) { + lua_pushinteger( L, locs[i] ); + lua_rawseti( L, -2, i + 1 ); + } + + return 1; +} + /* ## RLGL - Render batch management */ diff --git a/src/state.c b/src/state.c index 228cbce..3706561 100644 --- a/src/state.c +++ b/src/state.c @@ -41,6 +41,7 @@ bool stateInit( int argn, const char **argc, const char *exePath ) { for ( int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++ ) { state->RLGLcurrentShaderLocs[i] = defaultShaderLocs[i]; + printf( "defaultShaderLocs[%d] %d\n", i, defaultShaderLocs[i] ); } return state->run; -- cgit v1.2.3