MCPcopy Create free account
hub / github.com/ddnet/ddnet / DoRender

Method DoRender

src/game/map/render_layer.cpp:226–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224 CRenderLayer(GroupId, 0, 0), m_pGroup(pGroup) {}
225
226bool CRenderLayerGroup::DoRender(const CRenderLayerParams &Params)
227{
228 if(!g_Config.m_GfxNoclip || Params.m_RenderType == ERenderType::RENDERTYPE_FULL_DESIGN)
229 {
230 Graphics()->ClipDisable();
231 if(m_pGroup->m_Version >= 2 && m_pGroup->m_UseClipping)
232 {
233 // set clipping
234 Graphics()->MapScreenToInterface(Params.m_Center.x, Params.m_Center.y, Params.m_Zoom);
235
236 float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
237 Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
238 float ScreenWidth = ScreenX1 - ScreenX0;
239 float ScreenHeight = ScreenY1 - ScreenY0;
240 float Left = m_pGroup->m_ClipX - ScreenX0;
241 float Top = m_pGroup->m_ClipY - ScreenY0;
242 float Right = m_pGroup->m_ClipX + m_pGroup->m_ClipW - ScreenX0;
243 float Bottom = m_pGroup->m_ClipY + m_pGroup->m_ClipH - ScreenY0;
244
245 if(Right < 0.0f || Left > ScreenWidth || Bottom < 0.0f || Top > ScreenHeight)
246 return false;
247
248 // Render debug before enabling the clip
249 if(Params.m_DebugRenderGroupClips)
250 {
251 char aDebugText[32];
252 str_format(aDebugText, sizeof(aDebugText), "Group %d", m_GroupId);
253 RenderMap()->RenderDebugClip(m_pGroup->m_ClipX, m_pGroup->m_ClipY, m_pGroup->m_ClipW, m_pGroup->m_ClipH, ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), Params.m_Zoom, aDebugText);
254 }
255
256 int ClipX = (int)std::round(Left * Graphics()->ScreenWidth() / ScreenWidth);
257 int ClipY = (int)std::round(Top * Graphics()->ScreenHeight() / ScreenHeight);
258
259 Graphics()->ClipEnable(
260 ClipX,
261 ClipY,
262 (int)std::round(Right * Graphics()->ScreenWidth() / ScreenWidth) - ClipX,
263 (int)std::round(Bottom * Graphics()->ScreenHeight() / ScreenHeight) - ClipY);
264 }
265 }
266 return true;
267}
268
269void CRenderLayerGroup::Render(const CRenderLayerParams &Params)
270{

Callers 1

RenderMethod · 0.80

Calls 11

GraphicsFunction · 0.85
str_formatFunction · 0.85
RenderMapFunction · 0.85
MapScreenToInterfaceMethod · 0.80
GetScreenMethod · 0.80
RenderDebugClipMethod · 0.80
ScreenWidthMethod · 0.80
ScreenHeightMethod · 0.80
ColorRGBAClass · 0.50
ClipDisableMethod · 0.45
ClipEnableMethod · 0.45

Tested by

no test coverage detected