From b2579a754a5d41d25b7b964923674084be73cba2 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 29 May 2015 14:08:20 +0800 Subject: [PATCH] refactor, use Camera::apply() to apply Rendertarget and Viewport --- cocos/2d/CCCamera.cpp | 5 +++++ cocos/2d/CCCamera.h | 12 ++++++++++-- cocos/2d/CCScene.cpp | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index cd1e9bf6db..c503aa5dc0 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -462,6 +462,11 @@ void Camera::applyFrameBufferObject() } } +void Camera::apply() +{ + applyFrameBufferObject(); +} + int Camera::getRenderOrder() const { int result(0); diff --git a/cocos/2d/CCCamera.h b/cocos/2d/CCCamera.h index 1793990874..98676573a9 100644 --- a/cocos/2d/CCCamera.h +++ b/cocos/2d/CCCamera.h @@ -190,9 +190,17 @@ public: * Get the default camera of the current running scene. */ static Camera* getDefaultCamera(); - + /** + Before rendering scene with this camera, the background need to be cleared. + */ void clearBackground(float depth); - + /** + Apply the FBO, RenderTargets and viewport. + */ + void apply(); + /** + Set FBO, which will attacha several render target for the rendered result. + */ void setFrameBufferObject(FrameBufferObject* fbo); CC_CONSTRUCTOR_ACCESS: diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index dacc995fb1..448a94d8c7 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -164,7 +164,7 @@ void Scene::render(Renderer* renderer) director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, Camera::_visitingCamera->getViewProjectionMatrix()); - camera->applyFrameBufferObject(); + camera->apply(); //clear background with max depth camera->clearBackground(1.0); //visit the scene