Skip to content

Commit

Permalink
Added an orthographic camera class to the main VGL code.
Browse files Browse the repository at this point in the history
This is a fancy way of saying that I moved the OrthoCamera from the imageview example into the main codebase. :-)
  • Loading branch information
vilya committed Aug 18, 2010
1 parent 5549efc commit 5eb43ef
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 41 deletions.
2 changes: 2 additions & 0 deletions Makefile
Expand Up @@ -47,6 +47,7 @@ LIBVGL_OBJS := \
$(OBJ)/vgl_camera.o \
$(OBJ)/vgl_image.o \
$(OBJ)/vgl_objparser.o \
$(OBJ)/vgl_orthocamera.o \
$(OBJ)/vgl_parser.o \
$(OBJ)/vgl_plane3.o \
$(OBJ)/vgl_plyparser.o \
Expand All @@ -65,6 +66,7 @@ LIBVGL_INCS := \
$(DIST)/include/vgl_matrix3.h \
$(DIST)/include/vgl_matrix4.h \
$(DIST)/include/vgl_objparser.h \
$(DIST)/include/vgl_orthocamera.h \
$(DIST)/include/vgl_parser.h \
$(DIST)/include/vgl_plane3.h \
$(DIST)/include/vgl_plyparser.h \
Expand Down
35 changes: 1 addition & 34 deletions example/imageview.cpp
Expand Up @@ -7,16 +7,6 @@
// CLASSES
//

class OrthoCamera : public vgl::BaseCamera
{
public:
OrthoCamera(unsigned int pixelWidth, unsigned int pixelHeight);

virtual void setupProjectionMatrix();
virtual void setupModelViewMatrix();
};


class ImageViewRenderer : public vgl::Renderer
{
public:
Expand All @@ -30,29 +20,6 @@ class ImageViewRenderer : public vgl::Renderer
};


//
// OrthoCamera METHODS
//

OrthoCamera::OrthoCamera(unsigned int pixelWidth, unsigned int pixelHeight) :
vgl::BaseCamera(pixelWidth, pixelHeight)
{
}


void OrthoCamera::setupProjectionMatrix()
{
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glOrtho(viewport[0], viewport[2], viewport[1], viewport[3], -0.5, 0.5);
}


void OrthoCamera::setupModelViewMatrix()
{
}


//
// ImageViewRenderer METHODS
//
Expand Down Expand Up @@ -109,7 +76,7 @@ int main(int argc, char** argv)
}

vgl::RawImage* img = new vgl::RawImage(argv[1]);
OrthoCamera* camera = new OrthoCamera(img->getWidth(), img->getHeight());
vgl::Camera* camera = new vgl::OrthoCamera(img->getWidth(), img->getHeight());
ImageViewRenderer* renderer = new ImageViewRenderer(img);
vgl::Viewer viewer("VGL Image Viewer",
img->getWidth(), img->getHeight(), camera, renderer);
Expand Down
28 changes: 21 additions & 7 deletions src/vgl.h
Expand Up @@ -5,22 +5,36 @@
// individually. You may still wish to include them separately to help keep
// compile times down, though.

#include "vgl_basecamera.h"
#include "vgl_camera.h"
#include "vgl_image.h"
// Maths
#include "vgl_matrix3.h"
#include "vgl_matrix4.h"
#include "vgl_parser.h"
#include "vgl_plane3.h"
#include "vgl_quaternion.h"
#include "vgl_ray3.h"
#include "vgl_renderer.h"
#include "vgl_utils.h"
#include "vgl_vec2.h"
#include "vgl_vec3.h"
#include "vgl_vec4.h"
#include "vgl_quaternion.h"

// Cameras
#include "vgl_basecamera.h"
#include "vgl_camera.h"
#include "vgl_orthocamera.h"

// Image files
#include "vgl_image.h"

// Model files
#include "vgl_parser.h"

// Rendering
#include "vgl_renderer.h"

// GUI
#include "vgl_viewer.h"

// Miscellaneous
#include "vgl_utils.h"

#define GL_GLEXT_PROTOTYPES 1
#ifdef linux
#include <GL/gl.h>
Expand Down
30 changes: 30 additions & 0 deletions src/vgl_orthocamera.cpp
@@ -0,0 +1,30 @@
#include "vgl_orthocamera.h"

namespace vgl {


//
// OrthoCamera METHODS
//

OrthoCamera::OrthoCamera(unsigned int pixelWidth, unsigned int pixelHeight) :
BaseCamera(pixelWidth, pixelHeight)
{
}


void OrthoCamera::setupProjectionMatrix()
{
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glOrtho(viewport[0], viewport[2], viewport[1], viewport[3], -0.5, 0.5);
}


void OrthoCamera::setupModelViewMatrix()
{
}


} // namespace vgl

22 changes: 22 additions & 0 deletions src/vgl_orthocamera.h
@@ -0,0 +1,22 @@
#ifndef vgl_orthocamera_h
#define vgl_orthocamera_h

#include "vgl_basecamera.h"

namespace vgl {


class OrthoCamera : public vgl::BaseCamera
{
public:
OrthoCamera(unsigned int pixelWidth, unsigned int pixelHeight);

virtual void setupProjectionMatrix();
virtual void setupModelViewMatrix();
};


} // namespace vgl

#endif // vgl_orthocamera_h

0 comments on commit 5eb43ef

Please sign in to comment.