diff --git a/src/modules/graphics/wrap_Mesh.cpp b/src/modules/graphics/wrap_Mesh.cpp index 38df1d58d..e36e7a453 100644 --- a/src/modules/graphics/wrap_Mesh.cpp +++ b/src/modules/graphics/wrap_Mesh.cpp @@ -250,21 +250,28 @@ int w_Mesh_getVertexFormat(lua_State *L) for (size_t i = 0; i < vertexformat.size(); i++) { - const auto &decl = vertexformat[i].decl; + const auto &member = vertexformat[i]; - if (!getConstant(decl.format, tname)) - return luax_enumerror(L, "vertex attribute data type", getConstants(decl.format), tname); + if (!getConstant(member.decl.format, tname)) + return luax_enumerror(L, "vertex attribute data type", getConstants(member.decl.format), tname); - lua_createtable(L, 3, 0); + lua_createtable(L, 0, 4); - lua_pushstring(L, decl.name.c_str()); - lua_rawseti(L, -2, 1); + lua_pushstring(L, member.decl.name.c_str()); + lua_setfield(L, -2, "name"); - lua_pushstring(L, tname); - lua_rawseti(L, -2, 2); + const char *formatstr = "unknown"; + getConstant(member.decl.format, formatstr); + lua_pushstring(L, formatstr); + lua_setfield(L, -2, "format"); - // format[i] = {name, type} - lua_rawseti(L, -2, (int) i + 1); + lua_pushinteger(L, member.decl.arrayLength); + lua_setfield(L, -2, "arraylength"); + + lua_pushinteger(L, member.offset); + lua_setfield(L, -2, "offset"); + + lua_rawseti(L, -2, i + 1); } return 1; diff --git a/testing/tests/graphics.lua b/testing/tests/graphics.lua index af93042a8..82a98d301 100644 --- a/testing/tests/graphics.lua +++ b/testing/tests/graphics.lua @@ -468,8 +468,8 @@ love.test.graphics.Mesh = function(test) -- check def vertex format local format = mesh1:getVertexFormat() - test:assertEquals('floatvec2', format[2][2], 'check def vertex format 2') - test:assertEquals('VertexColor', format[3][1], 'check def vertex format 3') + test:assertEquals('floatvec2', format[2].format, 'check def vertex format 2') + test:assertEquals('VertexColor', format[3].name, 'check def vertex format 3') -- check vertext attributes test:assertTrue(mesh1:isAttributeEnabled('VertexPosition'), 'check def attribute VertexPosition')