summaryrefslogtreecommitdiffstats
path: root/Renderer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Renderer.cpp')
-rw-r--r--Renderer.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/Renderer.cpp b/Renderer.cpp
index c8ecac2..e2ededc 100644
--- a/Renderer.cpp
+++ b/Renderer.cpp
@@ -69,6 +69,15 @@ void Renderer::drawCircle(const Vertex &m, float r, int n) {
glEnd();
}
+void Renderer::fillCircle(const Vertex &m, float r, int n) {
+ glBegin(GL_POLYGON);
+
+ for(int i = 0; i < n; i++)
+ glVertex2f(m.getX()+r*cosf(2*M_PI*i/n), m.getY()+r*sinf(2*M_PI*i/n));
+
+ glEnd();
+}
+
void Renderer::drawCross(const Vertex &m, float r) {
glBegin(GL_LINES);
@@ -90,6 +99,15 @@ void Renderer::renderObject(const LevelObject &object, bool selected, bool highl
renderPortal(*(Portal*)&object, selected, highlighted, scale);
}
+void Renderer::renderVertex(const Vertex &vertex, bool selected, bool highlighted, float scale) {
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+ fillCircle(vertex, 3/scale, 16);
+
+ glLineWidth(1.0f);
+ glColor4f(9.0f, 0.7f, 0.0f, 0.9f);
+ drawCircle(vertex, 3/scale, 16);
+}
+
void Renderer::renderRoom(const Room &room, bool selected, bool highlighted, float scale) {
if(selected)
glColor4f(0.0f, 0.7f, 1.0f, 0.2f);
@@ -112,6 +130,11 @@ void Renderer::renderRoom(const Room &room, bool selected, bool highlighted, flo
}
drawPolygon(room);
+
+ if(selected || highlighted) {
+ for(Room::const_iterator v = room.begin(); v != room.end(); v++)
+ renderVertex(*v, false, false, scale);
+ }
}
void Renderer::renderPlayerStart(const PlayerStart &start, bool selected, bool highlighted, float scale) {
@@ -169,6 +192,17 @@ void Renderer::renderPortal(const Portal &portal, bool selected, bool highlighte
glVertex2f(portal.getPosition().getX()+x, portal.getPosition().getY()+y);
glEnd();
+
+ if(highlighted || selected) {
+ renderVertex(Vertex(portal.getPosition().getX()-x+ts, portal.getPosition().getY()-y-tc),
+ false, false, scale);
+ renderVertex(Vertex(portal.getPosition().getX()-x-ts, portal.getPosition().getY()-y+tc),
+ false, false, scale);
+ renderVertex(Vertex(portal.getPosition().getX()+x+ts, portal.getPosition().getY()+y-tc),
+ false, false, scale);
+ renderVertex(Vertex(portal.getPosition().getX()+x-ts, portal.getPosition().getY()+y+tc),
+ false, false, scale);
+ }
}
void Renderer::render(const Level &level, const Rectangle &rect, float scale) {