diff options
| author | Ahmad Fatoum <ahmad@a3f.at> | 2018-02-03 14:40:57 +0100 |
|---|---|---|
| committer | Ahmad Fatoum <ahmad@a3f.at> | 2018-02-03 14:46:26 +0100 |
| commit | 44cd4faf83666d545d6a9424128c5926e5cfdcef (patch) | |
| tree | ce3279ab57e96afd42b32cd4eb6e78174cfd10f6 /src | |
| parent | 2b2b1f91ee3a486280ef6c3704b1772b544a466b (diff) | |
| download | raylib-44cd4faf83666d545d6a9424128c5926e5cfdcef.tar.gz raylib-44cd4faf83666d545d6a9424128c5926e5cfdcef.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -1822,18 +1822,21 @@ static void InitGraphicsDevice(int width, int height) // No-fullscreen window creation window = glfwCreateWindow(screenWidth, screenHeight, windowTitle, NULL, NULL); + if (window) + { #if defined(PLATFORM_DESKTOP) - // Center window on screen - int windowPosX = displayWidth/2 - screenWidth/2; - int windowPosY = displayHeight/2 - screenHeight/2; + // Center window on screen + int windowPosX = displayWidth/2 - screenWidth/2; + int windowPosY = displayHeight/2 - screenHeight/2; - if (windowPosX < 0) windowPosX = 0; - if (windowPosY < 0) windowPosY = 0; + if (windowPosX < 0) windowPosX = 0; + if (windowPosY < 0) windowPosY = 0; - glfwSetWindowPos(window, windowPosX, windowPosY); + glfwSetWindowPos(window, windowPosX, windowPosY); #endif - renderWidth = screenWidth; - renderHeight = screenHeight; + renderWidth = screenWidth; + renderHeight = screenHeight; + } } if (!window) |
