From 8b62be20253a282edc8308cd3ce541be5ecbbb70 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 7 Dec 2012 22:49:18 +0100 Subject: [PATCH] fix ShowEFBCopyRegions those fancy colors were the result of the usage of non-allocated heap Signed-off-by: Ryan Houdek --- Source/Core/VideoCommon/Src/BPFunctions.cpp | 2 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 122 +++++++++++++----- 2 files changed, 90 insertions(+), 34 deletions(-) diff --git a/Source/Core/VideoCommon/Src/BPFunctions.cpp b/Source/Core/VideoCommon/Src/BPFunctions.cpp index cddeae3000..b9a76ba7b6 100644 --- a/Source/Core/VideoCommon/Src/BPFunctions.cpp +++ b/Source/Core/VideoCommon/Src/BPFunctions.cpp @@ -236,7 +236,7 @@ bool GetConfig(const int &type) case CONFIG_DISABLEFOG: return g_ActiveConfig.bDisableFog; case CONFIG_SHOWEFBREGIONS: - return false; + return g_ActiveConfig.bShowEFBCopyRegions; default: PanicAlert("GetConfig Error: Unknown Config Type!"); return false; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 3b7205867d..56991457e1 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -533,13 +533,15 @@ void Renderer::DrawDebugInfo() // Set Line Size glLineWidth(3.0f); - GLfloat *RectPoints = new GLfloat[stats.efb_regions.size() * 16]; - GLfloat *Colours = new GLfloat[stats.efb_regions.size() * 3]; + // 2*Coords + 3*Color + GLfloat *Vertices = new GLfloat[stats.efb_regions.size() * (2+3)*2*6]; // Draw EFB copy regions rectangles int a = 0; + GLfloat color[3] = {0.0f, 1.0f, 1.0f}; + for (std::vector::const_iterator it = stats.efb_regions.begin(); - it != stats.efb_regions.end(); ++it, ++a) + it != stats.efb_regions.end(); ++it) { GLfloat halfWidth = EFB_WIDTH / 2.0f; GLfloat halfHeight = EFB_HEIGHT / 2.0f; @@ -548,33 +550,88 @@ void Renderer::DrawDebugInfo() GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)it->right / halfWidth); GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)it->bottom / halfHeight); - Colours[a * 3] = 0.0f; - Colours[a * 3 + 1] = 1.0f; - Colours[a * 3 + 2] = 1.0f; - - RectPoints[a * 16] = x; - RectPoints[a * 16 + 1] = y; + Vertices[a++] = x; + Vertices[a++] = y; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; - RectPoints[a * 16 + 2] = x2; - RectPoints[a * 16 + 3] = y; + Vertices[a++] = x2; + Vertices[a++] = y; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; - RectPoints[a * 16 + 4] = x; - RectPoints[a * 16 + 5] = y2; - - RectPoints[a * 16 + 6] = x2; - RectPoints[a * 16 + 7] = y2; - - RectPoints[a * 16 + 8] = x; - RectPoints[a * 16 + 9] = y; - - RectPoints[a * 16 + 10] = x; - RectPoints[a * 16 + 11] = y2; - - RectPoints[a * 16 + 12] = x2; - RectPoints[a * 16 + 13] = y; - - RectPoints[a * 16 + 14] = x2; - RectPoints[a * 16 + 15] = y2; + + Vertices[a++] = x2; + Vertices[a++] = y; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + Vertices[a++] = x2; + Vertices[a++] = y2; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + + Vertices[a++] = x2; + Vertices[a++] = y2; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + Vertices[a++] = x; + Vertices[a++] = y2; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + + Vertices[a++] = x; + Vertices[a++] = y2; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + Vertices[a++] = x; + Vertices[a++] = y; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + + Vertices[a++] = x; + Vertices[a++] = y; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + Vertices[a++] = x2; + Vertices[a++] = y2; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + + Vertices[a++] = x2; + Vertices[a++] = y; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + Vertices[a++] = x; + Vertices[a++] = y2; + Vertices[a++] = color[0]; + Vertices[a++] = color[1]; + Vertices[a++] = color[2]; + + // TO DO: build something nicer here + GLfloat temp = color[0]; + color[0] = color[1]; + color[1] = color[2]; + color[2] = temp; } // disable all pointer, TODO: use VAO @@ -590,11 +647,10 @@ void Renderer::DrawDebugInfo() glDisableClientState(GL_TEXTURE_COORD_ARRAY); } - glColorPointer (3, GL_FLOAT, 0, Colours); - glVertexPointer(2, GL_FLOAT, 0, RectPoints); - glDrawArrays(GL_LINE_STRIP, 0, stats.efb_regions.size() * 8); - delete[] RectPoints; - delete[] Colours; + glColorPointer (3, GL_FLOAT, sizeof(GLfloat)*5, Vertices+2); + glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*5, Vertices); + glDrawArrays(GL_LINES, 0, stats.efb_regions.size() * 2*6); + delete[] Vertices; // Restore Line Size glLineWidth(lSize);