aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kdx@42l.fr>2023-01-23 01:18:47 +0100
committerkdx <kdx@42l.fr>2023-01-23 01:18:47 +0100
commit690720a2dcc42d8860ae4c6ee09dee8c4803a2a5 (patch)
tree5945a22ddb92764ec3d8ac98fc6a783dc8deaad7
parent11f6a2c707e8913e8c233b99dec1532dbb3766a0 (diff)
downloadlzr-690720a2dcc42d8860ae4c6ee09dee8c4803a2a5.tar.gz
Revert "show errors in message box"
This reverts commit 11f6a2c707e8913e8c233b99dec1532dbb3766a0.
-rw-r--r--.gitignore2
-rw-r--r--Makefile5
-rw-r--r--lzr.c33
3 files changed, 15 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 8912a72..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-lzr
-*.o
diff --git a/Makefile b/Makefile
index 1772a7c..506beaf 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,9 @@
CC := gcc
LD := $(CC)
CFLAGS := -Wall -Wextra -std=c99 -pedantic \
- -DLZR_DISABLE_IMAGE -DLZR_DISABLE_MIXER \
- $(shell sdl2-config --cflags)
+ -D_POSIX_C_SOURCE=200809L $(shell sdl2-config --cflags)
# -D_POSIX_C_SOURCE is only used by DEVMODE
-LDFLAGS := $(shell sdl2-config --libs) -lSDL2_gfx
+LDFLAGS := $(shell sdl2-config --libs) -lSDL2_gfx -lSDL2_image
SRC := $(wildcard *.c)
OBJ := $(patsubst %.c,%.o,$(SRC))
NAME := lzr
diff --git a/lzr.c b/lzr.c
index 7652b49..89ef073 100644
--- a/lzr.c
+++ b/lzr.c
@@ -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;