diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 33af53f76..324ce7892 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -11006,6 +11006,13 @@ function gfx_shader_set_int(loc, value) -- ... end +--- @param loc integer +--- @param value boolean +--- Sets the value of a shader uniform of type bool. +function gfx_shader_set_bool(loc, value) + -- ... +end + --- @param loc integer --- @param value number --- Sets the value of a shader uniform of type float. diff --git a/docs/lua/functions-7.md b/docs/lua/functions-7.md index dd24bd958..1e9fdda2b 100644 --- a/docs/lua/functions-7.md +++ b/docs/lua/functions-7.md @@ -961,6 +961,30 @@ Sets the value of a shader uniform of type int.
+## [gfx_shader_set_bool](#gfx_shader_set_bool) + +### Description +Sets the value of a shader uniform of type bool. + +### Lua Example +`gfx_shader_set_bool(loc, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| loc | `integer` | +| value | `boolean` | + +### Returns +- None + +### C Prototype +`void gfx_shader_set_bool(int loc, bool value);` + +[:arrow_up_small:](#) + +
+ ## [gfx_shader_set_float](#gfx_shader_set_float) ### Description diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 411effb19..ddb8a59c7 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1967,6 +1967,7 @@ - [gfx_use_program](functions-7.md#gfx_use_program) - [gfx_shader_get_uniform_location](functions-7.md#gfx_shader_get_uniform_location) - [gfx_shader_set_int](functions-7.md#gfx_shader_set_int) + - [gfx_shader_set_bool](functions-7.md#gfx_shader_set_bool) - [gfx_shader_set_float](functions-7.md#gfx_shader_set_float) - [gfx_shader_set_vec2](functions-7.md#gfx_shader_set_vec2) - [gfx_shader_set_vec3](functions-7.md#gfx_shader_set_vec3) diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 2c59b5915..4a0d78596 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -32651,6 +32651,25 @@ int smlua_func_gfx_shader_set_int(lua_State* L) { return 1; } +int smlua_func_gfx_shader_set_bool(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "gfx_shader_set_bool", 2, top); + return 0; + } + + int loc = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "gfx_shader_set_bool"); return 0; } + bool value = smlua_to_boolean(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "gfx_shader_set_bool"); return 0; } + + gfx_shader_set_bool(loc, value); + + return 1; +} + int smlua_func_gfx_shader_set_float(lua_State* L) { if (L == NULL) { return 0; } @@ -38835,6 +38854,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "gfx_use_program", smlua_func_gfx_use_program); smlua_bind_function(L, "gfx_shader_get_uniform_location", smlua_func_gfx_shader_get_uniform_location); smlua_bind_function(L, "gfx_shader_set_int", smlua_func_gfx_shader_set_int); + smlua_bind_function(L, "gfx_shader_set_bool", smlua_func_gfx_shader_set_bool); smlua_bind_function(L, "gfx_shader_set_float", smlua_func_gfx_shader_set_float); smlua_bind_function(L, "gfx_shader_set_vec2", smlua_func_gfx_shader_set_vec2); smlua_bind_function(L, "gfx_shader_set_vec3", smlua_func_gfx_shader_set_vec3); diff --git a/src/pc/lua/utils/smlua_gfx_utils.c b/src/pc/lua/utils/smlua_gfx_utils.c index b93e2ce1e..556c4bf8b 100644 --- a/src/pc/lua/utils/smlua_gfx_utils.c +++ b/src/pc/lua/utils/smlua_gfx_utils.c @@ -415,6 +415,12 @@ void gfx_shader_set_int(int loc, int value) { } } +void gfx_shader_set_bool(int loc, bool value) { + if (loc != -1) { + glUniform1i(loc, (int)value); + } +} + void gfx_shader_set_float(int loc, float value) { if (loc != -1) { glUniform1f(loc, value); diff --git a/src/pc/lua/utils/smlua_gfx_utils.h b/src/pc/lua/utils/smlua_gfx_utils.h index 4c62c40ea..50d6665aa 100644 --- a/src/pc/lua/utils/smlua_gfx_utils.h +++ b/src/pc/lua/utils/smlua_gfx_utils.h @@ -104,6 +104,8 @@ void gfx_use_program(u32 program); int gfx_shader_get_uniform_location(u32 program, const char* name); /* |description|Sets the value of a shader uniform of type int.|descriptionEnd| */ void gfx_shader_set_int(int loc, int value); +/* |description|Sets the value of a shader uniform of type bool.|descriptionEnd| */ +void gfx_shader_set_bool(int loc, bool value); /* |description|Sets the value of a shader uniform of type float.|descriptionEnd| */ void gfx_shader_set_float(int loc, float value); /* |description|Sets the value of a shader uniform of type vec2.|descriptionEnd| */