From 1962dfa52d143bc72638a3fa57129f74a8e23d87 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 30 Dec 2013 14:43:18 +0800 Subject: [PATCH] migration transition page turn to new renderer --- cocos/2d/CCTransitionPageTurn.cpp | 36 ++++++++++++++++++++++++------- cocos/2d/CCTransitionPageTurn.h | 7 ++++++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index f7b0188143..a4bc2fbe15 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -30,6 +30,7 @@ THE SOFTWARE. #include "CCActionGrid.h" #include "CCActionPageTurn3D.h" #include "CCNodeGrid.h" +#include "renderer/CCRenderer.h" NS_CC_BEGIN @@ -78,24 +79,43 @@ void TransitionPageTurn::sceneOrder() _isInSceneOnTop = _back; } +void TransitionPageTurn::onEnablePolygonOffset() +{ + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); +} + +void TransitionPageTurn::onDisablePolygonOffset() +{ + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); +} + void TransitionPageTurn::draw() { Scene::draw(); if( _isInSceneOnTop ) { _outSceneProxy->visit(); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); + _enableOffsetCmd.init(0, _vertexZ); + _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); + Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd); _inSceneProxy->visit(); - glDisable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0, 0); + _disableOffsetCmd.init(0, _vertexZ); + _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); + Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd); } else { _inSceneProxy->visit(); - glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); + + _enableOffsetCmd.init(0, _vertexZ); + _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); + Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd); + _outSceneProxy->visit(); - glDisable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(0, 0); + + _disableOffsetCmd.init(0, _vertexZ); + _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); + Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd); } } diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index 7230f2bd51..f21598c8f2 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -27,6 +27,7 @@ THE SOFTWARE. #define __CCPAGE_TURN_TRANSITION_H__ #include "CCTransition.h" +#include "renderer/CCCustomCommand.h" NS_CC_BEGIN @@ -96,6 +97,12 @@ protected: bool _back; static float POLYGON_OFFSET_FACTOR; static float POLYGON_OFFSET_UNITS; + +protected: + CustomCommand _enableOffsetCmd; + CustomCommand _disableOffsetCmd; + void onEnablePolygonOffset(); + void onDisablePolygonOffset(); }; // end of transition group