#include "Camera.h"

#include <glm/gtc/matrix_transform.hpp>

void OrtographicCamera::setPosition(glm::vec2 position) {
    this->cameraPos = position;
}

glm::vec2 OrtographicCamera::getPosition() {
    return this->cameraPos;
}

void OrtographicCamera::setZoomLevel(float newZoom) {
    this->zoom = newZoom;
}

void OrtographicCamera::zoomIn(float targetZoom) {
    zoom -= targetZoom;
}

void OrtographicCamera::translate(glm::vec2 target) {
    cameraPos = cameraPos - target;
}

void OrtographicCamera::smoothTranslate(glm::vec2 target) {

}

glm::mat4 OrtographicCamera::getViewMatrix() {
    glm::mat4 view(1);
    view = glm::translate(view, glm::vec3(-cameraPos,0.f));
    return view;
}

glm::mat4 OrtographicCamera::getProjectionMatrix() {
    //Dies gibt die Größe des kamera auschnittes an die in die welt zeigt (Frustum)
    int width = 800;
    int height = 600;
    int DPI = 2; // 200% windows settings
    glm::mat4 projection;
    projection = glm::ortho(0.0f, (width/DPI)*this->zoom, 0.0f, (height/DPI)*this->zoom);
    return projection;
}

glm::mat4 OrtographicCamera::getCombinedMatrix() {
    glm::mat4 combined;
    combined = getProjectionMatrix() * getViewMatrix();
    return combined;
}

void OrtographicCamera::update() {
    
}