mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Abort and print error if window/renderer cannot be created
This aborts and prints the error from SDL_GetError() if SDL_CreateWindow() or SDL_CreateRenderer() fails. We abort because there's not much point in continuing if the window or renderer can't be created. There might be a use case for running the game in headless mode, but let's code that in explicitly if we ever want it.
This commit is contained in:
parent
2525017990
commit
fbe613ce5c
1 changed files with 13 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "Alloc.h"
|
||||
#include "Constants.h"
|
||||
#include "Exit.h"
|
||||
#include "FileSystemUtils.h"
|
||||
#include "Game.h"
|
||||
#include "Graphics.h"
|
||||
|
@ -56,8 +57,20 @@ void Screen::init(const struct ScreenSettings* settings)
|
|||
SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI
|
||||
);
|
||||
|
||||
if (m_window == NULL)
|
||||
{
|
||||
vlog_error("Could not create window: %s", SDL_GetError());
|
||||
VVV_exit(1);
|
||||
}
|
||||
|
||||
m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
|
||||
if (m_renderer == NULL)
|
||||
{
|
||||
vlog_error("Could not create renderer: %s", SDL_GetError());
|
||||
VVV_exit(1);
|
||||
}
|
||||
|
||||
#ifdef INTERIM_VERSION_EXISTS
|
||||
/* Branch name limits are ill-defined but on GitHub it's ~256 chars
|
||||
* ( https://stackoverflow.com/a/24014513/ ).
|
||||
|
|
Loading…
Reference in a new issue