exit(3), don't crash, when glfwCreateWindow fails
glfwSetWindowPos was called on a NULL window, triggering an assert inside GLFW. Check for failure and exit cleanly by means of TraceLog(LOG_ERROR instead.
This commit is contained in:
parent
2b2b1f91ee
commit
44cd4faf83
1 changed files with 11 additions and 8 deletions
19
src/core.c
19
src/core.c
|
@ -1822,18 +1822,21 @@ static void InitGraphicsDevice(int width, int height)
|
||||||
// No-fullscreen window creation
|
// No-fullscreen window creation
|
||||||
window = glfwCreateWindow(screenWidth, screenHeight, windowTitle, NULL, NULL);
|
window = glfwCreateWindow(screenWidth, screenHeight, windowTitle, NULL, NULL);
|
||||||
|
|
||||||
|
if (window)
|
||||||
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
// Center window on screen
|
// Center window on screen
|
||||||
int windowPosX = displayWidth/2 - screenWidth/2;
|
int windowPosX = displayWidth/2 - screenWidth/2;
|
||||||
int windowPosY = displayHeight/2 - screenHeight/2;
|
int windowPosY = displayHeight/2 - screenHeight/2;
|
||||||
|
|
||||||
if (windowPosX < 0) windowPosX = 0;
|
if (windowPosX < 0) windowPosX = 0;
|
||||||
if (windowPosY < 0) windowPosY = 0;
|
if (windowPosY < 0) windowPosY = 0;
|
||||||
|
|
||||||
glfwSetWindowPos(window, windowPosX, windowPosY);
|
glfwSetWindowPos(window, windowPosX, windowPosY);
|
||||||
#endif
|
#endif
|
||||||
renderWidth = screenWidth;
|
renderWidth = screenWidth;
|
||||||
renderHeight = screenHeight;
|
renderHeight = screenHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue