Changeset View
Changeset View
Standalone View
Standalone View
source/gui/MiniMap.cpp
Show All 31 Lines | |||||
#include "gui/GUIManager.h" | #include "gui/GUIManager.h" | ||||
#include "lib/bits.h" | #include "lib/bits.h" | ||||
#include "lib/external_libraries/libsdl.h" | #include "lib/external_libraries/libsdl.h" | ||||
#include "lib/ogl.h" | #include "lib/ogl.h" | ||||
#include "lib/timer.h" | #include "lib/timer.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/Game.h" | #include "ps/Game.h" | ||||
#include "ps/GameSetup/Config.h" | |||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/ScreenSize.h" | |||||
#include "ps/World.h" | #include "ps/World.h" | ||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/WaterManager.h" | #include "renderer/WaterManager.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "simulation2/components/ICmpMinimap.h" | #include "simulation2/components/ICmpMinimap.h" | ||||
#include "simulation2/system/ParamNode.h" | #include "simulation2/system/ParamNode.h" | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | void CMiniMap::DrawViewRect(CMatrix3D transform) | ||||
// Compute the camera frustum intersected with a fixed-height plane. | // Compute the camera frustum intersected with a fixed-height plane. | ||||
// Use the water height as a fixed base height, which should be the lowest we can go | // Use the water height as a fixed base height, which should be the lowest we can go | ||||
float h = g_Renderer.GetWaterManager()->m_WaterHeight; | float h = g_Renderer.GetWaterManager()->m_WaterHeight; | ||||
const float width = m_CachedActualSize.GetWidth(); | const float width = m_CachedActualSize.GetWidth(); | ||||
const float height = m_CachedActualSize.GetHeight(); | const float height = m_CachedActualSize.GetHeight(); | ||||
const float invTileMapSize = 1.0f / float(TERRAIN_TILE_SIZE * m_MapSize); | const float invTileMapSize = 1.0f / float(TERRAIN_TILE_SIZE * m_MapSize); | ||||
CVector3D hitPt[4]; | CVector3D hitPt[4]; | ||||
hitPt[0] = m_Camera->GetWorldCoordinates(0, g_Renderer.GetHeight(), h); | hitPt[0] = m_Camera->GetWorldCoordinates(0, g_ScreenSize.LogicalHeight(), h); | ||||
hitPt[1] = m_Camera->GetWorldCoordinates(g_Renderer.GetWidth(), g_Renderer.GetHeight(), h); | hitPt[1] = m_Camera->GetWorldCoordinates(g_ScreenSize.LogicalWidth(), g_ScreenSize.LogicalHeight(), h); | ||||
hitPt[2] = m_Camera->GetWorldCoordinates(g_Renderer.GetWidth(), 0, h); | hitPt[2] = m_Camera->GetWorldCoordinates(g_ScreenSize.LogicalWidth(), 0, h); | ||||
hitPt[3] = m_Camera->GetWorldCoordinates(0, 0, h); | hitPt[3] = m_Camera->GetWorldCoordinates(0, 0, h); | ||||
float ViewRect[4][2]; | float ViewRect[4][2]; | ||||
for (int i = 0; i < 4; ++i) | for (int i = 0; i < 4; ++i) | ||||
{ | { | ||||
// convert to minimap space | // convert to minimap space | ||||
ViewRect[i][0] = (width * hitPt[i].X * invTileMapSize); | ViewRect[i][0] = (width * hitPt[i].X * invTileMapSize); | ||||
ViewRect[i][1] = (height * hitPt[i].Z * invTileMapSize); | ViewRect[i][1] = (height * hitPt[i].Z * invTileMapSize); | ||||
} | } | ||||
float viewVerts[] = { | float viewVerts[] = { | ||||
ViewRect[0][0], -ViewRect[0][1], | ViewRect[0][0], -ViewRect[0][1], | ||||
ViewRect[1][0], -ViewRect[1][1], | ViewRect[1][0], -ViewRect[1][1], | ||||
ViewRect[2][0], -ViewRect[2][1], | ViewRect[2][0], -ViewRect[2][1], | ||||
ViewRect[3][0], -ViewRect[3][1] | ViewRect[3][0], -ViewRect[3][1] | ||||
}; | }; | ||||
// Enable Scissoring to restrict the rectangle to only the minimap. | // Enable Scissoring to restrict the rectangle to only the minimap. | ||||
glScissor( | glScissor( | ||||
m_CachedActualSize.left * g_GuiScale, | m_CachedActualSize.left * g_ScreenSize.GuiScale(), | ||||
g_Renderer.GetHeight() - m_CachedActualSize.bottom * g_GuiScale, | g_Renderer.GetHeight() - m_CachedActualSize.bottom * g_ScreenSize.GuiScale(), | ||||
width * g_GuiScale, | width * g_ScreenSize.GuiScale(), | ||||
height * g_GuiScale); | height * g_ScreenSize.GuiScale()); | ||||
glEnable(GL_SCISSOR_TEST); | glEnable(GL_SCISSOR_TEST); | ||||
glLineWidth(2.0f); | glLineWidth(2.0f); | ||||
CShaderDefines lineDefines; | CShaderDefines lineDefines; | ||||
lineDefines.Add(str_MINIMAP_LINE, str_1); | lineDefines.Add(str_MINIMAP_LINE, str_1); | ||||
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_minimap, g_Renderer.GetSystemShaderDefines(), lineDefines); | CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_minimap, g_Renderer.GetSystemShaderDefines(), lineDefines); | ||||
tech->BeginPass(); | tech->BeginPass(); | ||||
CShaderProgramPtr shader = tech->GetShader(); | CShaderProgramPtr shader = tech->GetShader(); | ||||
▲ Show 20 Lines • Show All 410 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator