Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-02 14:53:46 +0000
committerStijn Buys <ingar@osirion.org>2008-02-02 14:53:46 +0000
commit67f8a7a783e550cab8e6a77d997b31815ee8cd7e (patch)
treeb68bde793bb881b965366569cfc9cea65423eb12 /src/render/box.cc
parent8ac9b27f5f0a1e833974058464cdf7029c9d7e0b (diff)
introduced librender
Diffstat (limited to 'src/render/box.cc')
-rw-r--r--src/render/box.cc102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/render/box.cc b/src/render/box.cc
new file mode 100644
index 0000000..8819a40
--- /dev/null
+++ b/src/render/box.cc
@@ -0,0 +1,102 @@
+/*
+ gl/box.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+// project headers
+#include "render/box.h"
+
+namespace render {
+
+using math::Vector3f;
+using math::Color;
+
+Box::Box(Vector3f const & tl, Vector3f const &br) :
+ topleft(tl), bottomright(br)
+{
+ topcolor = Color::White();
+ bottomcolor= Color::White() * 0.7f;
+}
+
+Box::Box(const Box & other)
+{
+ (*this) = other;
+}
+
+Box& Box::operator=(const Box &other)
+{
+ bottomcolor = other.bottomcolor;
+ topcolor = other.topcolor;
+
+ topleft = other.topleft;
+ bottomright = other.bottomright;
+ return (*this);
+}
+
+void Box::draw()
+{
+ using namespace gl;
+
+ Vector3f v0(topleft.x, bottomright.y, bottomright.z);
+ Vector3f v1(topleft.x, topleft.y, bottomright.z);
+ Vector3f v2(topleft.x, topleft.y, topleft.z);
+ Vector3f v3(topleft.x, bottomright.y, topleft.z);
+
+ Vector3f v4(bottomright.x, bottomright.y, bottomright.z);
+ Vector3f v5(bottomright.x, topleft.y, bottomright.z);
+ Vector3f v6(bottomright.x, topleft.y, topleft.z);
+ Vector3f v7(bottomright.x, bottomright.y, topleft.z);
+
+ begin(Quads);
+
+ // top
+ color(topcolor);
+ vertex(v2);
+ vertex(v1);
+ vertex(v5);
+ vertex(v6);
+
+ // sides
+ color(bottomcolor);
+ vertex(v0);
+ color(topcolor);
+ vertex(v1);
+ vertex(v2);
+ color(bottomcolor);
+ vertex(v3);
+
+ vertex(v3);
+ color(topcolor);
+ vertex(v2);
+ vertex(v6);
+ color(bottomcolor);
+ vertex(v7);
+
+ vertex(v4);
+ color(topcolor);
+ vertex(v5);
+ vertex(v1);
+ color(bottomcolor);
+ vertex(v0);
+
+ vertex(v7);
+ color(topcolor);
+ vertex(v6);
+ vertex(v5);
+ color(bottomcolor);
+ vertex(v4);
+
+ // bottom
+ color(bottomcolor);
+ vertex(v4);
+ vertex(v0);
+ vertex(v3);
+ vertex(v7);
+
+ end();
+
+}
+
+}
+