+ 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
This commit is contained in:
+7
-20
@@ -24,17 +24,12 @@ typedef struct Image{
|
|||||||
SDL_Texture* texture;
|
SDL_Texture* texture;
|
||||||
} Image;
|
} Image;
|
||||||
|
|
||||||
typedef struct{
|
void error_exit(const char* msg){
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
} window_size_delta;
|
|
||||||
|
|
||||||
static void error_exit(const char* msg){
|
|
||||||
printf("%s\n", msg);
|
printf("%s\n", msg);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_continue(const char* msg){
|
void error_continue(const char* msg){
|
||||||
printf("%s\n", msg);
|
printf("%s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +45,7 @@ void free_image_pixels_buffer(Image* image){
|
|||||||
image->pixels = NULL;
|
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_InitFlags init_flags = SDL_INIT_VIDEO | SDL_INIT_EVENTS;
|
||||||
const SDL_WindowFlags window_flags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE;
|
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;
|
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);
|
SDL_Surface* surface = SDL_GetWindowSurface(window);
|
||||||
image->surface = SDL_CreateSurface(image->x, image->y, SDL_PIXELFORMAT_RGBA32);
|
image->surface = SDL_CreateSurface(image->x, image->y, SDL_PIXELFORMAT_RGBA32);
|
||||||
if(!image->surface) {
|
if(!image->surface) {
|
||||||
@@ -121,7 +116,7 @@ bool populate_image(SDL_Window* window, Image* image){
|
|||||||
return true;
|
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);
|
SDL_Surface* surface = SDL_GetWindowSurface(window);
|
||||||
if(!surface){
|
if(!surface){
|
||||||
error_continue("Failed to get window surface! Cleaning up and exiting...");
|
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;
|
return in < low ? low : in;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_size_delta get_window_size_delta(SDL_Window* window, int new_w, int new_h){
|
static __attribute__((unused)) void on_wheel (SDL_Event* event, SDL_Window* window){
|
||||||
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){
|
|
||||||
int last_w, last_h;
|
int last_w, last_h;
|
||||||
SDL_GetWindowSize(window, &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);
|
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_left_mouse = false;
|
||||||
bool drag_right_mouse = false;
|
bool drag_right_mouse = false;
|
||||||
int last_pointer_x = 0;
|
int last_pointer_x = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user