From 6f274a80036e590ba14c219d02638bacddf17fa1 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sun, 2 Aug 2020 16:55:21 +0800 Subject: [PATCH] Set full screen before layout renderer elements to ensure VisibleRect is correct with full screen window size --- .../cpp-tests/Classes/WindowTest/WindowTest.cpp | 17 ++++++++++------- tests/cpp-tests/Classes/WindowTest/WindowTest.h | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/cpp-tests/Classes/WindowTest/WindowTest.cpp b/tests/cpp-tests/Classes/WindowTest/WindowTest.cpp index 87f40caff9..15fea11d59 100644 --- a/tests/cpp-tests/Classes/WindowTest/WindowTest.cpp +++ b/tests/cpp-tests/Classes/WindowTest/WindowTest.cpp @@ -59,30 +59,33 @@ std::string WindowTestWindowed2::subtitle() const { return "Windowed 960x640"; } -void WindowTestFullscreen1::onEnter() { - WindowTest::onEnter(); +bool WindowTestFullscreen1::init() +{ + // @remark: Set full screen before layout renderer elements to ensure VisibleRect is + // correct with full screen window size GLViewImpl* view = (GLViewImpl*)Director::getInstance()->getOpenGLView(); view->setFullscreen(); + return WindowTest::init(); } std::string WindowTestFullscreen1::subtitle() const { return "Fullscreen"; } -void WindowTestFullscreen2::onEnter() { - WindowTest::onEnter(); +bool WindowTestFullscreen2::init() { GLViewImpl* view = (GLViewImpl*)Director::getInstance()->getOpenGLView(); view->setFullscreen(1); + return WindowTest::init(); } std::string WindowTestFullscreen2::subtitle() const { return "Fullscreen Monitor 2 (if present)"; } -void WindowTestFullscreen3::onEnter() { - WindowTest::onEnter(); +bool WindowTestFullscreen3::init() { GLViewImpl* view = (GLViewImpl*)Director::getInstance()->getOpenGLView(); - view->setFullscreen(2); + view->setFullscreen(3); + return WindowTest::init(); } std::string WindowTestFullscreen3::subtitle() const { diff --git a/tests/cpp-tests/Classes/WindowTest/WindowTest.h b/tests/cpp-tests/Classes/WindowTest/WindowTest.h index d7a5b54bf7..f5ee4e7340 100644 --- a/tests/cpp-tests/Classes/WindowTest/WindowTest.h +++ b/tests/cpp-tests/Classes/WindowTest/WindowTest.h @@ -56,7 +56,7 @@ class WindowTestFullscreen1 : public WindowTest { public: CREATE_FUNC(WindowTestFullscreen1); - virtual void onEnter() override; + bool init() override; virtual std::string subtitle() const override; }; @@ -64,14 +64,14 @@ class WindowTestFullscreen2 : public WindowTest { public: CREATE_FUNC(WindowTestFullscreen2); - virtual void onEnter() override; + bool init() override; virtual std::string subtitle() const override; }; class WindowTestFullscreen3 : public WindowTest { public: CREATE_FUNC(WindowTestFullscreen3); - virtual void onEnter() override; + bool init() override; virtual std::string subtitle() const override; };