X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprojection.cpp;fp=source%2Fprojection.cpp;h=1b7fa61f11a4389d8799387df6e060fadb3b2188;hb=bdf2568e247af858c4a1ca8004d97f13fe9b8cb0;hp=0000000000000000000000000000000000000000;hpb=7ef0e6407e21acdcd9865651a12b40d6a3cb3c0e;p=libs%2Fgl.git diff --git a/source/projection.cpp b/source/projection.cpp new file mode 100644 index 00000000..1b7fa61f --- /dev/null +++ b/source/projection.cpp @@ -0,0 +1,52 @@ +/* $Id$ + +This file is part of libmspgl +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#include +#include +#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