diff --git a/src/engine/renderer/MasterRenderer.h b/src/engine/renderer/MasterRenderer.h index e9a8a8c..3dd5b16 100644 --- a/src/engine/renderer/MasterRenderer.h +++ b/src/engine/renderer/MasterRenderer.h @@ -39,7 +39,7 @@ private: public: MasterRenderer() : projectionMatrix(createProjectionMatrix()), entityRenderer(std::make_unique(projectionMatrix)), terrainRenderer(std::make_unique(projectionMatrix)), worldSpriteRenderer(std::make_unique(projectionMatrix)), - minimapRenderer(std::make_unique(600,400)) + minimapRenderer(std::make_unique(200,200)) { glEnable(GL_CULL_FACE); glCullFace(GL_BACK); diff --git a/src/engine/renderer/MinimapRenderer.cpp b/src/engine/renderer/MinimapRenderer.cpp index f545287..a69e9a7 100644 --- a/src/engine/renderer/MinimapRenderer.cpp +++ b/src/engine/renderer/MinimapRenderer.cpp @@ -62,10 +62,29 @@ void MinimapRenderer::prepareShader() { bounds.minZ + mapHeight * 0.5f ); - glm::mat4 view = glm::lookAt(mapCenter + glm::vec3(0,50,0), mapCenter, glm::vec3(0,0,1)); + float fboAspect = static_cast(width) / static_cast(height); + float mapAspect = mapWidth / mapHeight; + float left, right, bottom, top; float zoom = 1.2f; // >1 = weiter raus, <1 = näher ran - glm::mat4 proj = glm::ortho(-mapWidth * 0.5f * zoom, mapWidth * 0.5f * zoom, -mapHeight * 0.5f * zoom, mapHeight * 0.5f * zoom, -100.f, 100.0f); + if (mapAspect > fboAspect) { + // Map breiter als FBO → FBO horizontal voll, vertikal Padding + float adjustedHeight = mapWidth / fboAspect; + left = -mapWidth * 0.5f * zoom; + right = mapWidth * 0.5f * zoom; + bottom = -adjustedHeight * 0.5f * zoom; + top = adjustedHeight * 0.5f * zoom; + } else { + // Map höher als FBO → FBO vertikal voll, horizontal Padding + float adjustedWidth = mapHeight * fboAspect; + left = -adjustedWidth * 0.5f * zoom; + right = adjustedWidth * 0.5f * zoom; + bottom = -mapHeight * 0.5f * zoom; + top = mapHeight * 0.5f * zoom; + } + glm::mat4 view = glm::lookAt(mapCenter + glm::vec3(0,50,0), mapCenter, glm::vec3(0,0,1)); + + glm::mat4 proj = glm::ortho(left, right, bottom, top, -100.f, 100.f); minimapShader.loadViewProjectionMatrix(proj * view); } diff --git a/src/game/UILayer.cpp b/src/game/UILayer.cpp index a65d0c7..3dc5779 100644 --- a/src/game/UILayer.cpp +++ b/src/game/UILayer.cpp @@ -80,8 +80,8 @@ void UILayer::onAttach() { }); auto minimapStyle = LayoutStyle(); - minimapStyle.width = SizeValue(600, SizeUnit::Pixels); - minimapStyle.height = SizeValue(400.f, SizeUnit::Pixels); + minimapStyle.width = SizeValue(200, SizeUnit::Pixels); + minimapStyle.height = SizeValue(200.f, SizeUnit::Pixels); minimapStyle.margin.top = {10.f, SizeUnit::Pixels}; GLuint minimapTextureID = RenderTargets::instance().getMinimapTexture();