+#include "geomdraw.h"
+#include "opengl.h"
+#include "logger.h"
+#include "shader.h"
+
+static void draw_sphere(const Sphere *sph);
+static void draw_box(const Box *box);
+static void draw_plane(const Plane *plane);
+
+void draw_geom_object(const GeomObject *gobj)
+{
+ switch(gobj->type) {
+ case GOBJ_SPHERE:
+ draw_sphere((Sphere*)gobj);
+ break;
+
+ case GOBJ_AABOX:
+ {
+ Box box = Box(*(AABox*)gobj, Mat4::identity);
+ draw_box(&box);
+ }
+ break;
+
+ case GOBJ_BOX:
+ draw_box((Box*)gobj);
+ break;
+
+ case GOBJ_PLANE:
+ draw_plane((Plane*)gobj);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void draw_sphere(const Sphere *sph)
+{
+ // TODO
+ warning_log("draw_sphere unimplemented\n");
+}
+
+static void draw_box(const Box *box)
+{
+ static const int edges[][2] = {
+ {0, 1}, {1, 2}, {2, 3}, {3, 0},
+ {4, 5}, {5, 6}, {6, 7}, {7, 4},
+ {0, 4}, {1, 5}, {2, 6}, {3, 7}
+ };
+
+ bind_shader(0);
+
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_TEXTURE_2D);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glMultMatrixf(box->xform[0]);
+
+ glBegin(GL_LINES);
+ glColor3f(1, 1, 0);
+ for(int i=0; i<12; i++) {
+ Vec3 a = box->get_corner(edges[i][0]);
+ Vec3 b = box->get_corner(edges[i][1]);
+
+ glVertex3f(a.x, a.y, a.z);
+ glVertex3f(b.x, b.y, b.z);
+ }
+ glEnd();
+
+ glPopMatrix();
+ glPopAttrib();
+}
+
+static void draw_plane(const Plane *plane)
+{
+ // TODO
+ warning_log("draw_plane unimplemented\n");
+}