From 6ab047e30169ebf8f440d87dae68e0fdf6cc239f Mon Sep 17 00:00:00 2001 From: kdx Date: Thu, 11 May 2023 00:40:55 +0200 Subject: depreciate light system --- create_TZR.h.sh | 1 - headers/TZR.h | 2 +- headers/TZR_globals.h | 1 - headers/TZR_light.h | 11 ----------- headers/TZR_types.h | 2 +- main.c | 14 +------------- sources/TZR_DrawEnd.c | 8 -------- sources/TZR_Init.c | 27 ++++++++++++--------------- sources/TZR_LightBegin.c | 18 ------------------ sources/TZR_LightEnd.c | 8 -------- sources/TZR_Quit.c | 4 ---- sources/globals.c | 1 - 12 files changed, 15 insertions(+), 82 deletions(-) delete mode 100644 headers/TZR_light.h delete mode 100644 sources/TZR_LightBegin.c delete mode 100644 sources/TZR_LightEnd.c diff --git a/create_TZR.h.sh b/create_TZR.h.sh index 695ae42..85d2831 100755 --- a/create_TZR.h.sh +++ b/create_TZR.h.sh @@ -16,7 +16,6 @@ HEADER=TZR_resource ProcessHeader HEADER=TZR_sound ProcessHeader HEADER=TZR_events ProcessHeader HEADER=TZR_render ProcessHeader -HEADER=TZR_light ProcessHeader HEADER=TZR_keystate ProcessHeader HEADER=TZR ProcessHeader diff --git a/headers/TZR.h b/headers/TZR.h index 6c8fa9d..ac450ac 100644 --- a/headers/TZR.h +++ b/headers/TZR.h @@ -19,7 +19,7 @@ .show_cursor=false, \ .mixer=TZR_MIXER_ON, \ .png_loading=true, \ - .light_system=false, \ + .hd_render=false, \ .title="TZR", \ ._=0, __VA_ARGS__ }) diff --git a/headers/TZR_globals.h b/headers/TZR_globals.h index cfedc43..2406ff5 100644 --- a/headers/TZR_globals.h +++ b/headers/TZR_globals.h @@ -11,7 +11,6 @@ extern size_t ___tzr_resources_size; extern SDL_Window *___tzr_window; extern SDL_Renderer *___tzr_renderer; extern SDL_Texture *___tzr_target; -extern SDL_Texture *___tzr_target_light; extern unsigned long ___tzr_tick; extern unsigned long ___tzr_next_time; extern unsigned long ___tzr_min_dt; diff --git a/headers/TZR_light.h b/headers/TZR_light.h deleted file mode 100644 index 6d55944..0000000 --- a/headers/TZR_light.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#if __STDC_VERSION__ > 201710L -[[nodiscard]] -#endif -int TZR_LightBegin(void); - -#if __STDC_VERSION__ > 201710L -[[nodiscard]] -#endif -int TZR_LightEnd(void); diff --git a/headers/TZR_types.h b/headers/TZR_types.h index b9ec3eb..55a0d1d 100644 --- a/headers/TZR_types.h +++ b/headers/TZR_types.h @@ -54,10 +54,10 @@ struct TZR_Config { int scale; int target_fps; bool pixel_perfect; + bool hd_render; bool show_cursor; unsigned int mixer; bool png_loading; - bool light_system; const char *title; }; diff --git a/main.c b/main.c index dc2788d..e74d3cf 100644 --- a/main.c +++ b/main.c @@ -12,8 +12,7 @@ main(int argc, char **argv) (void)argc, (void)argv; /* Initialization. Arguments can be ommited. */ - if (TZR_Init(.width=256, .height=256, .pixel_perfect=false, - .light_system=true)) + if (TZR_Init(.width=256, .height=256, .pixel_perfect=false)) return 1; /* Call TZR_Quit on exit. */ @@ -63,17 +62,6 @@ main_loop(void *udata) if (TZR_IsKeyPressed(SDL_SCANCODE_SPACE)) TZR_PlaySound(id2); - if (TZR_LightBegin()) - return 1; - TZR_DrawSetColor(0.1f, 0.1f, 0.1f, 1.0f); - TZR_DrawClear(); - TZR_DrawSetColor(0.0f, 1.0f, 1.0f, 1.0f); - TZR_DrawRectangle(10, 10, 128, 64, .fill=true); - TZR_DrawSetColor(1.0f, 0.0f, 0.0f, 1.0f); - TZR_DrawRectangle(64, 30, 128, 64, .fill=true); - if (TZR_LightEnd()) - return 1; - if (TZR_DrawBegin() || TZR_DrawSetColor(0.0f, 0.0f, 0.0f) || TZR_DrawClear() diff --git a/sources/TZR_DrawEnd.c b/sources/TZR_DrawEnd.c index bc3ce95..d40120a 100644 --- a/sources/TZR_DrawEnd.c +++ b/sources/TZR_DrawEnd.c @@ -36,14 +36,6 @@ TZR_DrawEnd(void) if (SDL_RenderCopy(___tzr_renderer, ___tzr_target, NULL, &dest) < 0) return sdl_error(-1); - if (___tzr_config.light_system) { - if (SDL_SetTextureBlendMode(___tzr_target_light, - SDL_BLENDMODE_MOD) < 0) - return sdl_error(-1); - if (SDL_RenderCopy(___tzr_renderer, ___tzr_target_light, NULL, - &dest) < 0) - return sdl_error(-1); - } if (___tzr_config.target_fps > 0) { ___tzr_next_time += ___tzr_min_dt; diff --git a/sources/TZR_Init.c b/sources/TZR_Init.c index 25d0272..b6163c5 100644 --- a/sources/TZR_Init.c +++ b/sources/TZR_Init.c @@ -59,21 +59,18 @@ _TZR_Init(const TZR_Config *config) if (___tzr_renderer == NULL) return _sdl_error(); - ___tzr_target = SDL_CreateTexture(___tzr_renderer, - SDL_PIXELFORMAT_RGB888, - SDL_TEXTUREACCESS_TARGET, - ___tzr_config.width, - ___tzr_config.height); - if (___tzr_target == NULL) - return _sdl_error(); - - if (___tzr_config.light_system) { - ___tzr_target_light = SDL_CreateTexture(___tzr_renderer, - SDL_PIXELFORMAT_RGB888, - SDL_TEXTUREACCESS_TARGET, - ___tzr_config.width, - ___tzr_config.height); - if (___tzr_target_light == NULL) + if (___tzr_config.hd_render) { + if (SDL_RenderSetLogicalSize(___tzr_renderer, + ___tzr_config.width, + ___tzr_config.height) < 0) + return _sdl_error(); + } else { + ___tzr_target = SDL_CreateTexture(___tzr_renderer, + SDL_PIXELFORMAT_RGB888, + SDL_TEXTUREACCESS_TARGET, + ___tzr_config.width, + ___tzr_config.height); + if (___tzr_target == NULL) return _sdl_error(); } diff --git a/sources/TZR_LightBegin.c b/sources/TZR_LightBegin.c deleted file mode 100644 index 421d4c9..0000000 --- a/sources/TZR_LightBegin.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "TZR_light.h" -#include "TZR_globals.h" -#include "sdl_error.h" -#include - -int -TZR_LightBegin(void) -{ - if (!___tzr_config.light_system) { - fprintf(stderr, "light system disabled\n"); - return -1; - } - if (SDL_SetRenderDrawBlendMode(___tzr_renderer, SDL_BLENDMODE_ADD) < 0) - return sdl_error(-1); - if (SDL_SetRenderTarget(___tzr_renderer, ___tzr_target_light) < 0) - return sdl_error(-1); - return 0; -} diff --git a/sources/TZR_LightEnd.c b/sources/TZR_LightEnd.c deleted file mode 100644 index ae776b0..0000000 --- a/sources/TZR_LightEnd.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "TZR_light.h" -#include "TZR_globals.h" - -int -TZR_LightEnd(void) -{ - return ___tzr_config.light_system ? 0 : -1; -} diff --git a/sources/TZR_Quit.c b/sources/TZR_Quit.c index d316e2f..e11979e 100644 --- a/sources/TZR_Quit.c +++ b/sources/TZR_Quit.c @@ -14,10 +14,6 @@ TZR_Quit(void) ___tzr_resources = NULL; ___tzr_resources_size = 0; ___tzr_resources_capacity = 0; - if (___tzr_target_light != NULL) { - SDL_DestroyTexture(___tzr_target_light); - ___tzr_target_light = NULL; - } if (___tzr_target != NULL) { SDL_DestroyTexture(___tzr_target); ___tzr_target = NULL; diff --git a/sources/globals.c b/sources/globals.c index 02f9181..0833d28 100644 --- a/sources/globals.c +++ b/sources/globals.c @@ -11,7 +11,6 @@ size_t ___tzr_resources_size = 0; SDL_Window *___tzr_window = NULL; SDL_Renderer *___tzr_renderer = NULL; SDL_Texture *___tzr_target = NULL; -SDL_Texture *___tzr_target_light = NULL; unsigned long ___tzr_tick = 0; unsigned long ___tzr_next_time = 0; unsigned long ___tzr_min_dt = 0; -- cgit v1.2.3