Merge pull request #701 from ManIsCat2/luatextureimage
Some checks are pending
Build coop / build-ubuntu (push) Waiting to run
Build coop / build-windows (push) Waiting to run
Build coop / build-macos-arm (push) Waiting to run
Build coop / build-macos-intel (push) Waiting to run

Add gfx_set_texture_image for lua
This commit is contained in:
Isaac0-dev 2025-03-11 20:41:28 +10:00 committed by GitHub
commit 689bc5755f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 74 additions and 3 deletions

View file

@ -9245,11 +9245,21 @@ end
--- @param Ab1 integer
--- @param Ac1 integer
--- @param Ad1 integer
--- Sets the display list combine mode.
--- Sets the display list combine mode. you can fill this function with G_CCMUX_* and G_ACMUX_* constants
function gfx_set_combine_lerp(gfx, a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1)
-- ...
end
--- @param gfx Pointer_Gfx
--- @param format integer
--- @param size integer
--- @param width integer
--- @param texture Pointer_integer
--- Sets the display list texture image. Pass in textureInfo.texture as `texture`
function gfx_set_texture_image(gfx, format, size, width, texture)
-- ...
end
--- @param index integer
--- @param value integer
--- Sets a value of the global fog color

View file

@ -7890,7 +7890,7 @@ Traverses a display list. Takes a Lua function as a parameter, which is called b
## [gfx_set_combine_lerp](#gfx_set_combine_lerp)
### Description
Sets the display list combine mode.
Sets the display list combine mode. you can fill this function with G_CCMUX_* and G_ACMUX_* constants
### Lua Example
`gfx_set_combine_lerp(gfx, a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1)`
@ -7926,6 +7926,33 @@ Sets the display list combine mode.
<br />
## [gfx_set_texture_image](#gfx_set_texture_image)
### Description
Sets the display list texture image. Pass in textureInfo.texture as `texture`
### Lua Example
`gfx_set_texture_image(gfx, format, size, width, texture)`
### Parameters
| Field | Type |
| ----- | ---- |
| gfx | `Pointer` <`Gfx`> |
| format | `integer` |
| size | `integer` |
| width | `integer` |
| texture | `Pointer` <`integer`> |
### Returns
- None
### C Prototype
`void gfx_set_texture_image(Gfx* gfx, u32 format, u32 size, u32 width, u8* texture);`
[:arrow_up_small:](#)
<br />
## [set_fog_color](#set_fog_color)
### Description

View file

@ -1710,6 +1710,7 @@
- [gfx_get_vtx](functions-5.md#gfx_get_vtx)
- [gfx_parse](functions-5.md#gfx_parse)
- [gfx_set_combine_lerp](functions-5.md#gfx_set_combine_lerp)
- [gfx_set_texture_image](functions-5.md#gfx_set_texture_image)
- [set_fog_color](functions-5.md#set_fog_color)
- [set_fog_intensity](functions-5.md#set_fog_intensity)
- [set_lighting_color](functions-5.md#set_lighting_color)

View file

@ -28438,6 +28438,31 @@ int smlua_func_gfx_set_combine_lerp(lua_State* L) {
return 1;
}
int smlua_func_gfx_set_texture_image(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 5) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "gfx_set_texture_image", 5, top);
return 0;
}
Gfx* gfx = (Gfx*)smlua_to_cobject(L, 1, LOT_GFX);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "gfx_set_texture_image"); return 0; }
u32 format = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "gfx_set_texture_image"); return 0; }
u32 size = smlua_to_integer(L, 3);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "gfx_set_texture_image"); return 0; }
u32 width = smlua_to_integer(L, 4);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "gfx_set_texture_image"); return 0; }
u8* texture = (u8*)smlua_to_cpointer(L, 5, LVT_U8_P);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "gfx_set_texture_image"); return 0; }
gfx_set_texture_image(gfx, format, size, width, texture);
return 1;
}
int smlua_func_set_fog_color(lua_State* L) {
if (L == NULL) { return 0; }
@ -33745,6 +33770,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "gfx_get_vtx", smlua_func_gfx_get_vtx);
smlua_bind_function(L, "gfx_parse", smlua_func_gfx_parse);
smlua_bind_function(L, "gfx_set_combine_lerp", smlua_func_gfx_set_combine_lerp);
smlua_bind_function(L, "gfx_set_texture_image", smlua_func_gfx_set_texture_image);
smlua_bind_function(L, "set_fog_color", smlua_func_set_fog_color);
smlua_bind_function(L, "set_fog_intensity", smlua_func_set_fog_intensity);
smlua_bind_function(L, "set_lighting_color", smlua_func_set_lighting_color);

View file

@ -170,3 +170,8 @@ void gfx_set_combine_lerp(Gfx* gfx, u32 a0, u32 b0, u32 c0, u32 d0, u32 Aa0, u32
if (!gfx) { return; }
gDPSetCombineLERPNoString(gfx, a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1);
}
void gfx_set_texture_image(Gfx* gfx, u32 format, u32 size, u32 width, u8* texture) {
if (!gfx) { return; }
gDPSetTextureImage(gfx, format, size, width, texture);
}

View file

@ -52,7 +52,9 @@ void set_skybox_color(u8 index, u8 value);
void gfx_parse(Gfx* cmd, LuaFunction func);
/* |description|Gets a vertex from a display list command if it has the correct op. Intended to be used with `gfx_parse`.|descriptionEnd| */
Vtx *gfx_get_vtx(Gfx* gfx, u16 offset);
/* |description|Sets the display list combine mode.|descriptionEnd| */
/* |description|Sets the display list combine mode. you can fill this function with G_CCMUX_* and G_ACMUX_* constants|descriptionEnd| */
void gfx_set_combine_lerp(Gfx* gfx, u32 a0, u32 b0, u32 c0, u32 d0, u32 Aa0, u32 Ab0, u32 Ac0, u32 Ad0, u32 a1, u32 b1, u32 c1, u32 d1, u32 Aa1, u32 Ab1, u32 Ac1, u32 Ad1);
/* |description|Sets the display list texture image. Pass in textureInfo.texture as `texture`|descriptionEnd| */
void gfx_set_texture_image(Gfx* gfx, u32 format, u32 size, u32 width, u8* texture);
#endif