From dc6398a33e3be47a83ff38b9bbabedcbe6756341 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 9 Feb 2013 18:18:53 -0500 Subject: [PATCH] fix deco sample tool with 1 px brush, fix deco sample also sampling HUD/other text --- src/game/GameView.cpp | 1 + src/game/SampleTool.cpp | 2 +- src/graphics/Renderer.cpp | 8 +++++++- src/graphics/Renderer.h | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index c8b46847c..c352b790f 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1790,6 +1790,7 @@ void GameView::OnDraw() { ren->clearScreen(1.0f); ren->RenderBegin(); + ren->SetSample(c->PointTranslate(currentMouse).X, c->PointTranslate(currentMouse).Y); if(selectMode == SelectNone && (!zoomEnabled || zoomCursorFixed) && activeBrush && currentMouse.X >= 0 && currentMouse.X < XRES && currentMouse.Y >= 0 && currentMouse.Y < YRES) { ui::Point finalCurrentMouse = c->PointTranslate(currentMouse); diff --git a/src/game/SampleTool.cpp b/src/game/SampleTool.cpp index bdebee64c..a42a21423 100644 --- a/src/game/SampleTool.cpp +++ b/src/game/SampleTool.cpp @@ -24,7 +24,7 @@ void SampleTool::Draw(Simulation * sim, Brush * brush, ui::Point position) { if(gameModel->GetColourSelectorVisibility()) { - pixel colour = gameModel->GetRenderer()->GetPixel(position.X, position.Y); + pixel colour = gameModel->GetRenderer()->sampleColor; gameModel->SetColourSelectorColour(ui::Colour(PIXR(colour), PIXG(colour), PIXB(colour), 255)); } else diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 23ebcf0eb..86c0c58c9 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -161,6 +161,11 @@ void Renderer::RenderEnd() #endif } +void Renderer::SetSample(int x, int y) +{ + sampleColor = GetPixel(x, y); +} + void Renderer::clearScreen(float alpha) { #ifdef OGLR @@ -2379,7 +2384,8 @@ Renderer::Renderer(Graphics * g, Simulation * sim): colour_mode(0), gridSize(0), blackDecorations(false), - debugLines(false) + debugLines(false), + sampleColor(0xFFFFFFFF) { this->g = g; this->sim = sim; diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h index 2b6cc14cf..a1ed15970 100644 --- a/src/graphics/Renderer.h +++ b/src/graphics/Renderer.h @@ -63,6 +63,7 @@ public: Simulation * sim; Graphics * g; gcache_item *graphicscache; + pixel sampleColor; //Mouse position for debug information int mousePosX, mousePosY; @@ -94,8 +95,7 @@ public: void ClearAccumulation(); void clearScreen(float alpha); - - //class SolidsRenderer; + void SetSample(int x, int y); #ifdef OGLR void checkShader(GLuint shader, char * shname);