From 9dc32c854b3cdd1bbe7802352eaaa0ce938b2d41 Mon Sep 17 00:00:00 2001 From: Ano-sys Date: Sat, 15 Aug 2026 22:48:42 +0200 Subject: [PATCH] + made function that are not designed to be shared static - removed obsolete window_size_delta struct and helper func - marked on_wheel with attrib unused -> compiler would refuse compilation --- SimpleImageViewer.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/SimpleImageViewer.c b/SimpleImageViewer.c index 291606a..4756478 100644 --- a/SimpleImageViewer.c +++ b/SimpleImageViewer.c @@ -24,17 +24,12 @@ typedef struct Image{ SDL_Texture* texture; } Image; -typedef struct{ - int w; - int h; -} window_size_delta; - -static void error_exit(const char* msg){ +void error_exit(const char* msg){ printf("%s\n", msg); exit(-1); } -static void error_continue(const char* msg){ +void error_continue(const char* msg){ printf("%s\n", msg); } @@ -50,7 +45,7 @@ void free_image_pixels_buffer(Image* image){ image->pixels = NULL; } -SDL_Window* create_window(const char* title, int w, int h){ +static SDL_Window* create_window(const char* title, int w, int h){ const SDL_InitFlags init_flags = SDL_INIT_VIDEO | SDL_INIT_EVENTS; const SDL_WindowFlags window_flags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE; @@ -79,7 +74,7 @@ SDL_Window* create_window(const char* title, int w, int h){ return window; } -bool populate_image(SDL_Window* window, Image* image){ +static bool populate_image(SDL_Window* window, Image* image){ SDL_Surface* surface = SDL_GetWindowSurface(window); image->surface = SDL_CreateSurface(image->x, image->y, SDL_PIXELFORMAT_RGBA32); if(!image->surface) { @@ -121,7 +116,7 @@ bool populate_image(SDL_Window* window, Image* image){ return true; } -bool draw_image(SDL_Window* window, Image* image, float pixel_size_delta, int image_start_x, int image_start_y){ +static bool draw_image(SDL_Window* window, Image* image, float pixel_size_delta, int image_start_x, int image_start_y){ SDL_Surface* surface = SDL_GetWindowSurface(window); if(!surface){ error_continue("Failed to get window surface! Cleaning up and exiting..."); @@ -168,15 +163,7 @@ int clamp_low(const int in, const int low){ return in < low ? low : in; } -window_size_delta get_window_size_delta(SDL_Window* window, int new_w, int new_h){ - int last_w, last_h; - SDL_GetWindowSize(window, &last_w, &last_h); - - window_size_delta delta = {new_w - last_w, new_h - last_h}; - return delta; -} - -void on_wheel(SDL_Event* event, SDL_Window* window){ +static __attribute__((unused)) void on_wheel (SDL_Event* event, SDL_Window* window){ int last_w, last_h; SDL_GetWindowSize(window, &last_w, &last_h); @@ -198,7 +185,7 @@ void on_wheel(SDL_Event* event, SDL_Window* window){ SDL_SetWindowSize(window, new_w, new_h); } -void loop(SDL_Window* window, Image* image){ +static void loop(SDL_Window* window, Image* image){ bool drag_left_mouse = false; bool drag_right_mouse = false; int last_pointer_x = 0;