-
Notifications
You must be signed in to change notification settings - Fork 2
/
Camera2D.h
36 lines (28 loc) · 860 Bytes
/
Camera2D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <glm\glm.hpp>
#include <glm\gtc\matrix_transform.hpp>
namespace NeroEngine{
class Camera2D
{
public:
Camera2D();
void update();
void init(int screenWidth,int screenHeight);
void setScale(float newScale){ _scale = newScale; _needsMatrixUpdate = true; }
void setPosition(const glm::vec2 newPosition){ _position = newPosition; _needsMatrixUpdate = true; }
glm::vec2 convertScreenToWorld(glm::vec2 screenCoords);
bool isBoxiInView(const glm::vec2& position,const glm::vec2& dimensions);
float getScale(){ return _scale; }
glm::vec2 getPosition(){ return _position; }
glm::mat4 getCameraMatrix(){ return _cameraMatrix; }
~Camera2D();
private:
int _screenWidth;
int _screenHeight;
bool _needsMatrixUpdate;
float _scale;
glm::vec2 _position;
glm::mat4 _cameraMatrix;
glm::mat4 _orthoMatrix;
};
}