From 4f973044ac05b0946396942f166b87fb25faf900 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 24 Jun 2016 11:40:13 -0700 Subject: [PATCH] fix: FPS appears on iOS `glViewport()` has a default value so that it has a valid value after `Scene::render()` exits github issue #15934 --- cocos/base/CCDirector.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 3c92ec8779..b7b1c18019 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -256,6 +256,14 @@ void Director::setGLDefaultValues() setAlphaBlending(true); setDepthTest(false); setProjection(_projection); + + // Everything should be drawn within `Scene::render()`. + // Otherwise it might not render correctly since the GL state might not be the correct one + // so the FPS should be part of Scene. But until we move them there, this little hack is to + // set the default glViewPort(), so that when `Scene::render()` exits, the viewport is the correct + // one for the FPS + auto vp = Camera::getDefaultViewport(); + glViewport(vp._left, vp._bottom, vp._width, vp._height); } // Draw the Scene