diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp index e35894bf43..aa8f3a28b1 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.cpp +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.cpp @@ -37,6 +37,7 @@ THE SOFTWARE. #include "base/ccUtils.h" #include "base/ccUTF8.h" #include "2d/CCCamera.h" +#include "deprecated/CCString.h" NS_CC_BEGIN @@ -358,6 +359,19 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram _mainWindow = glfwCreateWindow(needWidth, neeHeight, _viewName.c_str(), _monitor, nullptr); + if (_mainWindow == nullptr) + { + std::string message = "Can't create window"; + if (!_glfwError.empty()) + { + message.append("\nMore info: \n"); + message.append(_glfwError); + } + + MessageBox(message.c_str(), "Error launch application"); + return false; + } + /* * Note that the created window and context may differ from what you requested, * as not all parameters and hints are @@ -600,7 +614,8 @@ Rect GLViewImpl::getScissorRect() const void GLViewImpl::onGLFWError(int errorID, const char* errorDesc) { - CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc); + _glfwError = StringUtils::format("GLFWError #%d Happen, %s", errorID, errorDesc); + CCLOGERROR(_glfwError.c_str()); } void GLViewImpl::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify) diff --git a/cocos/platform/desktop/CCGLViewImpl-desktop.h b/cocos/platform/desktop/CCGLViewImpl-desktop.h index 8cf63d51a0..0d4abc052e 100644 --- a/cocos/platform/desktop/CCGLViewImpl-desktop.h +++ b/cocos/platform/desktop/CCGLViewImpl-desktop.h @@ -146,6 +146,8 @@ protected: GLFWwindow* _mainWindow; GLFWmonitor* _monitor; + std::string _glfwError; + float _mouseX; float _mouseY;