67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
/*
|
|
* Renderer.h
|
|
*
|
|
* Created on: 4 nov. 2020
|
|
* Author: simon
|
|
*/
|
|
|
|
#ifndef RENDER_RENDERER_H_
|
|
#define RENDER_RENDERER_H_
|
|
|
|
#include <glm/glm.hpp>
|
|
#include <memory>
|
|
#include "loader/GLLoader.h"
|
|
#include "render/shaders/WorldShader.h"
|
|
#include "render/shaders/EntityShader.h"
|
|
|
|
namespace td {
|
|
namespace render {
|
|
|
|
class Renderer {
|
|
public:
|
|
static constexpr float m_AnimationSpeed = 2.0f;
|
|
|
|
struct Model {
|
|
GL::VertexArray* vao;
|
|
glm::vec2 positon;
|
|
};
|
|
private:
|
|
std::unique_ptr<WorldShader> m_WorldShader;
|
|
std::unique_ptr<EntityShader> m_EntityShader;
|
|
|
|
glm::vec3 m_BackgroundColor;
|
|
|
|
bool m_IsometricView = true;
|
|
float m_IsometricShade = m_IsometricView;
|
|
glm::vec2 m_CamPos{};
|
|
public:
|
|
Renderer();
|
|
~Renderer();
|
|
|
|
bool init();
|
|
|
|
void prepare();
|
|
void resize(const int width, const int height);
|
|
|
|
void renderVAO(const GL::VertexArray& vao);
|
|
void renderModel(const Model& model);
|
|
|
|
void setZoom(float zoom);
|
|
void setCamMovement(const glm::vec2& mov);
|
|
void setCamPos(const glm::vec2& newPos);
|
|
void setIsometricView(bool isometric); // false = 2D true = Isometric
|
|
|
|
void setBackgroundColor(const glm::vec3& color) { m_BackgroundColor = color; }
|
|
|
|
glm::vec2 getCursorWorldPos(const glm::vec2& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight);
|
|
private:
|
|
void updateIsometricView();
|
|
void updateIsometricFade();
|
|
void initShader();
|
|
};
|
|
|
|
} // namespace render
|
|
} // namespace td
|
|
|
|
#endif /* RENDER_RENDERER_H_ */
|