--- /dev/null
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include <cmath>
+#include <GL/gl.h>
+#include "projection.h"
+
+namespace Msp {
+namespace GL {
+
+void ortho(double left, double right, double bottom, double top, double near, double far)
+{
+ glOrtho(left, right, bottom, top, near, far);
+}
+
+void ortho_centered(double width, double height)
+{
+ ortho(-width/2, width/2, -height/2, height/2, 0, 1);
+}
+
+void ortho_bottomleft(double width, double height)
+{
+ ortho(0, width, 0, height, 0, 1);
+}
+
+void ortho_topleft(double width, double height)
+{
+ ortho(0, width, -height, 0, 0, 1);
+}
+
+void frustum(double left, double right, double bottom, double top, double near, double far)
+{
+ glFrustum(left, right, bottom, top, near, far);
+}
+
+void frustum_centered(double width, double height, double near, double far)
+{
+ glFrustum(-width/2, width/2, -height/2, height/2, near, far);
+}
+
+void perspective(double fov_y, double aspect, double near, double far)
+{
+ double hh=tan(fov_y*M_PI/360)*near;
+ frustum(-hh*aspect, hh*aspect, -hh, hh, near, far);
+}
+
+} // namespace GL
+} // namespace Msp
--- /dev/null
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_PROJECTION_H_
+#define MSP_GL_PROJECTION_H_
+
+namespace Msp {
+namespace GL {
+
+/**
+Sets up an orthogonal projection.
+*/
+void ortho(double, double, double, double, double, double);
+
+/**
+Sets up an orthogonal projection, with origin at the center of the screen.
+*/
+void ortho_centered(double, double);
+
+/**
+Sets up an orthogonal projection, with origin at the bottom left corner of the
+screen.
+*/
+void ortho_bottomleft(double, double);
+
+/**
+Sets up an orthogonal projection, with origin at the top left corner of the
+screen. The Y coordinate is reversed and grows downwards.
+*/
+void ortho_topleft(double, double);
+
+/**
+Sets up a perspective projection.
+*/
+void frustum(double, double, double, double, double, double);
+
+/**
+Sets up a perspective projection, with origin at the center of the screen.
+*/
+void frustum_centered(double width, double height, double near, double far);
+
+/**
+Sets up a centered perspective projection in a simple way.
+*/
+void perspective(double fov_y, double aspect, double near, double far);
+
+} // namespace GL
+} // namespace Msp
+
+#endif