YAGE  0.02
Yet Another Game Engine
camera2d.hpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * camera2d.hpp
3  *
4  * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
5  * MIT License, see LICENSE file for more details.
6  * ----------------------------------------------------------------------------
7  */
8 
9 #ifndef CAMERA_2D_HPP
10 #define CAMERA_2D_HPP
11 
12 #include "glslprogram.hpp"
13 
14 #include <glm/glm.hpp>
15 #include <glm/gtc/matrix_transform.hpp>
16 
17 namespace yage {
18 
19 class Camera2D {
20 private:
21  bool matrix_needs_update_ = true;
22  float scale_ = 1;
23  glm::vec2 position_;
24  glm::mat4 camera_matrix_;
25  glm::mat4 ortho_matrix_;
26 
27 public:
28  Camera2D(int screen_width = 1280, int screen_height = 720);
29 
30  // update camera location
31  void update(GlslProgram& program);
32  // camera movement
33  void move(const glm::vec2& direction);
34 };
35 
36 } // yage
37 
38 #endif
glm::mat4 ortho_matrix_
Definition: camera2d.hpp:25
float scale_
Definition: camera2d.hpp:22
bool matrix_needs_update_
Definition: camera2d.hpp:21
glm::mat4 camera_matrix_
Definition: camera2d.hpp:24
void update(GlslProgram &program)
Definition: camera2d.cpp:21
Definition: glslprogram.hpp:18
glm::vec2 position_
Definition: camera2d.hpp:23
Definition: camera2d.hpp:19
Templated matrix class.
Definition: camera2d.hpp:17
void move(const glm::vec2 &direction)
Definition: camera2d.cpp:36
Camera2D(int screen_width=1280, int screen_height=720)
Definition: camera2d.cpp:15