Make it so Backend_Init can fail

This commit is contained in:
Clownacy 2020-04-07 17:46:02 +01:00
parent 7d65d009ff
commit 41d5c5b5c8
4 changed files with 25 additions and 13 deletions

View file

@ -150,9 +150,12 @@ static void DragAndDropCallback(GLFWwindow *window, int count, const char **path
LoadProfile(paths[0]); LoadProfile(paths[0]);
} }
void Backend_Init(void) BOOL Backend_Init(void)
{ {
glfwInit(); if (glfwInit() == GL_TRUE)
return TRUE;
else
return FALSE;
} }
void Backend_Deinit(void) void Backend_Deinit(void)

View file

@ -85,7 +85,7 @@ enum
extern BOOL bActive; extern BOOL bActive;
void Backend_Init(void); BOOL Backend_Init(void);
void Backend_Deinit(void); void Backend_Deinit(void);
void Backend_PostWindowCreation(void); void Backend_PostWindowCreation(void);
BOOL Backend_GetBasePath(char *string_buffer); BOOL Backend_GetBasePath(char *string_buffer);

View file

@ -30,12 +30,12 @@ static unsigned char *cursor_surface_pixels;
static SDL_Surface *cursor_surface; static SDL_Surface *cursor_surface;
static SDL_Cursor *cursor; static SDL_Cursor *cursor;
void Backend_Init(void) BOOL Backend_Init(void)
{ {
SDL_Init(SDL_INIT_EVENTS); if (SDL_Init(SDL_INIT_EVENTS) == 0)
{
SDL_InitSubSystem(SDL_INIT_VIDEO); if (SDL_InitSubSystem(SDL_INIT_VIDEO) == 0)
{
puts("Available SDL2 video drivers:"); puts("Available SDL2 video drivers:");
for (int i = 0; i < SDL_GetNumVideoDrivers(); ++i) for (int i = 0; i < SDL_GetNumVideoDrivers(); ++i)
@ -45,6 +45,14 @@ void Backend_Init(void)
if (driver != NULL) if (driver != NULL)
printf("Selected SDL2 video driver: %s\n", driver); printf("Selected SDL2 video driver: %s\n", driver);
return TRUE;
}
SDL_Quit();
}
return FALSE;
} }
void Backend_Deinit(void) void Backend_Deinit(void)

View file

@ -88,7 +88,8 @@ int main(int argc, char *argv[])
int i; int i;
Backend_Init(); if (!Backend_Init())
return EXIT_FAILURE;
// Get executable's path // Get executable's path
if (!Backend_GetBasePath(gModulePath)) if (!Backend_GetBasePath(gModulePath))