UPD: Adjust size of Minimap
This commit is contained in:
parent
10a495c205
commit
66020b9b9a
@ -39,7 +39,7 @@ private:
|
||||
public:
|
||||
MasterRenderer() : projectionMatrix(createProjectionMatrix()), entityRenderer(std::make_unique<Renderer>(projectionMatrix)),
|
||||
terrainRenderer(std::make_unique<TerrainRenderer>(projectionMatrix)), worldSpriteRenderer(std::make_unique<WorldSpriteRenderer>(projectionMatrix)),
|
||||
minimapRenderer(std::make_unique<MinimapRenderer>(600,400))
|
||||
minimapRenderer(std::make_unique<MinimapRenderer>(200,200))
|
||||
{
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
@ -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<float>(width) / static_cast<float>(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);
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user