#include <GL/glu.h>
#include "dms/PerspCamera.h"

namespace dms
{

PerspCamera::PerspCamera(GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far)
    {
    fovy_ = fovy;
    aspect_ = aspect;
    near_ = near;
    far_ = far;
    }


void PerspCamera::applyProjection(void) const
    {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(fovy_, aspect_, near_, far_);
    glMatrixMode(GL_MODELVIEW);
    }


void PerspCamera::zoom(GLdouble angle)
    {
    GLdouble newFovy = fovy_ + angle;
    if ((newFovy > 0.0) && (newFovy < 180.0))
        fovy_ = newFovy;
    }


GLdouble PerspCamera::fovy(void) const
    {
    return fovy_;
    }


GLdouble PerspCamera::aspect(void) const
    {
    return aspect_;
    }


GLdouble PerspCamera::near(void) const
    {
    return near_;
    }


GLdouble PerspCamera::far(void) const
    {
    return far_;
    }


void PerspCamera::setFovy(GLdouble fovy)
    {
    fovy_ = fovy;
    }


void PerspCamera::setAspect(GLdouble aspect)
    {
    aspect_ = aspect;
    }


void PerspCamera::setNear(GLdouble near)
    {
    near_ = near;
    }


void PerspCamera::setFar(GLdouble far)
    {
    far_ = far;
    }

}
