UPD: Move MinimapConfig out of Engine Responsibility, closes #38
All checks were successful
Tests / test (push) Successful in 2m36s
All checks were successful
Tests / test (push) Successful in 2m36s
This commit is contained in:
parent
a9b155ffc8
commit
6c7254378c
@ -7,6 +7,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "../core/Application.h"
|
#include "../core/Application.h"
|
||||||
|
#include "config/MinimapConfig.h"
|
||||||
#include "glm/ext/matrix_clip_space.hpp"
|
#include "glm/ext/matrix_clip_space.hpp"
|
||||||
|
|
||||||
void MasterRenderer::render(const Light &light, const Camera &camera) {
|
void MasterRenderer::render(const Light &light, const Camera &camera) {
|
||||||
@ -29,13 +30,7 @@ void MasterRenderer::render(const Light &light, const Camera &camera) {
|
|||||||
worldSpriteRenderer->finalize();
|
worldSpriteRenderer->finalize();
|
||||||
worldSprites.clear();
|
worldSprites.clear();
|
||||||
|
|
||||||
std::unordered_map<Engine::PlayerID, glm::vec3> colorMapping;
|
minimapRenderer->render(minimapRenderData);
|
||||||
colorMapping[0] = glm::vec3(1.0f, 0.0f, 0.0f);
|
|
||||||
colorMapping[1] = glm::vec3(0.0f, 1.0f, 0.0f);
|
|
||||||
colorMapping[2] = glm::vec3(0.0f, 0.0f, 1.0f);
|
|
||||||
colorMapping[3] = glm::vec3(1.0f, 1.0f, 0.0f);
|
|
||||||
|
|
||||||
minimapRenderer->render(minimapRenderData, colorMapping);
|
|
||||||
minimapRenderData.clear();
|
minimapRenderData.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -67,6 +62,11 @@ void MasterRenderer::submitWorldSprite(
|
|||||||
worldSprites[texture.get()].push_back(world_sprite_rendering_data);
|
worldSprites[texture.get()].push_back(world_sprite_rendering_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MasterRenderer::configureMinimap(const MinimapConfig &minimapConfig) {
|
||||||
|
minimapRenderer = std::make_unique<MinimapRenderer>(minimapConfig);
|
||||||
|
RenderTargets::instance().setMinimapTexture(minimapRenderer->getMinimapTexture());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 MasterRenderer::createProjectionMatrix(const float width, const float height) {
|
glm::mat4 MasterRenderer::createProjectionMatrix(const float width, const float height) {
|
||||||
std::cout << "Creating projection matrix with width: " << width << " and height: " << height << std::endl;
|
std::cout << "Creating projection matrix with width: " << width << " and height: " << height << std::endl;
|
||||||
|
|||||||
@ -41,8 +41,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MasterRenderer(const float width, const float height) : projectionMatrix(createProjectionMatrix(width, height)), entityRenderer(std::make_unique<Renderer>(projectionMatrix)),
|
explicit MasterRenderer(const float width, const float height) : projectionMatrix(createProjectionMatrix(width, height)), entityRenderer(std::make_unique<Renderer>(projectionMatrix)),
|
||||||
terrainRenderer(std::make_unique<TerrainRenderer>(projectionMatrix)), worldSpriteRenderer(std::make_unique<WorldSpriteRenderer>()),
|
terrainRenderer(std::make_unique<TerrainRenderer>(projectionMatrix)), worldSpriteRenderer(std::make_unique<WorldSpriteRenderer>())
|
||||||
minimapRenderer(std::make_unique<MinimapRenderer>(200,200))
|
|
||||||
{
|
{
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
@ -50,7 +49,6 @@ public:
|
|||||||
EventBus::getInstance().subscribe<WindowResizeEvent>([this](const WindowResizeEvent& event) {
|
EventBus::getInstance().subscribe<WindowResizeEvent>([this](const WindowResizeEvent& event) {
|
||||||
projectionMatrix = createProjectionMatrix(event.updatedWidth, event.updatedHeight);
|
projectionMatrix = createProjectionMatrix(event.updatedWidth, event.updatedHeight);
|
||||||
});
|
});
|
||||||
RenderTargets::instance().setMinimapTexture(minimapRenderer->getMinimapTexture());
|
|
||||||
};
|
};
|
||||||
void render(const Light &light, const Camera &camera);
|
void render(const Light &light, const Camera &camera);
|
||||||
|
|
||||||
@ -61,6 +59,8 @@ public:
|
|||||||
shared_ptr<ModelTexture> &texture);
|
shared_ptr<ModelTexture> &texture);
|
||||||
|
|
||||||
[[nodiscard]] glm::mat4 getProjectionMatrix() const {return projectionMatrix;}
|
[[nodiscard]] glm::mat4 getProjectionMatrix() const {return projectionMatrix;}
|
||||||
|
|
||||||
|
void configureMinimap(const MinimapConfig& minimapConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
#include "glm/ext/matrix_transform.hpp"
|
#include "glm/ext/matrix_transform.hpp"
|
||||||
|
|
||||||
|
|
||||||
void MinimapRenderer::render(const std::vector<MinimapRenderData> &renderData, std::unordered_map<Engine::PlayerID, glm::vec3> colorMapping) {
|
void MinimapRenderer::render(const std::vector<MinimapRenderData> &renderData) {
|
||||||
minimapFBO->bind();
|
minimapFBO->bind();
|
||||||
glViewport(0,0, width, height);
|
glViewport(0,0, width, height);
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|||||||
@ -9,17 +9,19 @@
|
|||||||
|
|
||||||
#include "../../game/GameMode.h"
|
#include "../../game/GameMode.h"
|
||||||
#include "components/MinimapRenderData.h"
|
#include "components/MinimapRenderData.h"
|
||||||
|
#include "config/MinimapConfig.h"
|
||||||
#include "model/FramebufferObject.h"
|
#include "model/FramebufferObject.h"
|
||||||
#include "shaders/MinimapShader.h"
|
#include "shaders/MinimapShader.h"
|
||||||
|
|
||||||
|
|
||||||
class MinimapRenderer {
|
class MinimapRenderer {
|
||||||
public:
|
public:
|
||||||
MinimapRenderer(int width, int height): width(width), height(height) {
|
MinimapRenderer(const MinimapConfig& minimapConfig): width(minimapConfig.resolution), height(minimapConfig.resolution) {
|
||||||
minimapFBO = std::make_unique<FramebufferObject>(width, height);
|
minimapFBO = std::make_unique<FramebufferObject>(width, height);
|
||||||
|
colorMapping = minimapConfig.playerColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void render(const std::vector<MinimapRenderData> &renderData, std::unordered_map<Engine::PlayerID, glm::vec3> colorMapping);
|
void render(const std::vector<MinimapRenderData> &renderData);
|
||||||
|
|
||||||
GLuint getMinimapTexture();
|
GLuint getMinimapTexture();
|
||||||
|
|
||||||
@ -27,6 +29,7 @@ private:
|
|||||||
std::unique_ptr<FramebufferObject> minimapFBO;
|
std::unique_ptr<FramebufferObject> minimapFBO;
|
||||||
MinimapShader minimapShader;
|
MinimapShader minimapShader;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
std::unordered_map<Engine::PlayerID, glm::vec3> colorMapping;
|
||||||
|
|
||||||
void prepareShader();
|
void prepareShader();
|
||||||
void finalizeShader();
|
void finalizeShader();
|
||||||
|
|||||||
@ -31,7 +31,8 @@
|
|||||||
#include "hexWorld/events/BuildingTypeSelectEvent.h"
|
#include "hexWorld/events/BuildingTypeSelectEvent.h"
|
||||||
#include "hexWorld/events/TurnChangedEvent.h"
|
#include "hexWorld/events/TurnChangedEvent.h"
|
||||||
|
|
||||||
GameLayer::GameLayer() :texturedModel(0,0) //Platzhalter, echtes Model kommt in onAttach
|
GameLayer::GameLayer() : texturedModel(0, 0), testEntity(0)
|
||||||
|
//Platzhalter, echtes Model kommt in onAttach
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +81,14 @@ void GameLayer::onAttach()
|
|||||||
EventBus::getInstance().subscribe<BuildingTypeSelectEvent>([this](const BuildingTypeSelectEvent& event) {
|
EventBus::getInstance().subscribe<BuildingTypeSelectEvent>([this](const BuildingTypeSelectEvent& event) {
|
||||||
gameMode->setActiveBuilding(event.selectedBuildingType);
|
gameMode->setActiveBuilding(event.selectedBuildingType);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
std::unordered_map<Engine::PlayerID, glm::vec3> colorMapping;
|
||||||
|
colorMapping[0] = glm::vec3(1.0f, 0.0f, 0.0f);
|
||||||
|
colorMapping[1] = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||||
|
colorMapping[2] = glm::vec3(0.0f, 0.0f, 1.0f);
|
||||||
|
colorMapping[3] = glm::vec3(1.0f, 1.0f, 0.0f);
|
||||||
|
MinimapConfig minimapConfig = MinimapConfig(200, colorMapping);
|
||||||
|
renderer->configureMinimap(minimapConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameLayer::onDetach()
|
void GameLayer::onDetach()
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include "../engine/renderer/model/TexturedModel.h"
|
#include "../engine/renderer/model/TexturedModel.h"
|
||||||
#include "../engine/layer/entities/Camera.h"
|
#include "../engine/layer/entities/Camera.h"
|
||||||
#include "../engine/renderer/MasterRenderer.h"
|
#include "../engine/renderer/MasterRenderer.h"
|
||||||
|
#include "../engine/renderer/config/MinimapConfig.h"
|
||||||
#include "hexWorld/Map.h"
|
#include "hexWorld/Map.h"
|
||||||
#include "hexWorld/ecs/systems/BuildingPlacementSystem.h"
|
#include "hexWorld/ecs/systems/BuildingPlacementSystem.h"
|
||||||
#include "hexWorld/ecs/systems/TileHighlightSystem.h"
|
#include "hexWorld/ecs/systems/TileHighlightSystem.h"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user