diff --git a/src/library/gl.c b/src/library/gl.c index e65cd6f..95ae6c9 100644 --- a/src/library/gl.c +++ b/src/library/gl.c @@ -1537,6 +1537,7 @@ void _bolt_gl_onDrawElements(GLenum mode, GLsizei count, GLenum type, const void } int32_t xy0[2]; int32_t xy2[2]; + float abgr[4]; _bolt_get_attr_binding_int(c, vertex_userdata.position, indices[i], 2, xy0); _bolt_get_attr_binding_int(c, vertex_userdata.position, indices[i + 2], 2, xy2); struct RenderItemIconEvent event; @@ -1545,6 +1546,10 @@ void _bolt_gl_onDrawElements(GLenum mode, GLsizei count, GLenum type, const void event.target_y = (int16_t)((int32_t)batch.screen_height - xy2[1]); event.target_w = (uint16_t)(xy0[0] - xy2[0]); event.target_h = (uint16_t)(xy2[1] - xy0[1]); + _bolt_get_attr_binding(c, vertex_userdata.colour, indices[i], 4, abgr); + for (size_t i = 0; i < 4; i += 1) { + event.rgba[i] = abgr[3 - i]; + } _bolt_plugin_handle_rendericon(&event); batch_start = i + batch.vertices_per_icon; } diff --git a/src/library/plugin/plugin.h b/src/library/plugin/plugin.h index 1a87f4d..d45f175 100644 --- a/src/library/plugin/plugin.h +++ b/src/library/plugin/plugin.h @@ -302,6 +302,7 @@ struct RenderItemIconEvent { uint16_t target_y; uint16_t target_w; uint16_t target_h; + float rgba[4]; }; struct MinimapTerrainEvent { diff --git a/src/library/plugin/plugin_api.c b/src/library/plugin/plugin_api.c index 63674df..1b0ab84 100644 --- a/src/library/plugin/plugin_api.c +++ b/src/library/plugin/plugin_api.c @@ -1248,7 +1248,7 @@ static int api_rendericon_modelvertexpoint(lua_State* state) { } static int api_rendericon_modelvertexcolour(lua_State* state) { - const struct RenderItemIconEvent* event = require_self_userdata(state, "modelvertexpoint"); + const struct RenderItemIconEvent* event = require_self_userdata(state, "modelvertexcolour"); const size_t model = luaL_checkinteger(state, 2); const size_t vertex = luaL_checkinteger(state, 3); for (size_t i = 0; i < 4; i += 1) { @@ -1257,6 +1257,14 @@ static int api_rendericon_modelvertexcolour(lua_State* state) { return 4; } +static int api_rendericon_colour(lua_State* state) { + const struct RenderItemIconEvent* event = require_self_userdata(state, "colour"); + for (size_t i = 0; i < 4; i += 1) { + lua_pushnumber(state, event->rgba[i]); + } + return 4; +} + static int api_rendericon_modelviewmatrix(lua_State* state) { const struct RenderItemIconEvent* event = require_self_userdata(state, "modelviewmatrix"); const size_t model = luaL_checkinteger(state, 2); @@ -1648,6 +1656,8 @@ static struct ApiFuncTemplate rendericon_functions[] = { BOLTFUNC(modelprojectionmatrix, rendericon), BOLTFUNC(modelviewprojmatrix, rendericon), BOLTALIAS(modelvertexcolour, modelvertexcolor, rendericon), + BOLTFUNC(colour, rendericon), + BOLTALIAS(colour, color, rendericon), }; static struct ApiFuncTemplate minimapterrain_functions[] = {