Mesh:getVertexFormat uses named fields, to match the new format syntax in newMesh.

This commit is contained in:
Sasha Szpakowski
2024-04-08 12:20:07 -03:00
parent 8140817107
commit 994079e76d
2 changed files with 19 additions and 12 deletions
+17 -10
View File
@@ -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;
+2 -2
View File
@@ -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')