diff options
| author | degasus <wickmarkus@web.de> | 2014-01-24 14:46:05 +0100 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2014-01-31 07:19:25 +0100 |
| commit | 210f4f3e559696afea64244c29994aed9685d483 (patch) | |
| tree | bc442e96a2197c1d4711ec71af9d52b0bffd83a3 /Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp | |
| parent | 02d1d8e6a04f0536b6dff014e1223605f8b661ac (diff) | |
PortableVertexFormat: add a struct which hold all needed information for every vertex and use this for position
atm, position attribute is hardcoded both in VertexLoader and in backends.
v2: fix coding style + cleanup lookup table
Diffstat (limited to 'Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp b/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp index b23836ac90..49098b24b4 100644 --- a/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp +++ b/Source/Core/VideoBackends/OGL/NativeVertexFormat.cpp @@ -42,6 +42,18 @@ inline GLuint VarToGL(VarType t) return lookup[t]; } +static void SetPointer(u32 attrib, u32 stride, const AttributeFormat &format) +{ + if (!format.enable) + return; + + glEnableVertexAttribArray(attrib); + if (format.integer) + glVertexAttribIPointer(attrib, format.components, VarToGL(format.type), stride, (u8*)NULL + format.offset); + else + glVertexAttribPointer(attrib, format.components, VarToGL(format.type), true, stride, (u8*)NULL + format.offset); +} + void GLVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) { this->vtx_decl = _vtx_decl; @@ -60,8 +72,7 @@ void GLVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vm->m_index_buffers); glBindBuffer(GL_ARRAY_BUFFER, vm->m_vertex_buffers); - glEnableVertexAttribArray(SHADER_POSITION_ATTRIB); - glVertexAttribPointer(SHADER_POSITION_ATTRIB, 3, GL_FLOAT, GL_FALSE, vtx_decl.stride, (u8*)NULL); + SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, vtx_decl.position); for (int i = 0; i < 3; i++) { if (vtx_decl.num_normals > i) { |
