diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-09-22 01:20:42 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-09-22 01:24:28 -0700 |
commit | 941256e3cbd62a0cf88641c8e865b26b8e3fcd32 (patch) | |
tree | 4334fcbae300044dd9de2935a5b6846c3acea7fe /src | |
parent | f8d142c8c03faadff939846a1acb35be4588b453 (diff) |
pig: remove vestigial helpers
These came from my game boilerplate I bootstrapped pig from.
If pig becomes more interactive with the need for things like
mapping mouse movement and clicks into NDC space these can be
restored.
Diffstat (limited to 'src')
-rw-r--r-- | src/pig.c | 100 | ||||
-rw-r--r-- | src/pig.h | 9 |
2 files changed, 1 insertions, 108 deletions
@@ -45,104 +45,6 @@ static inline float randf(void) } -void pig_canvas_size(pig_t *pig, int *res_width, int *res_height) -{ - assert(pig); - assert(res_width); - assert(res_height); - - SDL_GL_GetDrawableSize(pig->window, res_width, res_height); -} - - -void pig_canvas_to_ndc(pig_t *pig, int x, int y, float *res_x, float *res_y) -{ - int w, h; - - assert(pig); - assert(res_x); - assert(res_y); - - pig_canvas_size(pig, &w, &h); - - *res_x = (float)x / (float)w * 2.f - 1.f; - *res_y = (1.f - (float)y / (float)h) * 2.f - 1.f; -} - - -void pig_canvas_from_ndc(pig_t *pig, float x, float y, int *res_x, int *res_y) -{ - int w, h; - - assert(pig); - assert(res_x); - assert(res_y); - - pig_canvas_size(pig, &w, &h); - - *res_x = roundf(x * (float)w * .5f + .5f * (float)w); - *res_y = roundf(y * (float)h * .5f + .5f * (float)h); -} - - -void pig_viewport_size(pig_t *pig, int *res_width, int *res_height) -{ - assert(pig); - assert(res_width); - assert(res_height); - - SDL_GetWindowSize(pig->window, res_width, res_height); -} - - -void pig_viewport_to_ndc(pig_t *pig, int x, int y, float *res_x, float *res_y) -{ - int w, h; - - assert(pig); - assert(res_x); - assert(res_y); - - pig_viewport_size(pig, &w, &h); - - *res_x = (float)x / (float)w * 2.f - 1.f; - *res_y = (1.f - (float)y / (float)h) * 2.f - 1.f; -} - - -void pig_viewport_from_ndc(pig_t *pig, float x, float y, int *res_x, int *res_y) -{ - int w, h; - - assert(pig); - assert(res_x); - assert(res_y); - - pig_viewport_size(pig, &w, &h); - - *res_x = roundf(x * (float)w * .5f + .5f * (float)w); - *res_y = roundf(y * (float)h * .5f + .5f * (float)h); -} - - -uint32_t pig_viewport_id(pig_t *pig) -{ - return SDL_GetWindowID(pig->window); -} - - -void pig_toggle_fullscreen(pig_t *pig) -{ - if (pig->windowed) { - if (!SDL_SetWindowFullscreen(pig->window, SDL_WINDOW_FULLSCREEN_DESKTOP)) - pig->windowed = 0; - } else { - if (!SDL_SetWindowFullscreen(pig->window, 0)) - pig->windowed = 1; - } -} - - static void randomize_color(v3f_t *color) { color->x = randf(); @@ -359,7 +261,7 @@ static void pig_dispatch(play_t *play, void *context, SDL_Event *event) /* on highdpi the window size and pixels are decoupled, so ignore what * the event contains and query the canvas size. */ - pig_canvas_size(pig, &w, &h); + SDL_GL_GetDrawableSize(pig->window, &w, &h); glViewport(0, 0, w, h); stage_dirty(pig->stage); } @@ -35,13 +35,4 @@ typedef struct pig_t { v3f_t color; } pig_t; -void pig_canvas_size(pig_t *pig, int *res_width, int *res_height); -void pig_canvas_to_ndc(pig_t *pig, int x, int y, float *res_x, float *res_y); -void pig_canvas_from_ndc(pig_t *pig, float x, float y, int *res_x, int *res_y); -void pig_viewport_size(pig_t *pig, int *res_width, int *res_height); -void pig_viewport_to_ndc(pig_t *pig, int x, int y, float *res_x, float *res_y); -void pig_viewport_from_ndc(pig_t *pig, float x, float y, int *res_x, int *res_y); -uint32_t pig_viewport_id(pig_t *pig); -void pig_toggle_fullscreen(pig_t *pig); - #endif |