diff options
author | TravisBot <> | 2017-09-21 23:52:57 +0000 |
---|---|---|
committer | TravisBot <> | 2017-09-21 23:52:57 +0000 |
commit | 43d8d9b5de8f269643c380d8d6c6c65d9224ad4a (patch) | |
tree | b8a9546cb663081e4587f812fa49a228be9978e5 /yage/base/camera2d.cpp | |
parent | ad666428488d3c800ca18d877dad803bf18b8168 (diff) | |
download | YAGE-43d8d9b5de8f269643c380d8d6c6c65d9224ad4a.tar.gz YAGE-43d8d9b5de8f269643c380d8d6c6c65d9224ad4a.zip |
Rebuilding documentation
Diffstat (limited to 'yage/base/camera2d.cpp')
-rw-r--r-- | yage/base/camera2d.cpp | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/yage/base/camera2d.cpp b/yage/base/camera2d.cpp deleted file mode 100644 index 9eda38ee..00000000 --- a/yage/base/camera2d.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* ---------------------------------------------------------------------------- - * camera2d.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License - * See file LICENSE for more details - * ---------------------------------------------------------------------------- - */ - -#include "camera2d.h" - -#include <glad/glad.h> - -namespace yage -{ - -Camera2D::Camera2D(int screen_width, int screen_height) - : position_(0.f, 0.f), camera_matrix_(1.f), - ortho_matrix_( - glm::ortho(0.f, (float)screen_width, 0.f, (float)screen_height)) -{ -} - -void Camera2D::update(GlslProgram &program) -{ - if (update_matrix_) { - glm::vec3 translate(-position_.x, -position_.y, 0.f); - glm::vec3 scale(scale_, scale_, 0.f); - - camera_matrix_ = glm::translate(ortho_matrix_, translate); - camera_matrix_ = glm::scale(glm::mat4(1.f), scale) * camera_matrix_; - - update_matrix_ = false; - } - - GLint matrix_location = program.getUniformLocation("P"); - glUniformMatrix4fv(matrix_location, 1, GL_FALSE, &(camera_matrix_[0][0])); -} - -void Camera2D::move(const glm::vec2 &direction) -{ - position_ += direction; - update_matrix_ = true; -} - -} // namespace yage |