#include "window.h"



/* Initializes a window; needs name, width, height, and flags. */
void
window_init(Window* self, char* name, ivec2 size, u32 flags)
{
	memset(self, '\0', sizeof(Window));

	glm_ivec2_copy(size, self->expectedSize);

	self->sdl = SDL_CreateWindow
	(
		name,
		SDL_WINDOWPOS_UNDEFINED,
		SDL_WINDOWPOS_UNDEFINED,
		size[0],
		size[1],
		flags
	);
}

/* Returns window size/viewport. */
void
window_ivec4_get(struct Window* self, ivec4 value)
{
	ivec2 size;

	window_size_get(self, size);

	value[0] = 0;
	value[1] = 0;
	value[2] = size[0];
	value[3] = size[1];
}

/* Returns window's size. */
void
window_size_get(Window* self, ivec2 size)
{
	SDL_GetWindowSize(self->sdl, &size[0], &size[1]);
}

/* Frees a given window. */
void
window_free(Window* self)
{
	SDL_DestroyWindow(self->sdl);
	
	memset(self, '\0', sizeof(Window));
}

