Fix build errors related to formatting non-scoped enums

This commit is contained in:
Pokechu22
2022-10-11 14:23:38 -07:00
parent b051903c3d
commit cc5640245c
31 changed files with 234 additions and 182 deletions

View File

@ -32,18 +32,18 @@ static inline GLuint VarToGL(ComponentFormat t)
return lookup[t];
}
static void SetPointer(u32 attrib, u32 stride, const AttributeFormat& format)
static void SetPointer(ShaderAttrib attrib, u32 stride, const AttributeFormat& format)
{
if (!format.enable)
return;
glEnableVertexAttribArray(attrib);
glEnableVertexAttribArray(static_cast<GLuint>(attrib));
if (format.integer)
glVertexAttribIPointer(attrib, format.components, VarToGL(format.type), stride,
(u8*)nullptr + format.offset);
glVertexAttribIPointer(static_cast<GLuint>(attrib), format.components, VarToGL(format.type),
stride, (u8*)nullptr + format.offset);
else
glVertexAttribPointer(attrib, format.components, VarToGL(format.type), true, stride,
(u8*)nullptr + format.offset);
glVertexAttribPointer(static_cast<GLuint>(attrib), format.components, VarToGL(format.type),
true, stride, (u8*)nullptr + format.offset);
}
GLVertexFormat::GLVertexFormat(const PortableVertexDeclaration& vtx_decl)
@ -65,18 +65,18 @@ GLVertexFormat::GLVertexFormat(const PortableVertexDeclaration& vtx_decl)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vm->GetIndexBufferHandle());
glBindBuffer(GL_ARRAY_BUFFER, vm->GetVertexBufferHandle());
SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, vtx_decl.position);
SetPointer(ShaderAttrib::Position, vertex_stride, vtx_decl.position);
for (int i = 0; i < 3; i++)
SetPointer(SHADER_NORMAL_ATTRIB + i, vertex_stride, vtx_decl.normals[i]);
for (u32 i = 0; i < 3; i++)
SetPointer(ShaderAttrib::Normal + i, vertex_stride, vtx_decl.normals[i]);
for (int i = 0; i < 2; i++)
SetPointer(SHADER_COLOR0_ATTRIB + i, vertex_stride, vtx_decl.colors[i]);
for (u32 i = 0; i < 2; i++)
SetPointer(ShaderAttrib::Color0 + i, vertex_stride, vtx_decl.colors[i]);
for (int i = 0; i < 8; i++)
SetPointer(SHADER_TEXTURE0_ATTRIB + i, vertex_stride, vtx_decl.texcoords[i]);
for (u32 i = 0; i < 8; i++)
SetPointer(ShaderAttrib::TexCoord0 + i, vertex_stride, vtx_decl.texcoords[i]);
SetPointer(SHADER_POSMTX_ATTRIB, vertex_stride, vtx_decl.posmtx);
SetPointer(ShaderAttrib::PositionMatrix, vertex_stride, vtx_decl.posmtx);
}
GLVertexFormat::~GLVertexFormat()

View File

@ -133,23 +133,24 @@ void SHADER::SetProgramBindings(bool is_compute)
glBindFragDataLocationIndexed(glprogid, 0, 1, "ocol1");
}
// Need to set some attribute locations
glBindAttribLocation(glprogid, SHADER_POSITION_ATTRIB, "rawpos");
glBindAttribLocation(glprogid, static_cast<GLuint>(ShaderAttrib::Position), "rawpos");
glBindAttribLocation(glprogid, SHADER_POSMTX_ATTRIB, "posmtx");
glBindAttribLocation(glprogid, static_cast<GLuint>(ShaderAttrib::PositionMatrix), "posmtx");
glBindAttribLocation(glprogid, SHADER_COLOR0_ATTRIB, "rawcolor0");
glBindAttribLocation(glprogid, SHADER_COLOR1_ATTRIB, "rawcolor1");
glBindAttribLocation(glprogid, static_cast<GLuint>(ShaderAttrib::Color0), "rawcolor0");
glBindAttribLocation(glprogid, static_cast<GLuint>(ShaderAttrib::Color1), "rawcolor1");
glBindAttribLocation(glprogid, SHADER_NORMAL_ATTRIB, "rawnormal");
glBindAttribLocation(glprogid, SHADER_TANGENT_ATTRIB, "rawtangent");
glBindAttribLocation(glprogid, SHADER_BINORMAL_ATTRIB, "rawbinormal");
glBindAttribLocation(glprogid, static_cast<GLuint>(ShaderAttrib::Normal), "rawnormal");
glBindAttribLocation(glprogid, static_cast<GLuint>(ShaderAttrib::Tangent), "rawtangent");
glBindAttribLocation(glprogid, static_cast<GLuint>(ShaderAttrib::Binormal), "rawbinormal");
}
for (int i = 0; i < 8; i++)
{
// Per documentation: OpenGL copies the name string when glBindAttribLocation is called, so an
// application may free its copy of the name string immediately after the function returns.
glBindAttribLocation(glprogid, SHADER_TEXTURE0_ATTRIB + i, fmt::format("rawtex{}", i).c_str());
glBindAttribLocation(glprogid, static_cast<GLuint>(ShaderAttrib::TexCoord0 + i),
fmt::format("rawtex{}", i).c_str());
}
}