diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 060774731..b80a1e771 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -1237,6 +1237,38 @@ void CGraphics_Threaded::QuadsText(float x, float y, float Size, const char *pTe } } +void CGraphics_Threaded::DrawCircle(float x, float y, float r, int Segments) +{ + IGraphics::CFreeformItem Array[32]; + int NumItems = 0; + float FSegments = (float)Segments; + for(int i = 0; i < Segments; i += 2) + { + float a1 = i / FSegments * 2 * pi; + float a2 = (i + 1) / FSegments * 2 * pi; + float a3 = (i + 2) / FSegments * 2 * pi; + float Ca1 = cosf(a1); + float Ca2 = cosf(a2); + float Ca3 = cosf(a3); + float Sa1 = sinf(a1); + float Sa2 = sinf(a2); + float Sa3 = sinf(a3); + + Array[NumItems++] = IGraphics::CFreeformItem( + x, y, + x + Ca1 * r, y + Sa1 * r, + x + Ca3 * r, y + Sa3 * r, + x + Ca2 * r, y + Sa2 * r); + if(NumItems == 32) + { + QuadsDrawFreeform(Array, 32); + NumItems = 0; + } + } + if(NumItems) + QuadsDrawFreeform(Array, NumItems); +} + void CGraphics_Threaded::RenderTileLayer(int BufferContainerIndex, const ColorRGBA &Color, char **pOffsets, unsigned int *pIndicedVertexDrawNum, size_t NumIndicesOffset) { if(NumIndicesOffset == 0) diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 1bb3614bb..f470cae36 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -1127,6 +1127,8 @@ public: void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) override; void QuadsText(float x, float y, float Size, const char *pText) override; + void DrawCircle(float x, float y, float r, int Segments) override; + const GL_STexCoord *GetCurTextureCoordinates() override { return m_aTexture; diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 24a236e54..f13e3dee1 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -442,6 +442,8 @@ public: virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) = 0; virtual void QuadsText(float x, float y, float Size, const char *pText) = 0; + virtual void DrawCircle(float x, float y, float r, int Segments) = 0; + struct CColorVertex { int m_Index; diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index 9f9421552..3c99c5a4f 100644 --- a/src/game/client/components/emoticon.cpp +++ b/src/game/client/components/emoticon.cpp @@ -58,11 +58,6 @@ bool CEmoticon::OnCursorMove(float x, float y, IInput::ECursorType CursorType) return true; } -void CEmoticon::DrawCircle(float x, float y, float r, int Segments) -{ - RenderTools()->DrawCircle(x, y, r, Segments); -} - void CEmoticon::OnRender() { if(!m_Active) @@ -107,7 +102,7 @@ void CEmoticon::OnRender() Graphics()->TextureClear(); Graphics()->QuadsBegin(); Graphics()->SetColor(0, 0, 0, 0.3f); - DrawCircle(Screen.w / 2, Screen.h / 2, 190.0f, 64); + Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 190.0f, 64); Graphics()->QuadsEnd(); Graphics()->WrapClamp(); @@ -138,7 +133,7 @@ void CEmoticon::OnRender() Graphics()->TextureClear(); Graphics()->QuadsBegin(); Graphics()->SetColor(1.0, 1.0, 1.0, 0.3f); - DrawCircle(Screen.w / 2, Screen.h / 2, 100.0f, 64); + Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 100.0f, 64); Graphics()->QuadsEnd(); CTeeRenderInfo *pTeeInfo = &m_pClient->m_aClients[m_pClient->m_aLocalIDs[g_Config.m_ClDummy]].m_RenderInfo; @@ -162,7 +157,7 @@ void CEmoticon::OnRender() Graphics()->TextureClear(); Graphics()->QuadsBegin(); Graphics()->SetColor(0, 0, 0, 0.3f); - DrawCircle(Screen.w / 2, Screen.h / 2, 30.0f, 64); + Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 30.0f, 64); Graphics()->QuadsEnd(); } else diff --git a/src/game/client/components/emoticon.h b/src/game/client/components/emoticon.h index ed9f10a01..aec896cfa 100644 --- a/src/game/client/components/emoticon.h +++ b/src/game/client/components/emoticon.h @@ -7,8 +7,6 @@ class CEmoticon : public CComponent { - void DrawCircle(float x, float y, float r, int Segments); - bool m_WasActive; bool m_Active; diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 4c909efe5..d72e5304c 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1242,9 +1242,9 @@ void CMenus::RenderColorPicker() Graphics()->TextureClear(); Graphics()->QuadsBegin(); Graphics()->SetColor(MarkerOutline); - RenderTools()->DrawCircle(MarkerX, MarkerY, 4.5f, 32); + Graphics()->DrawCircle(MarkerX, MarkerY, 4.5f, 32); Graphics()->SetColor(color_cast(PickerColorHSV)); - RenderTools()->DrawCircle(MarkerX, MarkerY, 3.5f, 32); + Graphics()->DrawCircle(MarkerX, MarkerY, 3.5f, 32); Graphics()->QuadsEnd(); // Marker Hue Area diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index 825e7bbc0..e1223f008 100644 --- a/src/game/client/render.cpp +++ b/src/game/client/render.cpp @@ -529,38 +529,6 @@ void CRenderTools::DrawUIRect4(const CUIRect *pRect, vec4 ColorTopLeft, vec4 Col DrawRect4(pRect->x, pRect->y, pRect->w, pRect->h, ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight, Corners, Rounding); } -void CRenderTools::DrawCircle(float x, float y, float r, int Segments) -{ - IGraphics::CFreeformItem Array[32]; - int NumItems = 0; - float FSegments = (float)Segments; - for(int i = 0; i < Segments; i += 2) - { - float a1 = i / FSegments * 2 * pi; - float a2 = (i + 1) / FSegments * 2 * pi; - float a3 = (i + 2) / FSegments * 2 * pi; - float Ca1 = cosf(a1); - float Ca2 = cosf(a2); - float Ca3 = cosf(a3); - float Sa1 = sinf(a1); - float Sa2 = sinf(a2); - float Sa3 = sinf(a3); - - Array[NumItems++] = IGraphics::CFreeformItem( - x, y, - x + Ca1 * r, y + Sa1 * r, - x + Ca3 * r, y + Sa3 * r, - x + Ca2 * r, y + Sa2 * r); - if(NumItems == 32) - { - Graphics()->QuadsDrawFreeform(Array, 32); - NumItems = 0; - } - } - if(NumItems) - Graphics()->QuadsDrawFreeform(Array, NumItems); -} - void CRenderTools::GetRenderTeeAnimScaleAndBaseSize(CAnimState *pAnim, CTeeRenderInfo *pInfo, float &AnimScale, float &BaseSize) { AnimScale = pInfo->m_Size * 1.0f / 64.0f; diff --git a/src/game/client/render.h b/src/game/client/render.h index bc63d031b..704cf0d08 100644 --- a/src/game/client/render.h +++ b/src/game/client/render.h @@ -117,8 +117,6 @@ public: void DrawRect4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding); void DrawUIRect4(const CUIRect *pRect, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding); - void DrawCircle(float x, float y, float r, int Segments); - // larger rendering methods void GetRenderTeeBodySize(class CAnimState *pAnim, CTeeRenderInfo *pInfo, vec2 &BodyOffset, float &Width, float &Height); void GetRenderTeeFeetSize(class CAnimState *pAnim, CTeeRenderInfo *pInfo, vec2 &FeetOffset, float &Width, float &Height); diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index b56507036..7ab5251e1 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -2936,7 +2936,7 @@ void CEditor::DoMapEditor(CUIRect View) Graphics()->TextureClear(); Graphics()->QuadsBegin(); Graphics()->SetColor(0, 0, 1, 0.3f); - RenderTools()->DrawCircle(m_WorldOffsetX, m_WorldOffsetY - 3.0f, 20.0f, 32); + Graphics()->DrawCircle(m_WorldOffsetX, m_WorldOffsetY - 3.0f, 20.0f, 32); Graphics()->QuadsEnd(); } } diff --git a/src/game/editor/layer_sounds.cpp b/src/game/editor/layer_sounds.cpp index 8c78f36f4..b25663c07 100644 --- a/src/game/editor/layer_sounds.cpp +++ b/src/game/editor/layer_sounds.cpp @@ -40,12 +40,12 @@ void CLayerSounds::Render(bool Tileset) { case CSoundShape::SHAPE_CIRCLE: { - m_pEditor->RenderTools()->DrawCircle(fx2f(Source.m_Position.x) + OffsetX, fx2f(Source.m_Position.y) + OffsetY, + m_pEditor->Graphics()->DrawCircle(fx2f(Source.m_Position.x) + OffsetX, fx2f(Source.m_Position.y) + OffsetY, Source.m_Shape.m_Circle.m_Radius, 32); float Falloff = ((float)Source.m_Falloff / 255.0f); if(Falloff > 0.0f) - m_pEditor->RenderTools()->DrawCircle(fx2f(Source.m_Position.x) + OffsetX, fx2f(Source.m_Position.y) + OffsetY, + m_pEditor->Graphics()->DrawCircle(fx2f(Source.m_Position.x) + OffsetX, fx2f(Source.m_Position.y) + OffsetY, Source.m_Shape.m_Circle.m_Radius * Falloff, 32); break; }