PortableVertexFormat: use AttributeFormat for normal attribute format
This commit is contained in:
parent
210f4f3e55
commit
b38ef39ab7
|
@ -74,12 +74,13 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if (_vtx_decl.normal_offset[i] > 0)
|
format = &_vtx_decl.normals[i];
|
||||||
|
if (format->enable)
|
||||||
{
|
{
|
||||||
m_elems[m_num_elems].SemanticName = "NORMAL";
|
m_elems[m_num_elems].SemanticName = "NORMAL";
|
||||||
m_elems[m_num_elems].SemanticIndex = i;
|
m_elems[m_num_elems].SemanticIndex = i;
|
||||||
m_elems[m_num_elems].AlignedByteOffset = _vtx_decl.normal_offset[i];
|
m_elems[m_num_elems].AlignedByteOffset = format->offset;
|
||||||
m_elems[m_num_elems].Format = VarToD3D(_vtx_decl.normal_gl_type, _vtx_decl.normal_gl_size, false);
|
m_elems[m_num_elems].Format = VarToD3D(format->type, format->components, format->integer);
|
||||||
m_elems[m_num_elems].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
m_elems[m_num_elems].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||||
++m_num_elems;
|
++m_num_elems;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,10 +75,7 @@ void GLVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
|
||||||
SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, vtx_decl.position);
|
SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, vtx_decl.position);
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (vtx_decl.num_normals > i) {
|
SetPointer(SHADER_NORM0_ATTRIB+i, vertex_stride, vtx_decl.normals[i]);
|
||||||
glEnableVertexAttribArray(SHADER_NORM0_ATTRIB+i);
|
|
||||||
glVertexAttribPointer(SHADER_NORM0_ATTRIB+i, vtx_decl.normal_gl_size, VarToGL(vtx_decl.normal_gl_type), GL_TRUE, vtx_decl.stride, (u8*)NULL + vtx_decl.normal_offset[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
|
|
|
@ -86,11 +86,8 @@ struct PortableVertexDeclaration
|
||||||
int stride;
|
int stride;
|
||||||
|
|
||||||
AttributeFormat position;
|
AttributeFormat position;
|
||||||
|
AttributeFormat normals[3];
|
||||||
|
|
||||||
int num_normals;
|
|
||||||
int normal_offset[3];
|
|
||||||
VarType normal_gl_type;
|
|
||||||
int normal_gl_size;
|
|
||||||
VarType color_gl_type; // always GL_UNSIGNED_BYTE
|
VarType color_gl_type; // always GL_UNSIGNED_BYTE
|
||||||
int color_offset[2];
|
int color_offset[2];
|
||||||
VarType texcoord_gl_type[8];
|
VarType texcoord_gl_type[8];
|
||||||
|
|
|
@ -594,7 +594,6 @@ void VertexLoader::CompileVertexTranslator()
|
||||||
vtx_decl.position.integer = false;
|
vtx_decl.position.integer = false;
|
||||||
|
|
||||||
// Normals
|
// Normals
|
||||||
vtx_decl.num_normals = 0;
|
|
||||||
if (m_VtxDesc.Normal != NOT_PRESENT)
|
if (m_VtxDesc.Normal != NOT_PRESENT)
|
||||||
{
|
{
|
||||||
m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal,
|
m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal,
|
||||||
|
@ -611,20 +610,13 @@ void VertexLoader::CompileVertexTranslator()
|
||||||
}
|
}
|
||||||
WriteCall(pFunc);
|
WriteCall(pFunc);
|
||||||
|
|
||||||
vtx_decl.num_normals = vtx_attr.NormalElements ? 3 : 1;
|
for (int i = 0; i < (vtx_attr.NormalElements ? 3 : 1); i++)
|
||||||
vtx_decl.normal_offset[0] = -1;
|
|
||||||
vtx_decl.normal_offset[1] = -1;
|
|
||||||
vtx_decl.normal_offset[2] = -1;
|
|
||||||
vtx_decl.normal_gl_type = VAR_FLOAT;
|
|
||||||
vtx_decl.normal_gl_size = 3;
|
|
||||||
vtx_decl.normal_offset[0] = nat_offset;
|
|
||||||
nat_offset += 12;
|
|
||||||
|
|
||||||
if (vtx_attr.NormalElements)
|
|
||||||
{
|
{
|
||||||
vtx_decl.normal_offset[1] = nat_offset;
|
vtx_decl.normals[i].components = 3;
|
||||||
nat_offset += 12;
|
vtx_decl.normals[i].enable = true;
|
||||||
vtx_decl.normal_offset[2] = nat_offset;
|
vtx_decl.normals[i].offset = nat_offset;
|
||||||
|
vtx_decl.normals[i].type = VAR_FLOAT;
|
||||||
|
vtx_decl.normals[i].integer = false;
|
||||||
nat_offset += 12;
|
nat_offset += 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue