bool resizeRadar() { if (radarBuffer) { free(radarBuffer); } radarTexWidth = scrollMaxX - scrollMinX; radarTexHeight = scrollMaxY - scrollMinY; radarBufferSize = radarTexWidth * radarTexHeight * sizeof(UDWORD); radarBuffer = (uint32_t *)malloc(radarBufferSize); memset(radarBuffer, 0, radarBufferSize); if (rotateRadar) { RadarZoomMultiplier = (float)MAX(RADWIDTH, RADHEIGHT) / (float)MAX(radarTexWidth, radarTexHeight); } else { RadarZoomMultiplier = 1.0f; } debug(LOG_WZ, "Setting radar zoom to %u", RadarZoom); radarSize(RadarZoom); pie_SetRadar(-radarWidth / 2.0 - 1, -radarHeight / 2.0 - 1, radarWidth, radarHeight, radarTexWidth, radarTexHeight, rotateRadar || (RadarZoom % 16 != 0)); setViewingWindow(); return true; }
void drawRadar() { float pixSizeH, pixSizeV; CalcRadarPixelSize(&pixSizeH, &pixSizeV); ASSERT_OR_RETURN(, radarBuffer, "No radar buffer allocated"); // Do not recalculate frustum window coordinates if position or zoom does not change if (playerpos.x != player.p.x || playerpos.y != player.p.y || playerpos.z != player.p.z) { setViewingWindow(); } playerpos = player.p; // cache position if (frameSkip <= 0) { DrawRadarTiles(); DrawRadarObjects(); pie_DownLoadRadar(radarBuffer); frameSkip = RADAR_FRAME_SKIP; } frameSkip--; pie_SetRendMode(REND_ALPHA); pie_MatBegin(); pie_TRANSLATE(radarCenterX, radarCenterY, 0); if (rotateRadar) { // rotate the map pie_MatRotZ(player.r.y); DrawNorth(); } pie_RenderRadar(); pie_MatBegin(); pie_TRANSLATE(-radarWidth / 2 - 1, -radarHeight / 2 - 1, 0); DrawRadarExtras(); pie_MatEnd(); drawRadarBlips(-radarWidth / 2.0 - 1, -radarHeight / 2.0 - 1, pixSizeH, pixSizeV); pie_MatEnd(); }
void drawRadar() { float pixSizeH, pixSizeV; CalcRadarPixelSize(&pixSizeH, &pixSizeV); ASSERT_OR_RETURN(, radarBuffer, "No radar buffer allocated"); // Do not recalculate frustum window coordinates if position or zoom does not change if (playerpos.x != player.p.x || playerpos.y != player.p.y || playerpos.z != player.p.z) { setViewingWindow(); } playerpos = player.p; // cache position if (frameSkip <= 0) { DrawRadarTiles(); DrawRadarObjects(); pie_DownLoadRadar(radarBuffer); frameSkip = RADAR_FRAME_SKIP; } frameSkip--; pie_SetRendMode(REND_ALPHA); glm::mat4 radarMatrix = glm::translate(radarCenterX, radarCenterY, 0); glm::mat4 orthoMatrix = glm::ortho(0.f, static_cast<float>(pie_GetVideoBufferWidth()), static_cast<float>(pie_GetVideoBufferHeight()), 0.f); if (rotateRadar) { // rotate the map radarMatrix *= glm::rotate(UNDEG(player.r.y), glm::vec3(0.f, 0.f, 1.f)); DrawNorth(orthoMatrix * radarMatrix); } pie_RenderRadar(orthoMatrix * radarMatrix); DrawRadarExtras(orthoMatrix * radarMatrix * glm::translate(-radarWidth / 2.f - 1.f, -radarHeight / 2.f - 1.f, 0.f)); drawRadarBlips(-radarWidth / 2.0 - 1, -radarHeight / 2.0 - 1, pixSizeH, pixSizeV, orthoMatrix * radarMatrix); }