From 48e0d7d3a611a6d6d9bcaff8ef4f9011eb25146d Mon Sep 17 00:00:00 2001 From: coulsonwang Date: Sat, 31 Aug 2019 20:10:32 +0800 Subject: [PATCH] resize metal drawable (#20074) --- cocos/platform/mac/CCGLViewImpl-mac.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos/platform/mac/CCGLViewImpl-mac.mm b/cocos/platform/mac/CCGLViewImpl-mac.mm index d430083ed5..e03446dc2f 100644 --- a/cocos/platform/mac/CCGLViewImpl-mac.mm +++ b/cocos/platform/mac/CCGLViewImpl-mac.mm @@ -319,7 +319,6 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram return false; } - int fbWidth, fbHeight; glfwGetFramebufferSize(_mainWindow, &fbWidth, &fbHeight); @@ -879,6 +878,14 @@ void GLViewImpl::onGLFWWindowSizeFunCallback(GLFWwindow* /*window*/, int width, setDesignResolutionSize(baseDesignSize.width, baseDesignSize.height, baseResolutionPolicy); Director::getInstance()->setViewport(); Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(GLViewImpl::EVENT_WINDOW_RESIZED, nullptr); + + //update metal drawable size. + int fbWidth, fbHeight; + glfwGetFramebufferSize(_mainWindow, &fbWidth, &fbHeight); + CGSize size; + size.width = static_cast(fbWidth); + size.height = static_cast(fbHeight); + [backend::DeviceMTL::getCAMetalLayer() setDrawableSize:size]; } }