diff options
| author | degasus <wickmarkus@web.de> | 2012-12-25 12:39:00 +0100 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2012-12-25 12:39:00 +0100 |
| commit | bff0faea2d3afbd3fc9d19f9449f2c31d64a5e3e (patch) | |
| tree | 1b7262148633924c53e066a354c4b2a1a46d459d /Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp | |
| parent | b3714f4874681b463c48f5aa96e3f89274f94aac (diff) | |
| parent | 399a6af66de69ffaf54d779441b57b05aa2b24e0 (diff) | |
Merge branch 'immediate-removal'
Conflicts:
Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
Diffstat (limited to 'Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp')
| -rw-r--r-- | Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp index ae20649433..a435be0dca 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp @@ -27,8 +27,9 @@ #define COMPILED_CODE_SIZE 4096 -// TODO: this guy is never initialized -u32 s_prevcomponents; // previous state set +// TODO: Use this again for performance, but without VAO we never know exactly the last configuration +static u32 s_prevcomponents; // previous state set + /* #ifdef _WIN32 #ifdef _M_IX86 @@ -64,7 +65,6 @@ public: virtual void Initialize(const PortableVertexDeclaration &_vtx_decl); virtual void SetupVertexPointers(); - virtual void EnableComponents(u32 components); }; namespace OGL @@ -187,6 +187,7 @@ void GLVertexFormat::SetupVertexPointers() { #ifdef USE_JIT ((void (*)())(void*)m_compiledCode)(); #else + glVertexPointer(3, GL_FLOAT, vtx_decl.stride, VertexManager::s_pBaseBufferPointer); if (vtx_decl.num_normals >= 1) { glNormalPointer(VarToGL(vtx_decl.normal_gl_type), vtx_decl.stride, (void *)(VertexManager::s_pBaseBufferPointer + vtx_decl.normal_offset[0])); @@ -219,34 +220,32 @@ void GLVertexFormat::SetupVertexPointers() { glVertexAttribPointer(SHADER_POSMTX_ATTRIB, 4, GL_UNSIGNED_BYTE, GL_FALSE, vtx_decl.stride, (void *)(VertexManager::s_pBaseBufferPointer + vtx_decl.posmtx_offset)); } #endif -} -void GLVertexFormat::EnableComponents(u32 components) -{ - if (s_prevcomponents != components) + if (s_prevcomponents != m_components) { - VertexManager::Flush(); + // vertices + glEnableClientState(GL_VERTEX_ARRAY); // matrices - if ((components & VB_HAS_POSMTXIDX) != (s_prevcomponents & VB_HAS_POSMTXIDX)) + if ((m_components & VB_HAS_POSMTXIDX) != (s_prevcomponents & VB_HAS_POSMTXIDX)) { - if (components & VB_HAS_POSMTXIDX) + if (m_components & VB_HAS_POSMTXIDX) glEnableVertexAttribArray(SHADER_POSMTX_ATTRIB); else glDisableVertexAttribArray(SHADER_POSMTX_ATTRIB); } // normals - if ((components & VB_HAS_NRM0) != (s_prevcomponents & VB_HAS_NRM0)) + if ((m_components & VB_HAS_NRM0) != (s_prevcomponents & VB_HAS_NRM0)) { - if (components & VB_HAS_NRM0) + if (m_components & VB_HAS_NRM0) glEnableClientState(GL_NORMAL_ARRAY); else glDisableClientState(GL_NORMAL_ARRAY); } - if ((components & VB_HAS_NRM1) != (s_prevcomponents & VB_HAS_NRM1)) + if ((m_components & VB_HAS_NRM1) != (s_prevcomponents & VB_HAS_NRM1)) { - if (components & VB_HAS_NRM1) { + if (m_components & VB_HAS_NRM1) { glEnableVertexAttribArray(SHADER_NORM1_ATTRIB); glEnableVertexAttribArray(SHADER_NORM2_ATTRIB); } @@ -259,9 +258,9 @@ void GLVertexFormat::EnableComponents(u32 components) // color for (int i = 0; i < 2; ++i) { - if ((components & (VB_HAS_COL0 << i)) != (s_prevcomponents & (VB_HAS_COL0 << i))) + if ((m_components & (VB_HAS_COL0 << i)) != (s_prevcomponents & (VB_HAS_COL0 << i))) { - if (components & (VB_HAS_COL0 << i)) + if (m_components & (VB_HAS_COL0 << i)) glEnableClientState(i ? GL_SECONDARY_COLOR_ARRAY : GL_COLOR_ARRAY); else glDisableClientState(i ? GL_SECONDARY_COLOR_ARRAY : GL_COLOR_ARRAY); @@ -271,16 +270,16 @@ void GLVertexFormat::EnableComponents(u32 components) // tex for (int i = 0; i < 8; ++i) { - if ((components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i))) + if ((m_components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i))) { glClientActiveTexture(GL_TEXTURE0 + i); - if (components & (VB_HAS_UV0 << i)) + if (m_components & (VB_HAS_UV0 << i)) glEnableClientState(GL_TEXTURE_COORD_ARRAY); else glDisableClientState(GL_TEXTURE_COORD_ARRAY); } } - s_prevcomponents = components; + s_prevcomponents = m_components; } } |
