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 "Framebuffer.h"
#include "Scene.h"
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> void Camera<MatrixType, VectorType, ObjectType, SceneType, CameraType>::setViewport(const Math::Vector2<GLsizei>& size) {
Framebuffer::setViewport({0, 0}, size);
_viewport = size;
fixAspectRatio();
@ -65,8 +63,6 @@ template<class MatrixType, class VectorType, class ObjectType, class SceneType,
SceneType* s = this->scene();
CORRADE_ASSERT(s, "Camera: cannot draw without camera attached to scene", );
Framebuffer::clear();
/* Recursively draw child objects */
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
*
* Call when window size changes.
*
* Calls Framebuffer::setViewport() and stores viewport size
* internally.
* Stores viewport size internally and recalculates projection matrix
* according to aspect ratio policy.
* @see setAspectRatioPolicy()
*/
virtual void setViewport(const Math::Vector2<GLsizei>& size);
/**
* @brief Draw the scene
*
* Calls Framebuffer::clear() and draws the scene using drawChildren().
* Draws the scene using drawChildren().
*/
virtual void draw();

Loading…
Cancel
Save