diff options
| author | degasus <wickmarkus@web.de> | 2014-01-24 15:16:52 +0100 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2014-01-31 07:19:34 +0100 |
| commit | b38ef39ab7b88eb7e4fa253deec64cecb72508aa (patch) | |
| tree | 33021b490fcaf4732eadb4b74101357e816f0f08 /Source | |
| parent | 210f4f3e559696afea64244c29994aed9685d483 (diff) | |
PortableVertexFormat: use AttributeFormat for normal attribute format
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp | 7 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp | 5 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/NativeVertexFormat.h | 5 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoader.cpp | 20 |
4 files changed, 12 insertions, 25 deletions
diff --git a/Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp b/Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp index 244df9bb5b..70dfe23df0 100644 --- a/Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp +++ b/Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp @@ -74,12 +74,13 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) 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].SemanticIndex = i; - m_elems[m_num_elems].AlignedByteOffset = _vtx_decl.normal_offset[i]; - m_elems[m_num_elems].Format = VarToD3D(_vtx_decl.normal_gl_type, _vtx_decl.normal_gl_size, false); + m_elems[m_num_elems].AlignedByteOffset = format->offset; + 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_num_elems; } diff --git a/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp b/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp index 49098b24b4..88147aa755 100644 --- a/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp +++ b/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp @@ -75,10 +75,7 @@ void GLVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, vtx_decl.position); for (int i = 0; i < 3; i++) { - if (vtx_decl.num_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]); - } + SetPointer(SHADER_NORM0_ATTRIB+i, vertex_stride, vtx_decl.normals[i]); } for (int i = 0; i < 2; i++) { diff --git a/Source/Core/VideoCommon/NativeVertexFormat.h b/Source/Core/VideoCommon/NativeVertexFormat.h index 127d8f7b8e..9e389a2d64 100644 --- a/Source/Core/VideoCommon/NativeVertexFormat.h +++ b/Source/Core/VideoCommon/NativeVertexFormat.h @@ -86,11 +86,8 @@ struct PortableVertexDeclaration int stride; 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 int color_offset[2]; VarType texcoord_gl_type[8]; diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index 968e98676a..42fa6a7b0c 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -594,7 +594,6 @@ void VertexLoader::CompileVertexTranslator() vtx_decl.position.integer = false; // Normals - vtx_decl.num_normals = 0; if (m_VtxDesc.Normal != NOT_PRESENT) { m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal, @@ -611,20 +610,13 @@ void VertexLoader::CompileVertexTranslator() } WriteCall(pFunc); - vtx_decl.num_normals = vtx_attr.NormalElements ? 3 : 1; - 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) + for (int i = 0; i < (vtx_attr.NormalElements ? 3 : 1); i++) { - vtx_decl.normal_offset[1] = nat_offset; - nat_offset += 12; - vtx_decl.normal_offset[2] = nat_offset; + vtx_decl.normals[i].components = 3; + vtx_decl.normals[i].enable = true; + vtx_decl.normals[i].offset = nat_offset; + vtx_decl.normals[i].type = VAR_FLOAT; + vtx_decl.normals[i].integer = false; nat_offset += 12; } |
