From fb92c338af83a56edaabaea13168696e3cf1c7c7 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 27 Oct 2012 22:50:06 -0500 Subject: Bit of cleanup and fixing of one issue that was noticeable in SMS with Mario's shadow. --- Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp index ae20649433..0cbf878799 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp @@ -274,10 +274,6 @@ void GLVertexFormat::EnableComponents(u32 components) if ((components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i))) { glClientActiveTexture(GL_TEXTURE0 + i); - if (components & (VB_HAS_UV0 << i)) - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - else - glDisableClientState(GL_TEXTURE_COORD_ARRAY); } } -- cgit v1.2.3 From 6864b40e26354f6b366e8fe8c2ff4f6680f09189 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 7 Dec 2012 21:09:48 +0100 Subject: reset glEnableClientState befor every draw should be done with VAO, but atm, this is not possible :-( this also partial revert the fix in fb92c338af83 (activating texture0 globally). Signed-off-by: Ryan Houdek --- .../Plugin_VideoOGL/Src/NativeVertexFormat.cpp | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp index 0cbf878799..14035c0634 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 @@ -219,34 +219,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 +257,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,12 +269,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 (m_components & (VB_HAS_UV0 << i)) + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + else + glDisableClientState(GL_TEXTURE_COORD_ARRAY); } } - s_prevcomponents = components; + s_prevcomponents = m_components; } } -- cgit v1.2.3 From c207422987a3f39032ee348fed4bde1b67a21fcc Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 9 Dec 2012 22:49:58 +0100 Subject: using of vao, warning: ARB_vertex_array_object is needed Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp index 14035c0634..724212d208 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp @@ -187,6 +187,10 @@ void GLVertexFormat::SetupVertexPointers() { #ifdef USE_JIT ((void (*)())(void*)m_compiledCode)(); #else + // TODO: use this :-) + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); + 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])); -- cgit v1.2.3 From 79a7ce4827de774bc0d454ad2e679f99e1da96fe Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 13 Dec 2012 15:48:42 +0100 Subject: move glBindBuffer and glBindVertexArray out of VertexManager Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp index 724212d208..a435be0dca 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/NativeVertexFormat.cpp @@ -187,9 +187,6 @@ void GLVertexFormat::SetupVertexPointers() { #ifdef USE_JIT ((void (*)())(void*)m_compiledCode)(); #else - // TODO: use this :-) - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); glVertexPointer(3, GL_FLOAT, vtx_decl.stride, VertexManager::s_pBaseBufferPointer); if (vtx_decl.num_normals >= 1) { @@ -224,13 +221,13 @@ void GLVertexFormat::SetupVertexPointers() { } #endif -// if (s_prevcomponents != m_components) + if (s_prevcomponents != m_components) { // vertices glEnableClientState(GL_VERTEX_ARRAY); // matrices -// if ((m_components & VB_HAS_POSMTXIDX) != (s_prevcomponents & VB_HAS_POSMTXIDX)) + if ((m_components & VB_HAS_POSMTXIDX) != (s_prevcomponents & VB_HAS_POSMTXIDX)) { if (m_components & VB_HAS_POSMTXIDX) glEnableVertexAttribArray(SHADER_POSMTX_ATTRIB); @@ -239,14 +236,14 @@ void GLVertexFormat::SetupVertexPointers() { } // normals -// if ((m_components & VB_HAS_NRM0) != (s_prevcomponents & VB_HAS_NRM0)) + if ((m_components & VB_HAS_NRM0) != (s_prevcomponents & VB_HAS_NRM0)) { if (m_components & VB_HAS_NRM0) glEnableClientState(GL_NORMAL_ARRAY); else glDisableClientState(GL_NORMAL_ARRAY); } -// if ((m_components & VB_HAS_NRM1) != (s_prevcomponents & VB_HAS_NRM1)) + if ((m_components & VB_HAS_NRM1) != (s_prevcomponents & VB_HAS_NRM1)) { if (m_components & VB_HAS_NRM1) { glEnableVertexAttribArray(SHADER_NORM1_ATTRIB); @@ -261,7 +258,7 @@ void GLVertexFormat::SetupVertexPointers() { // color for (int i = 0; i < 2; ++i) { -// if ((m_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 (m_components & (VB_HAS_COL0 << i)) glEnableClientState(i ? GL_SECONDARY_COLOR_ARRAY : GL_COLOR_ARRAY); @@ -273,7 +270,7 @@ void GLVertexFormat::SetupVertexPointers() { // tex for (int i = 0; i < 8; ++i) { -// if ((m_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 (m_components & (VB_HAS_UV0 << i)) -- cgit v1.2.3