diff options
Diffstat (limited to 'lzr.c')
-rw-r--r-- | lzr.c | 33 |
1 files changed, 13 insertions, 20 deletions
@@ -1,7 +1,6 @@ /* Licensing information can be found at the end of the file. */ #include "lzr.h" #include <SDL2/SDL.h> -#include <SDL2/SDL_error.h> #ifdef LZR_ENABLE_GFX # include <SDL2/SDL2_gfxPrimitives.h> #endif @@ -169,21 +168,15 @@ exit_bind_menu: SDL_Log("leaving bind menu"); } -static void _LZR_ErrorBox(const char *msg, SDL_Window *win) -{ - if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "LZR", msg, win)) - SDL_Log("%s (%s)", msg, SDL_GetError()); -} - int LZR_Init(LZR_Config cfg) { memcpy(&config, &cfg, sizeof(config)); if (config.display_width == 0) { - _LZR_ErrorBox("display_width can't be 0", NULL); + SDL_Log("display_width can't be 0"); return -1; } if (config.display_height == 0) { - _LZR_ErrorBox("display_height can't be 0", NULL); + SDL_Log("display_height can't be 0"); return -1; } if (config.title == NULL) { @@ -200,19 +193,19 @@ int LZR_Init(LZR_Config cfg) config.ratio /= ratio; } if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { - _LZR_ErrorBox(SDL_GetError(), NULL); + SDL_Log("%s", SDL_GetError()); return -1; } #ifdef LZR_ENABLE_IMAGE if (IMG_Init(IMG_INIT_PNG) != IMG_INIT_PNG) { - _LZR_ErrorBox(SDL_GetError(), NULL); + SDL_Log("%s", IMG_GetError()); return -1; } #endif #ifdef LZR_ENABLE_MIXER audio_mutex = SDL_CreateMutex(); if (audio_mutex == NULL) { - _LZR_ErrorBox(SDL_GetError(), NULL); + SDL_Log("%s", SDL_GetError()); return -1; } SDL_AudioSpec fmt = {.freq = 44100, @@ -224,7 +217,7 @@ int LZR_Init(LZR_Config cfg) audio_dev = SDL_OpenAudioDevice(NULL, 0, &fmt, &got, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE); if (audio_dev == 0) { - _LZR_ErrorBox(SDL_GetError(), NULL); + SDL_Log("%s", SDL_GetError()); return -1; } cm_init(44100); @@ -233,7 +226,7 @@ int LZR_Init(LZR_Config cfg) #endif basepath = SDL_GetBasePath(); if (basepath == NULL) { - _LZR_ErrorBox(SDL_GetError(), NULL); + SDL_Log("%s", SDL_GetError()); return -1; } const int dwidth = config.display_width * config.ratio; @@ -241,25 +234,25 @@ int LZR_Init(LZR_Config cfg) SDL_WINDOWPOS_UNDEFINED, dwidth, config.display_height, SDL_WINDOW_RESIZABLE); if (window == NULL) { - _LZR_ErrorBox(SDL_GetError(), NULL); + SDL_Log("%s", SDL_GetError()); return -1; } renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); if (renderer == NULL) { - _LZR_ErrorBox(SDL_GetError(), window); + SDL_Log("%s", SDL_GetError()); return -1; } target = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, config.display_width, config.display_height); if (target == NULL) { - _LZR_ErrorBox(SDL_GetError(), window); + SDL_Log("%s", SDL_GetError()); return -1; } points = calloc(cfg.display_width * cfg.display_height, sizeof(SDL_Point)); if (points == NULL) { - _LZR_ErrorBox("calloc failed", window); + SDL_Log("calloc failed"); return -1; } SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, 0); @@ -268,7 +261,7 @@ int LZR_Init(LZR_Config cfg) next_time = SDL_GetTicks64(); } if (config.hide_cursor && SDL_ShowCursor(SDL_DISABLE) < 0) { - _LZR_ErrorBox(SDL_GetError(), window); + SDL_Log("%s", SDL_GetError()); return -1; } if (LZR_DrawSetColor(1.0f, 1.0f, 1.0f, 1.0f)) @@ -615,7 +608,7 @@ int LZR_DrawSetColor(float r, float g, float b, float a) const unsigned int ub = (unsigned int)(b * 255) & 255; const unsigned int ua = (unsigned int)(a * 255) & 255; if (SDL_SetRenderDrawColor(renderer, ur, ug, ub, ua) < 0) { - _LZR_ErrorBox(SDL_GetError(), window); + SDL_Log("%s", SDL_GetError()); return -1; } color[0] = ur, color[1] = ug, color[2] = ub, color[3] = ua; |