Files
punchie-engine/include/Window.h
T
2022-10-02 02:16:28 +01:00

53 lines
1.3 KiB
C

#ifndef WINDOW_H
#define WINDOW_H
#include "Renderer.h"
#include "SDL.h"
#include "SDL_pixels.h"
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif // !__cplusplus
typedef struct window_size {
int32_t width;
int32_t height;
} WindowSize;
typedef struct drawing_area {
float x;
float y;
float width;
float height;
} WindowDrawingArea;
typedef struct window {
// We need to store the defined size because the coordinates of the mouse
// cursor are calculated according to it. In the case of displays that support
// high DPI, this creates a problem, because the mouse coordinates retrieved
// from an SDL_Event won't work with the actual window size. By storing the
// defined size of the window, this allows us to convert the mouse coordinates
// to a ratio of the defined size, then multiply that ratio by the real size.
WindowSize defined_size;
WindowSize real_size;
WindowDrawingArea drawing_area;
Renderer *renderer;
SDL_Window *SDL_base_window;
SDL_Color background_color;
bool full_screen;
} Window;
bool init_window(Window *wnd, const char *title, WindowSize size,
SDL_Color color, bool full_screen);
void clear_window(const Window *wnd);
void swap_render_buffers(const Window *wnd);
void destroy_window(Window *wnd);
#ifdef __cplusplus
}
#endif // !__cplusplus
#endif // !WINDOW_H