diff --git a/src/game/Brush.cpp b/src/game/Brush.cpp new file mode 100644 index 000000000..e52febb22 --- /dev/null +++ b/src/game/Brush.cpp @@ -0,0 +1,42 @@ +#include "Brush.h" +#include "graphics/Renderer.h" + +void Brush::RenderRect(Renderer * ren, ui::Point position1, ui::Point position2) +{ + int width, height, t; + width = position2.X-position1.X; + height = position2.Y-position1.Y; + if(height<0) + { + position1.Y += height; + height *= -1; + } + if(width<0) + { + position1.X += width; + width *= -1; + } + ren->xor_line(position1.X, position1.Y, position1.X+width, position1.Y); + ren->xor_line(position1.X, position1.Y+height, position1.X+width, position1.Y+height); + ren->xor_line(position1.X+width, position1.Y+1, position1.X+width, position1.Y+height-1); + ren->xor_line(position1.X, position1.Y+1, position1.X, position1.Y+height-1); +} + +void Brush::RenderLine(Renderer * ren, ui::Point position1, ui::Point position2) +{ + ren->xor_line(position1.X, position1.Y, position2.X, position2.Y); +} + +void Brush::RenderPoint(Renderer * ren, ui::Point position) +{ + if(!outline) + updateOutline(); + if(!outline) + return; + ren->xor_bitmap(outline, position.X-radius.X, position.Y-radius.Y, size.X, size.Y); +} + +void Brush::RenderFill(Renderer * ren, ui::Point position) +{ + +} \ No newline at end of file diff --git a/src/game/Brush.h b/src/game/Brush.h index 1b7cf6991..a7737ee20 100644 --- a/src/game/Brush.h +++ b/src/game/Brush.h @@ -11,6 +11,7 @@ #include #include "interface/Point.h" +class Renderer; class Brush { protected: @@ -73,43 +74,10 @@ public: if(outline) delete[] outline; } - virtual void RenderRect(Graphics * g, ui::Point position1, ui::Point position2) - { - int width, height, t; - width = position2.X-position1.X; - height = position2.Y-position1.Y; - if(height<0) - { - position1.Y += height; - height *= -1; - } - if(width<0) - { - position1.X += width; - width *= -1; - } - g->xor_line(position1.X, position1.Y, position1.X+width, position1.Y); - g->xor_line(position1.X, position1.Y+height, position1.X+width, position1.Y+height); - g->xor_line(position1.X+width, position1.Y+1, position1.X+width, position1.Y+height-1); - g->xor_line(position1.X, position1.Y+1, position1.X, position1.Y+height-1); - } - virtual void RenderLine(Graphics * g, ui::Point position1, ui::Point position2) - { - g->xor_line(position1.X, position1.Y, position2.X, position2.Y); - } - //Draw the brush outline onto the screen - virtual void RenderPoint(Graphics * g, ui::Point position) - { - if(!outline) - updateOutline(); - if(!outline) - return; - g->xor_bitmap(outline, position.X-radius.X, position.Y-radius.Y, size.X, size.Y); - } - virtual void RenderFill(Graphics * g, ui::Point position) - { - //Do nothing for now - possibly draw some sort of flood fill mask - } + virtual void RenderRect(Renderer * ren, ui::Point position1, ui::Point position2); + virtual void RenderLine(Renderer * ren, ui::Point position1, ui::Point position2); + virtual void RenderPoint(Renderer * ren, ui::Point position); + virtual void RenderFill(Renderer * ren, ui::Point position); virtual void GenerateBitmap() { if(bitmap) diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 7e34b856a..a35f524a0 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1206,7 +1206,7 @@ void GameView::OnDraw() { finalCurrentMouse = rectSnapCoords(c->PointTranslate(drawPoint1), finalCurrentMouse); } - activeBrush->RenderRect(g, c->PointTranslate(drawPoint1), finalCurrentMouse); + activeBrush->RenderRect(ren, c->PointTranslate(drawPoint1), finalCurrentMouse); } else if(drawMode==DrawLine && isMouseDown) { @@ -1214,15 +1214,15 @@ void GameView::OnDraw() { finalCurrentMouse = lineSnapCoords(c->PointTranslate(drawPoint1), finalCurrentMouse); } - activeBrush->RenderLine(g, c->PointTranslate(drawPoint1), finalCurrentMouse); + activeBrush->RenderLine(ren, c->PointTranslate(drawPoint1), finalCurrentMouse); } else if(drawMode==DrawFill) { - activeBrush->RenderFill(g, finalCurrentMouse); + activeBrush->RenderFill(ren, finalCurrentMouse); } else { - activeBrush->RenderPoint(g, finalCurrentMouse); + activeBrush->RenderPoint(ren, finalCurrentMouse); } } ren->RenderEnd(); diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index e1c0da047..73d9b63fa 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -45,15 +45,14 @@ void Renderer::RenderBegin() DrawWalls(); DrawSigns(); #ifndef OGLR - RenderZoom(); FinaliseParts(); #endif } void Renderer::RenderEnd() { -#ifdef OGLR RenderZoom(); +#ifdef OGLR FinaliseParts(); #endif }