#include "camera.h"

/* Initialize orthographic camera. */
void
camera_orthographic_init(Camera* self, vec2 size)
{
	memset(self, '\0', sizeof(Camera));

	self->type = CAMERA_ORTHOGRAPHIC;
	glm_vec2_copy(size, self->orthographic.size);
}

/* Returns view matrix of camera. */
void
camera_view_get(Camera* self, mat4 view)
{
	glm_mat4_identity(view);

	switch (self->type)
	{
		case CAMERA_ORTHOGRAPHIC:
			glm_mat4_identity(view);
			break;
		default:
			break;
	}
}

/* Gets projection of camera. */
void
camera_projection_get(Camera* self, mat4 projection)
{
	glm_mat4_identity(projection);

	switch (self->type)
	{
		case CAMERA_ORTHOGRAPHIC:
			glm_ortho
			(
				0.0f,
				self->orthographic.size[0], 
				self->orthographic.size[1], 
				0.0f, 
				CAMERA_ORTHOGRAPHIC_NEAR, 
				CAMERA_ORTHOGRAPHIC_FAR,
				projection
			);
			break;
		default:
			break;
	}
}

/* Sets the camera to a position. */
void
camera_position_set(Camera* self, vec3 position)
{
	glm_vec3_copy(position, self->position);
}

/* Sets an orthographic camera's size to a window's. */
void
camera_orthographic_window_set(Camera* self, Window* window)
{
	ivec2 size;

	window_size_get(window, size);

	self->orthographic.size[0] = (f32)size[0];
	self->orthographic.size[1] = (f32)size[1];
}
