resize metal drawable (#20074)

This commit is contained in:
coulsonwang 2019-08-31 20:10:32 +08:00 committed by minggo
parent 73ad115702
commit 48e0d7d3a6
1 changed files with 8 additions and 1 deletions

View File

@ -319,7 +319,6 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
return false; return false;
} }
int fbWidth, fbHeight; int fbWidth, fbHeight;
glfwGetFramebufferSize(_mainWindow, &fbWidth, &fbHeight); glfwGetFramebufferSize(_mainWindow, &fbWidth, &fbHeight);
@ -879,6 +878,14 @@ void GLViewImpl::onGLFWWindowSizeFunCallback(GLFWwindow* /*window*/, int width,
setDesignResolutionSize(baseDesignSize.width, baseDesignSize.height, baseResolutionPolicy); setDesignResolutionSize(baseDesignSize.width, baseDesignSize.height, baseResolutionPolicy);
Director::getInstance()->setViewport(); Director::getInstance()->setViewport();
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(GLViewImpl::EVENT_WINDOW_RESIZED, nullptr); 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<CGFloat>(fbWidth);
size.height = static_cast<CGFloat>(fbHeight);
[backend::DeviceMTL::getCAMetalLayer() setDrawableSize:size];
} }
} }