From 99432aa171e9db0afa247e943a5b58095217faf4 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sun, 2 Aug 2020 16:48:19 +0800 Subject: [PATCH] Optimize param use. --- cocos/platform/desktop/CCGLViewImpl-desktop.cpp | 9 +++++---- cocos/platform/desktop/CCGLViewImpl-desktop.h | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp index 742644ccb1..cc9fbc3bf6 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp @@ -681,13 +681,14 @@ void GLViewImpl::setFullscreen(int monitorIndex, int w, int h, int refreshRate) void GLViewImpl::setFullscreen(GLFWmonitor *monitor, int w, int h, int refreshRate) { _monitor = monitor; - if (w == -1 || h == -1 || refreshRate == -1) - { - const GLFWvidmode* videoMode = glfwGetVideoMode(_monitor); + const GLFWvidmode* videoMode = glfwGetVideoMode(_monitor); + + if (w == -1) w = videoMode->width; + if (h == -1) h = videoMode->height; + if (refreshRate == -1) refreshRate = videoMode->refreshRate; - } glfwSetWindowMonitor(_mainWindow, _monitor, 0, 0, w, h, refreshRate); diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.h b/cocos/platform/desktop/CCGLViewImpl-desktop.h index b8cd6719df..8cefe6703a 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.h +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.h @@ -94,9 +94,9 @@ public: /// Sets monitor full screen with w*h(refresh rate) /// /// the 0 based index of monitor - /// the width of hardware resolution in full screen - /// the height of hardware resolution in full screen - /// the display refresh rate, usually 60 + /// the width of hardware resolution in full screen, -1 use default value + /// the height of hardware resolution in full screen, -1 use default value + /// the display refresh rate, usually 60, -1 use default value void setFullscreen(int monitorIndex, int w, int h, int refreshRate); /* for internal use */