Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
camera2d.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <glm/glm.hpp>
4 #include <glm/gtc/matrix_transform.hpp>
5 
6 namespace fireworks { namespace graphics {
7 
11  class Camera2D // aka Orthographic Camera
12  {
13  private:
14  glm::vec3 m_Position;
15  float m_Rotation = 0.0f;
16 
17  glm::mat4 m_ProjectionMatrix;
18  glm::mat4 m_ViewMatrix;
19  glm::mat4 m_ViewProjectionMatrix;
20  public:
24  Camera2D(glm::mat4 projection);
25 
27  void update();
28 
32  void setPosition(const glm::vec3& pos) { m_Position = pos; updateViewMatrix(); }
36  void setRotaion(float rot) { m_Rotation = rot; updateViewMatrix(); }
37 
39  const glm::vec3& getPosition() const { return m_Position; }
41  const float getRotation() const { return m_Rotation; }
42 
44  const glm::mat4& getProjectionMatrix() const { return m_ProjectionMatrix; }
46  const glm::mat4& getViewMatrix() const { return m_ViewMatrix; }
48  const glm::mat4& getProjectionViewMatrix() const { return m_ViewProjectionMatrix; }
49  private:
50  void updateViewMatrix();
51  };
52 
53 
54 } }
void update()
Updates the camera.
Definition: camera2d.cpp:11
const glm::mat4 & getProjectionViewMatrix() const
Gets the View * Projection matrix.
Definition: camera2d.h:48
Camera2D(glm::mat4 projection)
Creates a camera by taking in a projection matrix.
Definition: camera2d.cpp:5
void setRotaion(float rot)
Sets the rotation of the camera.
Definition: camera2d.h:36
const glm::mat4 & getViewMatrix() const
Gets the view matrix of the camera.
Definition: camera2d.h:46
Definition: audioclip.cpp:3
const glm::vec3 & getPosition() const
Gets the position of the camera in the world.
Definition: camera2d.h:39
const glm::mat4 & getProjectionMatrix() const
Gets the projection matrix with which the camera is rendering the scene.
Definition: camera2d.h:44
The eye of the 2D world.
Definition: camera2d.h:11
void setPosition(const glm::vec3 &pos)
Sets the position of the camera.
Definition: camera2d.h:32
const float getRotation() const
Gets the rotation of the camera in the world.
Definition: camera2d.h:41