summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-28 12:09:35 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-28 12:09:35 (GMT)
commitf9eeebb91039d88ceb7e4cf4e4aecf374d77e633 (patch)
treef6efdfcd4189a8c5b2fb483ecb8737633d71461c
parent30b11a7724c20bb3cf09a9dd67ee7ea39093c44b (diff)
downloadpowder-f9eeebb91039d88ceb7e4cf4e4aecf374d77e633.zip
powder-f9eeebb91039d88ceb7e4cf4e4aecf374d77e633.tar.gz
Draw brush using renderer, fixes issue #25
-rw-r--r--src/game/Brush.cpp42
-rw-r--r--src/game/Brush.h42
-rw-r--r--src/game/GameView.cpp8
-rw-r--r--src/graphics/Renderer.cpp3
4 files changed, 52 insertions, 43 deletions
diff --git a/src/game/Brush.cpp b/src/game/Brush.cpp
new file mode 100644
index 0000000..e52febb
--- /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 1b7cf69..a7737ee 100644
--- a/src/game/Brush.h
+++ b/src/game/Brush.h
@@ -11,6 +11,7 @@
#include <iostream>
#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 7e34b85..a35f524 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 e1c0da0..73d9b63 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
}