From d550afa3d41e49c6cb215498db0eb547a628d578 Mon Sep 17 00:00:00 2001 From: jussi Date: Fri, 2 Jun 2023 16:18:32 +0300 Subject: RLGL Textures state functions. --- API.md | 61 ++++++++++++++++++++++++++ ReiLua_API.lua | 49 +++++++++++++++++++++ changelog | 1 + include/lrlgl.h | 8 ++++ src/core.c | 3 +- src/lua_core.c | 8 ++++ src/rlgl.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 262 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index b846443..39eaef7 100644 --- a/API.md +++ b/API.md @@ -6833,6 +6833,67 @@ Get light enabled --- +## RLGL - Textures state + +--- + +> success = RL.rlActiveTextureSlot( int slot ) + +Select and active a texture slot + +- Failure return false +- Success return true + +--- + +> success = RL.rlEnableTexture( int id ) + +Enable texture + +- Failure return false +- Success return true + +--- + +> RL.rlDisableTexture() + +Disable texture + +--- + +> success = RL.rlEnableTextureCubemap( int id ) + +Enable texture cubemap + +- Failure return false +- Success return true + +--- + +> RL.rlDisableTextureCubemap() + +Disable texture cubemap + +--- + +> success = RL.rlTextureParameters( int id, int param, int value ) + +Set texture parameters ( filter, wrap ) + +- Failure return false +- Success return true + +--- + +> success = RL.rlCubemapParameters( int id, int param, int value ) + +Set cubemap parameters ( filter, wrap ) + +- Failure return false +- Success return true + +--- + ## RLGL - Framebuffer state --- diff --git a/ReiLua_API.lua b/ReiLua_API.lua index 3f0a274..990295e 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -5549,6 +5549,55 @@ function RL.GetLightColor( light ) end ---@return any enabled function RL.IsLightEnabled( light ) end +-- RLGL - Textures state + +---Select and active a texture slot +---- Failure return false +---- Success return true +---@param slot integer +---@return any success +function RL.rlActiveTextureSlot( slot ) end + +---Enable texture +---- Failure return false +---- Success return true +---@param id integer +---@return any success +function RL.rlEnableTexture( id ) end + +---Disable texture +---@return any RL.rlDisableTexture +function RL.rlDisableTexture() end + +---Enable texture cubemap +---- Failure return false +---- Success return true +---@param id integer +---@return any success +function RL.rlEnableTextureCubemap( id ) end + +---Disable texture cubemap +---@return any RL.rlDisableTextureCubemap +function RL.rlDisableTextureCubemap() end + +---Set texture parameters ( filter, wrap ) +---- Failure return false +---- Success return true +---@param id integer +---@param param integer +---@param value integer +---@return any success +function RL.rlTextureParameters( id, param, value ) end + +---Set cubemap parameters ( filter, wrap ) +---- Failure return false +---- Success return true +---@param id integer +---@param param integer +---@param value integer +---@return any success +function RL.rlCubemapParameters( id, param, value ) end + -- RLGL - Framebuffer state ---Enable render texture (fbo) diff --git a/changelog b/changelog index c20c829..ac393f5 100644 --- a/changelog +++ b/changelog @@ -82,6 +82,7 @@ Detailed changes: - ADDED: SetMaterialParams and GetMaterialParams - ADDED: GetTextureId - ADDED: RLGL defines + - ADDED: RLGL Textures state functions ------------------------------------------------------------------------ Release: ReiLua version 0.4.0 Using Raylib 4.2 diff --git a/include/lrlgl.h b/include/lrlgl.h index 8784a17..b07fc09 100644 --- a/include/lrlgl.h +++ b/include/lrlgl.h @@ -1,5 +1,13 @@ #pragma once +/* Textures state */ +int lrlglActiveTextureSlot( lua_State *L ); +int lrlglEnableTexture( lua_State *L ); +int lrlglDisableTexture( lua_State *L ); +int lrlglEnableTextureCubemap( lua_State *L ); +int lrlglDisableTextureCubemap( lua_State *L ); +int lrlglTextureParameters( lua_State *L ); +int lrlglCubemapParameters( lua_State *L ); /* Framebuffer state. */ int lrlglEnableFramebuffer( lua_State *L ); int lrlglDisableFramebuffer( lua_State *L ); diff --git a/src/core.c b/src/core.c index 313fd88..6c8e7a1 100644 --- a/src/core.c +++ b/src/core.c @@ -1568,8 +1568,7 @@ int lcoreGetKeyScancode( lua_State *L ) { } int key = lua_tointeger( L, 1 ); - int scancode = glfwGetKeyScancode( key ); - lua_pushinteger( L, scancode ); + lua_pushinteger( L, glfwGetKeyScancode( key ) ); return 1; } diff --git a/src/lua_core.c b/src/lua_core.c index 09684c7..0fa02da 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1475,6 +1475,14 @@ void luaRegister() { assingGlobalFunction( "IsLightEnabled", llightsIsLightEnabled ); /* RLGL */ + /* Textures state */ + assingGlobalFunction( "rlActiveTextureSlot", lrlglActiveTextureSlot ); + assingGlobalFunction( "rlEnableTexture", lrlglEnableTexture ); + assingGlobalFunction( "rlDisableTexture", lrlglDisableTexture ); + assingGlobalFunction( "rlEnableTextureCubemap", lrlglEnableTextureCubemap ); + assingGlobalFunction( "rlDisableTextureCubemap", lrlglDisableTextureCubemap ); + assingGlobalFunction( "rlTextureParameters", lrlglTextureParameters ); + assingGlobalFunction( "rlCubemapParameters", lrlglCubemapParameters ); /* Framebuffer state. */ assingGlobalFunction( "rlEnableFramebuffer", lrlglEnableFramebuffer ); assingGlobalFunction( "rlDisableFramebuffer", lrlglDisableFramebuffer ); diff --git a/src/rlgl.c b/src/rlgl.c index f4774a8..582e771 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -3,6 +3,140 @@ #include "lua_core.h" #include "lrlgl.h" +/* +## RLGL - Textures state +*/ + +/* +> success = RL.rlActiveTextureSlot( int slot ) + +Select and active a texture slot + +- Failure return false +- Success return true +*/ +int lrlglActiveTextureSlot( lua_State *L ) { + if ( !lua_isnumber( L, 1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlActiveTextureSlot( int slot )" ); + lua_pushboolean( L, false ); + return 1; + } + rlActiveTextureSlot( lua_tointeger( L, 1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + +/* +> success = RL.rlEnableTexture( int id ) + +Enable texture + +- Failure return false +- Success return true +*/ +int lrlglEnableTexture( lua_State *L ) { + if ( !lua_isnumber( L, 1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlEnableTexture( int id )" ); + lua_pushboolean( L, false ); + return 1; + } + rlEnableTexture( lua_tointeger( L, 1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + +/* +> RL.rlDisableTexture() + +Disable texture +*/ +int lrlglDisableTexture( lua_State *L ) { + rlDisableTexture(); + + return 0; +} + +/* +> success = RL.rlEnableTextureCubemap( int id ) + +Enable texture cubemap + +- Failure return false +- Success return true +*/ +int lrlglEnableTextureCubemap( lua_State *L ) { + if ( !lua_isnumber( L, 1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlEnableTextureCubemap( int id )" ); + lua_pushboolean( L, false ); + return 1; + } + rlEnableTextureCubemap( lua_tointeger( L, 1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + +/* +> RL.rlDisableTextureCubemap() + +Disable texture cubemap +*/ +int lrlglDisableTextureCubemap( lua_State *L ) { + rlDisableTextureCubemap(); + + return 0; +} + +/* +> success = RL.rlTextureParameters( int id, int param, int value ) + +Set texture parameters ( filter, wrap ) + +- Failure return false +- Success return true +*/ +int lrlglTextureParameters( lua_State *L ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlTextureParameters( int id, int param, int value )" ); + lua_pushboolean( L, false ); + return 1; + } + unsigned int id = lua_tointeger( L, 1 ); + int param = lua_tointeger( L, 2 ); + int value = lua_tointeger( L, 3 ); + + rlTextureParameters( id, param, value ); + lua_pushboolean( L, true ); + + return 1; +} + +/* +> success = RL.rlCubemapParameters( int id, int param, int value ) + +Set cubemap parameters ( filter, wrap ) + +- Failure return false +- Success return true +*/ +int lrlglCubemapParameters( lua_State *L ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlCubemapParameters( int id, int param, int value )" ); + lua_pushboolean( L, false ); + return 1; + } + unsigned int id = lua_tointeger( L, 1 ); + int param = lua_tointeger( L, 2 ); + int value = lua_tointeger( L, 3 ); + + rlCubemapParameters( id, param, value ); + lua_pushboolean( L, true ); + + return 1; +} + /* ## RLGL - Framebuffer state */ -- cgit v1.2.3