fix: change renderer to class
This commit is contained in:
@@ -9,37 +9,53 @@
|
||||
#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{
|
||||
namespace render {
|
||||
|
||||
namespace Renderer{
|
||||
class Renderer {
|
||||
public:
|
||||
static constexpr float m_AnimationSpeed = 2.0f;
|
||||
|
||||
struct Model{
|
||||
GL::VAO* vao;
|
||||
glm::vec2 positon;
|
||||
struct Model {
|
||||
GL::VAO* vao;
|
||||
glm::vec2 positon;
|
||||
};
|
||||
private:
|
||||
std::unique_ptr<WorldShader> m_WorldShader;
|
||||
std::unique_ptr<EntityShader> m_EntityShader;
|
||||
|
||||
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::VAO& 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
|
||||
|
||||
glm::vec2 getCursorWorldPos(const glm::vec2& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight);
|
||||
private:
|
||||
void updateIsometricView();
|
||||
void updateIsometricFade();
|
||||
void initShader();
|
||||
};
|
||||
|
||||
bool init();
|
||||
void destroy();
|
||||
|
||||
void prepare();
|
||||
void resize(const int width, const int height);
|
||||
|
||||
void renderVAO(const GL::VAO& 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
|
||||
|
||||
glm::vec2 getCursorWorldPos(const glm::vec2& cursorPos, float aspectRatio, float zoom, float windowWidth, float windowHeight);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace render
|
||||
} // namespace td
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "game/World.h"
|
||||
#include "render/loader/GLLoader.h"
|
||||
#include "render/Renderer.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
@@ -10,6 +11,7 @@ namespace render {
|
||||
|
||||
class WorldRenderer{
|
||||
private:
|
||||
Renderer* m_Renderer;
|
||||
game::World* m_World;
|
||||
std::unique_ptr<GL::VAO> m_WorldVao, m_MobVao, m_SelectTileVao;
|
||||
glm::vec2 m_CamPos;
|
||||
@@ -17,7 +19,7 @@ private:
|
||||
float m_Zoom = 1;
|
||||
float m_CamSensibility = 1;
|
||||
public:
|
||||
WorldRenderer(game::World* world);
|
||||
WorldRenderer(game::World* world, Renderer* renderer);
|
||||
~WorldRenderer();
|
||||
|
||||
void loadModels();
|
||||
|
||||
@@ -10,9 +10,18 @@
|
||||
|
||||
struct GLFWwindow;
|
||||
|
||||
namespace TowerGui{
|
||||
namespace td {
|
||||
namespace render {
|
||||
|
||||
void init(GLFWwindow* window);
|
||||
class Renderer;
|
||||
|
||||
} // namespace render
|
||||
} // namespace td
|
||||
|
||||
|
||||
namespace TowerGui {
|
||||
|
||||
void init(GLFWwindow* window, td::render::Renderer* renderer);
|
||||
void render();
|
||||
void destroy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user