Skip to content

Commit

Permalink
Fixed 625af77
Browse files Browse the repository at this point in the history
  • Loading branch information
lhog committed Mar 13, 2021
1 parent a460600 commit 10fd8bb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions rts/Game/UI/MiniMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,29 @@ void CMiniMap::UpdateGeometry()
curPos.x = Clamp(curPos.x, 0, globalRendering->viewSizeX - curDim.x);
}

{
// Draw{WorldStuff} transform
viewMats[0].LoadIdentity();
viewMats[0].Translate(UpVector);
viewMats[0].Scale({ +1.0f / (mapDims.mapx * SQUARE_SIZE), -1.0f / (mapDims.mapy * SQUARE_SIZE), 1.0f });
viewMats[0].RotateX(90.0f * math::DEG_TO_RAD); // rotate to match real 'world' coordinates
viewMats[0].Scale(XZVector + UpVector * 0.0001f); // (invertibly) flatten; LuaOpenGL::DrawScreen uses persp-proj so z-values influence x&y

viewMats[1].LoadIdentity();
viewMats[1].Translate(UpVector);
// heightmap (squares) to minimap
viewMats[1].Scale({ 1.0f / mapDims.mapx, -1.0f / mapDims.mapy, 1.0f });
// worldmap (elmos) to minimap
// viewMats[1].Scale({1.0f / (mapDims.mapx * SQUARE_SIZE), -1.0f / (mapDims.mapy * SQUARE_SIZE), 1.0f});

viewMats[2].LoadIdentity();
viewMats[2].Scale({ 1.0f / curDim.x, 1.0f / curDim.y, 1.0f });

projMats[0] = CMatrix44f::ClipOrthoProj01();
projMats[1] = CMatrix44f::ClipOrthoProj(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, -1.0f, globalRendering->supportClipSpaceControl * 1.0f);
projMats[2] = projMats[1];
}

lastWindowSizeX = globalRendering->viewSizeX;
lastWindowSizeY = globalRendering->viewSizeY;

Expand Down
8 changes: 8 additions & 0 deletions rts/Game/UI/MiniMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <deque>
#include "InputReceiver.h"
#include "Rendering/GL/FBO.h"
#include "System/Matrix44f.h"
#include "System/Color.h"
#include "System/float3.h"
#include "System/type2.h"
Expand Down Expand Up @@ -69,6 +70,9 @@ class CMiniMap : public CInputReceiver {
const unsigned char* GetAllyTeamIconColor() const { return &allyColor[0]; }
const unsigned char* GetEnemyTeamIconColor() const { return &enemyColor[0]; }

const CMatrix44f& GetViewMat(unsigned int idx) const { return viewMats[idx]; }
const CMatrix44f& GetProjMat(unsigned int idx) const { return projMats[idx]; }

void ApplyConstraintsMatrix() const;

protected:
Expand Down Expand Up @@ -171,6 +175,10 @@ class CMiniMap : public CInputReceiver {
SColor allyColor;
SColor enemyColor;

// transforms for [0] := Draw, [1] := DrawInMiniMap, [2] := Lua DrawInMiniMap
CMatrix44f viewMats[3];
CMatrix44f projMats[3];

FBO fbo;
FBO fboResolve;
GLuint minimapTex = 0;
Expand Down

0 comments on commit 10fd8bb

Please sign in to comment.