Browse Source

Don't do anything OpenGL-related inside Camera itself.

* The user might not want to call Framebuffer::clear(), because there
   could be something already rendered with another camera.
 * The user might not want to call Framebuffer::setViewport(), because
   there could be different framebuffer attached.
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
e1c22b9ca2
  1. 4
      src/SceneGraph/Camera.cpp
  2. 9
      src/SceneGraph/Camera.h

4
src/SceneGraph/Camera.cpp

@ -14,7 +14,6 @@
*/ */
#include "Camera.h" #include "Camera.h"
#include "Framebuffer.h"
#include "Scene.h" #include "Scene.h"
using namespace std; using namespace std;
@ -49,7 +48,6 @@ template Matrix4 aspectRatioFix<Matrix4>(AspectRatioPolicy, const Vector2&, cons
template<class MatrixType, class VectorType, class ObjectType, class SceneType, class CameraType> Camera<MatrixType, VectorType, ObjectType, SceneType, CameraType>::Camera(ObjectType* parent): ObjectType(parent), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) {} template<class MatrixType, class VectorType, class ObjectType, class SceneType, class CameraType> Camera<MatrixType, VectorType, ObjectType, SceneType, CameraType>::Camera(ObjectType* parent): ObjectType(parent), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) {}
template<class MatrixType, class VectorType, class ObjectType, class SceneType, class CameraType> void Camera<MatrixType, VectorType, ObjectType, SceneType, CameraType>::setViewport(const Math::Vector2<GLsizei>& size) { template<class MatrixType, class VectorType, class ObjectType, class SceneType, class CameraType> void Camera<MatrixType, VectorType, ObjectType, SceneType, CameraType>::setViewport(const Math::Vector2<GLsizei>& size) {
Framebuffer::setViewport({0, 0}, size);
_viewport = size; _viewport = size;
fixAspectRatio(); fixAspectRatio();
@ -65,8 +63,6 @@ template<class MatrixType, class VectorType, class ObjectType, class SceneType,
SceneType* s = this->scene(); SceneType* s = this->scene();
CORRADE_ASSERT(s, "Camera: cannot draw without camera attached to scene", ); CORRADE_ASSERT(s, "Camera: cannot draw without camera attached to scene", );
Framebuffer::clear();
/* Recursively draw child objects */ /* Recursively draw child objects */
drawChildren(s, cameraMatrix()); drawChildren(s, cameraMatrix());
} }

9
src/SceneGraph/Camera.h

@ -112,17 +112,16 @@ template<class MatrixType, class VectorType, class ObjectType, class SceneType,
/** /**
* @brief Set viewport size * @brief Set viewport size
* *
* Call when window size changes. * Stores viewport size internally and recalculates projection matrix
* * according to aspect ratio policy.
* Calls Framebuffer::setViewport() and stores viewport size * @see setAspectRatioPolicy()
* internally.
*/ */
virtual void setViewport(const Math::Vector2<GLsizei>& size); virtual void setViewport(const Math::Vector2<GLsizei>& size);
/** /**
* @brief Draw the scene * @brief Draw the scene
* *
* Calls Framebuffer::clear() and draws the scene using drawChildren(). * Draws the scene using drawChildren().
*/ */
virtual void draw(); virtual void draw();

Loading…
Cancel
Save