#include <stdbool.h>


#include <SDL3/SDL.h>


struct app {
	int win_w;
	int win_h;
	SDL_Window *win;
	SDL_Renderer *ren;
	bool running;
};

int
main(int argc, char *argv[])
{
	struct app app = {0};

	app.win_w = 800;
	app.win_h = 600;
	app.running = true;

	SDL_Init(SDL_INIT_VIDEO);

	SDL_CreateWindowAndRenderer("Title", app.win_w, app.win_h, 0, &app.win, &app.ren);

	while ( app.running ) {
		SDL_Event e;

event_loop:
		if ( ! SDL_PollEvent(&e) ) {
			goto event_loop_out;
		}
		switch( e.type ) {
		case SDL_EVENT_QUIT: 
			app.running = false;
			goto event_loop_out;
		}
		goto event_loop;
event_loop_out:	;
		
		SDL_SetRenderDrawColor(app.ren, 0xFF, 0, 0, 0xFF);
		SDL_RenderClear(app.ren);

		{
			SDL_FRect rect = {0, 0, 10, 10};
			rect.x = (((float)app.win_w) - rect.w) / 2.0f;
			rect.y = (((float)app.win_h) - rect.h) / 2.0f;

			SDL_SetRenderDrawColor(app.ren, 0x00, 0xFF, 0, 0xFF);
			SDL_RenderFillRect(app.ren, &rect);
		}


		SDL_RenderPresent(app.ren);
	}

	SDL_DestroyWindow(app.win);
	SDL_DestroyRenderer(app.ren);

	SDL_Quit();
	(void) argc; (void) argv;
	return 0;
}
