From cb89ee90f5de2350a64f82077514690d974ea666 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 20 May 2020 14:43:27 -0600 Subject: [PATCH] DRTVWR-510: Fix coord error in 'Show Color Under Cursor' --- indra/newview/llviewerwindow.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 48547947b2..18a2237f20 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -781,19 +781,23 @@ public: addText(xpos, ypos, "View Matrix"); ypos += y_inc; } - // - //if (gSavedSettings.getBOOL("DebugShowColor") && !LLRender::sNsightDebugSupport) - //static LLCachedControl debugShowColor(gSavedSettings, "DebugShowColor"); - static LLCachedControl debugShowColor(gSavedSettings, "DebugShowColor"); - // - if (debugShowColor && !LLRender::sNsightDebugSupport) - { - U8 color[4]; - LLCoordGL coord = gViewerWindow->getCurrentMouse(); - glReadPixels(coord.mX, coord.mY, 1,1,GL_RGBA, GL_UNSIGNED_BYTE, color); - addText(xpos, ypos, llformat("%d %d %d %d", color[0], color[1], color[2], color[3])); - ypos += y_inc; - } + // + //static LLCachedControl debugShowColor(gSavedSettings, "DebugShowColor"); + static LLCachedControl debugShowColor(gSavedSettings, "DebugShowColor"); + if (debugShowColor && !LLRender::sNsightDebugSupport) + // + { + U8 color[4]; + LLCoordGL coord = gViewerWindow->getCurrentMouse(); + + // Convert x,y to raw pixel coords + S32 x_raw = llround(coord.mX * gViewerWindow->getWindowWidthRaw() / (F32) gViewerWindow->getWindowWidthScaled()); + S32 y_raw = llround(coord.mY * gViewerWindow->getWindowHeightRaw() / (F32) gViewerWindow->getWindowHeightScaled()); + + glReadPixels(x_raw, y_raw, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, color); + addText(xpos, ypos, llformat("Pixel <%1d, %1d> R:%1d G:%1d B:%1d A:%1d", x_raw, y_raw, color[0], color[1], color[2], color[3])); + ypos += y_inc; + } // FIRE-29880: Movelock static LLCachedControl fsRenderMovelockState(gSavedPerAccountSettings, "UseMoveLock");