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

Method RenderDataLines

src/engine/client/graph.cpp:163–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163void CGraph::RenderDataLines(IGraphics *pGraphics, float x, float y, float w, float h)
164{
165 if(m_pFirstScaled == nullptr)
166 {
167 return;
168 }
169
170 IGraphics::CLineItemBatch LineItemBatch;
171 pGraphics->LinesBatchBegin(&LineItemBatch);
172
173 const int64_t StartTime = m_pFirstScaled->m_Time;
174
175 CEntry *pEntry0 = m_pFirstScaled;
176 int a0 = round_to_int((pEntry0->m_Time - StartTime) * w / m_RenderedTotalTime);
177 int v0 = round_to_int((pEntry0->m_Value - m_MinAxis) * h / (m_MaxAxis - m_MinAxis));
178 while(pEntry0 != nullptr)
179 {
180 CEntry *pEntry1 = m_Entries.Next(pEntry0);
181 if(pEntry1 == nullptr)
182 break;
183
184 const int a1 = round_to_int((pEntry1->m_Time - StartTime) * w / m_RenderedTotalTime);
185 const int v1 = round_to_int((pEntry1->m_Value - m_MinAxis) * h / (m_MaxAxis - m_MinAxis));
186
187 if(pEntry1->m_ApplyColor)
188 {
189 pGraphics->LinesBatchEnd(&LineItemBatch);
190 pGraphics->LinesBatchBegin(&LineItemBatch);
191
192 const IGraphics::CColorVertex aColorVertices[] = {
193 IGraphics::CColorVertex(0, pEntry0->m_Color.r, pEntry0->m_Color.g, pEntry0->m_Color.b, pEntry0->m_Color.a),
194 IGraphics::CColorVertex(1, pEntry1->m_Color.r, pEntry1->m_Color.g, pEntry1->m_Color.b, pEntry1->m_Color.a)};
195 pGraphics->SetColorVertex(aColorVertices, std::size(aColorVertices));
196 }
197 const IGraphics::CLineItem Item = IGraphics::CLineItem(
198 x + a0,
199 y + h - v0,
200 x + a1,
201 y + h - v1);
202 pGraphics->LinesBatchDraw(&LineItemBatch, &Item, 1);
203
204 pEntry0 = pEntry1;
205 a0 = a1;
206 v0 = v1;
207 }
208 pGraphics->LinesBatchEnd(&LineItemBatch);
209}
210
211void CGraph::Render(IGraphics *pGraphics, ITextRender *pTextRender, float x, float y, float w, float h, const char *pDescription)
212{

Callers

nothing calls this directly

Calls 8

round_to_intFunction · 0.85
CColorVertexClass · 0.85
CLineItemClass · 0.85
LinesBatchBeginMethod · 0.80
LinesBatchEndMethod · 0.80
SetColorVertexMethod · 0.80
LinesBatchDrawMethod · 0.80
NextMethod · 0.45

Tested by

no test coverage detected