From 1b8e45fe19b8e8666a0a0231185395ccf5bde478 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 3 Apr 2014 17:40:14 +0800 Subject: [PATCH] remove kmGLFreeAll call --- cocos/2d/CCDirector.cpp | 20 ++++++++++++++++++++ cocos/2d/CCDirector.h | 1 + cocos/2d/ccGLStateCache.cpp | 3 +-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index f71b356426..c8c992c976 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -434,11 +434,31 @@ void Director::initMatrixStack() kmMat4 identity; kmMat4Identity(&identity); + while (!_modelViewMatrixStack.empty()) + { + _modelViewMatrixStack.pop(); + } + + while (!_projectionMatrixStack.empty()) + { + _projectionMatrixStack.pop(); + } + + while (!_textureMatrixStack.empty()) + { + _textureMatrixStack.pop(); + } + _modelViewMatrixStack.push(identity); _projectionMatrixStack.push(identity); _textureMatrixStack.push(identity); } +void Director::resetMatrixStack() +{ + initMatrixStack(); +} + void Director::popMatrix(MATRIX_STACK_TYPE type) { if(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW == type) diff --git a/cocos/2d/CCDirector.h b/cocos/2d/CCDirector.h index 91e1ee9378..157913057b 100644 --- a/cocos/2d/CCDirector.h +++ b/cocos/2d/CCDirector.h @@ -106,6 +106,7 @@ public: void loadMatrix(MATRIX_STACK_TYPE type, const kmMat4& mat); void multiplyMatrix(MATRIX_STACK_TYPE type, const kmMat4& mat); kmMat4 getMatrix(MATRIX_STACK_TYPE type); + void resetMatrixStack(); public: static const char *EVENT_PROJECTION_CHANGED; static const char* EVENT_AFTER_UPDATE; diff --git a/cocos/2d/ccGLStateCache.cpp b/cocos/2d/ccGLStateCache.cpp index 987f30b709..7e076e5366 100644 --- a/cocos/2d/ccGLStateCache.cpp +++ b/cocos/2d/ccGLStateCache.cpp @@ -65,8 +65,7 @@ namespace GL { void invalidateStateCache( void ) { - kmGLFreeAll(); - + Director::getInstance()->resetMatrixStack(); s_currentProjectionMatrix = -1; s_vertexAttribPosition = false; s_vertexAttribColor = false;