diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 813ea8101..adde5a677 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -1237,6 +1237,332 @@ void CGraphics_Threaded::QuadsText(float x, float y, float Size, const char *pTe } } +void CGraphics_Threaded::DrawRectExt(float x, float y, float w, float h, float r, int Corners) +{ + int NumItems = 0; + const int Num = 8; + + IGraphics::CFreeformItem ArrayF[Num * 4]; + + for(int i = 0; i < Num; i += 2) + { + float a1 = i / (float)Num * pi / 2; + float a2 = (i + 1) / (float)Num * pi / 2; + float a3 = (i + 2) / (float)Num * pi / 2; + float Ca1 = cosf(a1); + float Ca2 = cosf(a2); + float Ca3 = cosf(a3); + float Sa1 = sinf(a1); + float Sa2 = sinf(a2); + float Sa3 = sinf(a3); + + if(Corners & 1) // TL + ArrayF[NumItems++] = IGraphics::CFreeformItem( + x + r, y + r, + x + (1 - Ca1) * r, y + (1 - Sa1) * r, + x + (1 - Ca3) * r, y + (1 - Sa3) * r, + x + (1 - Ca2) * r, y + (1 - Sa2) * r); + + if(Corners & 2) // TR + ArrayF[NumItems++] = IGraphics::CFreeformItem( + x + w - r, y + r, + x + w - r + Ca1 * r, y + (1 - Sa1) * r, + x + w - r + Ca3 * r, y + (1 - Sa3) * r, + x + w - r + Ca2 * r, y + (1 - Sa2) * r); + + if(Corners & 4) // BL + ArrayF[NumItems++] = IGraphics::CFreeformItem( + x + r, y + h - r, + x + (1 - Ca1) * r, y + h - r + Sa1 * r, + x + (1 - Ca3) * r, y + h - r + Sa3 * r, + x + (1 - Ca2) * r, y + h - r + Sa2 * r); + + if(Corners & 8) // BR + ArrayF[NumItems++] = IGraphics::CFreeformItem( + x + w - r, y + h - r, + x + w - r + Ca1 * r, y + h - r + Sa1 * r, + x + w - r + Ca3 * r, y + h - r + Sa3 * r, + x + w - r + Ca2 * r, y + h - r + Sa2 * r); + } + QuadsDrawFreeform(ArrayF, NumItems); + + CQuadItem ArrayQ[9]; + NumItems = 0; + ArrayQ[NumItems++] = CQuadItem(x + r, y + r, w - r * 2, h - r * 2); // center + ArrayQ[NumItems++] = CQuadItem(x + r, y, w - r * 2, r); // top + ArrayQ[NumItems++] = CQuadItem(x + r, y + h - r, w - r * 2, r); // bottom + ArrayQ[NumItems++] = CQuadItem(x, y + r, r, h - r * 2); // left + ArrayQ[NumItems++] = CQuadItem(x + w - r, y + r, r, h - r * 2); // right + + if(!(Corners & 1)) + ArrayQ[NumItems++] = CQuadItem(x, y, r, r); // TL + if(!(Corners & 2)) + ArrayQ[NumItems++] = CQuadItem(x + w, y, -r, r); // TR + if(!(Corners & 4)) + ArrayQ[NumItems++] = CQuadItem(x, y + h, r, -r); // BL + if(!(Corners & 8)) + ArrayQ[NumItems++] = CQuadItem(x + w, y + h, -r, -r); // BR + + QuadsDrawTL(ArrayQ, NumItems); +} + +void CGraphics_Threaded::DrawRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners) +{ + if(Corners == 0 || r == 0.0f) + { + SetColor4(ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight); + CQuadItem ItemQ = CQuadItem(x, y, w, h); + QuadsDrawTL(&ItemQ, 1); + return; + } + + int Num = 8; + for(int i = 0; i < Num; i += 2) + { + float a1 = i / (float)Num * pi / 2; + float a2 = (i + 1) / (float)Num * pi / 2; + float a3 = (i + 2) / (float)Num * pi / 2; + float Ca1 = cosf(a1); + float Ca2 = cosf(a2); + float Ca3 = cosf(a3); + float Sa1 = sinf(a1); + float Sa2 = sinf(a2); + float Sa3 = sinf(a3); + + if(Corners & 1) // TL + { + SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a); + IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( + x + r, y + r, + x + (1 - Ca1) * r, y + (1 - Sa1) * r, + x + (1 - Ca3) * r, y + (1 - Sa3) * r, + x + (1 - Ca2) * r, y + (1 - Sa2) * r); + QuadsDrawFreeform(&ItemF, 1); + } + + if(Corners & 2) // TR + { + SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a); + IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( + x + w - r, y + r, + x + w - r + Ca1 * r, y + (1 - Sa1) * r, + x + w - r + Ca3 * r, y + (1 - Sa3) * r, + x + w - r + Ca2 * r, y + (1 - Sa2) * r); + QuadsDrawFreeform(&ItemF, 1); + } + + if(Corners & 4) // BL + { + SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a); + IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( + x + r, y + h - r, + x + (1 - Ca1) * r, y + h - r + Sa1 * r, + x + (1 - Ca3) * r, y + h - r + Sa3 * r, + x + (1 - Ca2) * r, y + h - r + Sa2 * r); + QuadsDrawFreeform(&ItemF, 1); + } + + if(Corners & 8) // BR + { + SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a); + IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( + x + w - r, y + h - r, + x + w - r + Ca1 * r, y + h - r + Sa1 * r, + x + w - r + Ca3 * r, y + h - r + Sa3 * r, + x + w - r + Ca2 * r, y + h - r + Sa2 * r); + QuadsDrawFreeform(&ItemF, 1); + } + + if(Corners & 16) // ITL + { + SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a); + IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( + x, y, + x + (1 - Ca1) * r, y - r + Sa1 * r, + x + (1 - Ca3) * r, y - r + Sa3 * r, + x + (1 - Ca2) * r, y - r + Sa2 * r); + QuadsDrawFreeform(&ItemF, 1); + } + + if(Corners & 32) // ITR + { + SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a); + IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( + x + w, y, + x + w - r + Ca1 * r, y - r + Sa1 * r, + x + w - r + Ca3 * r, y - r + Sa3 * r, + x + w - r + Ca2 * r, y - r + Sa2 * r); + QuadsDrawFreeform(&ItemF, 1); + } + + if(Corners & 64) // IBL + { + SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a); + IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( + x, y + h, + x + (1 - Ca1) * r, y + h + (1 - Sa1) * r, + x + (1 - Ca3) * r, y + h + (1 - Sa3) * r, + x + (1 - Ca2) * r, y + h + (1 - Sa2) * r); + QuadsDrawFreeform(&ItemF, 1); + } + + if(Corners & 128) // IBR + { + SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a); + IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( + x + w, y + h, + x + w - r + Ca1 * r, y + h + (1 - Sa1) * r, + x + w - r + Ca3 * r, y + h + (1 - Sa3) * r, + x + w - r + Ca2 * r, y + h + (1 - Sa2) * r); + QuadsDrawFreeform(&ItemF, 1); + } + } + + SetColor4(ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight); + CQuadItem ItemQ = CQuadItem(x + r, y + r, w - r * 2, h - r * 2); // center + QuadsDrawTL(&ItemQ, 1); + SetColor4(ColorTopLeft, ColorTopRight, ColorTopLeft, ColorTopRight); + ItemQ = CQuadItem(x + r, y, w - r * 2, r); // top + QuadsDrawTL(&ItemQ, 1); + SetColor4(ColorBottomLeft, ColorBottomRight, ColorBottomLeft, ColorBottomRight); + ItemQ = CQuadItem(x + r, y + h - r, w - r * 2, r); // bottom + QuadsDrawTL(&ItemQ, 1); + SetColor4(ColorTopLeft, ColorTopLeft, ColorBottomLeft, ColorBottomLeft); + ItemQ = CQuadItem(x, y + r, r, h - r * 2); // left + QuadsDrawTL(&ItemQ, 1); + SetColor4(ColorTopRight, ColorTopRight, ColorBottomRight, ColorBottomRight); + ItemQ = CQuadItem(x + w - r, y + r, r, h - r * 2); // right + QuadsDrawTL(&ItemQ, 1); + + if(!(Corners & 1)) + { + SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a); + ItemQ = CQuadItem(x, y, r, r); // TL + QuadsDrawTL(&ItemQ, 1); + } + if(!(Corners & 2)) + { + SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a); + ItemQ = CQuadItem(x + w, y, -r, r); // TR + QuadsDrawTL(&ItemQ, 1); + } + if(!(Corners & 4)) + { + SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a); + ItemQ = CQuadItem(x, y + h, r, -r); // BL + QuadsDrawTL(&ItemQ, 1); + } + if(!(Corners & 8)) + { + SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a); + ItemQ = CQuadItem(x + w, y + h, -r, -r); // BR + QuadsDrawTL(&ItemQ, 1); + } +} + +int CGraphics_Threaded::CreateRectQuadContainer(float x, float y, float w, float h, float r, int Corners) +{ + int ContainerIndex = CreateQuadContainer(false); + + if(Corners == 0 || r == 0.0f) + { + CQuadItem ItemQ = CQuadItem(x, y, w, h); + QuadContainerAddQuads(ContainerIndex, &ItemQ, 1); + QuadContainerUpload(ContainerIndex); + QuadContainerChangeAutomaticUpload(ContainerIndex, true); + return ContainerIndex; + } + + IGraphics::CFreeformItem ArrayF[32]; + int NumItems = 0; + int Num = 8; + for(int i = 0; i < Num; i += 2) + { + float a1 = i / (float)Num * pi / 2; + float a2 = (i + 1) / (float)Num * pi / 2; + float a3 = (i + 2) / (float)Num * pi / 2; + float Ca1 = cosf(a1); + float Ca2 = cosf(a2); + float Ca3 = cosf(a3); + float Sa1 = sinf(a1); + float Sa2 = sinf(a2); + float Sa3 = sinf(a3); + + if(Corners & 1) // TL + ArrayF[NumItems++] = IGraphics::CFreeformItem( + x + r, y + r, + x + (1 - Ca1) * r, y + (1 - Sa1) * r, + x + (1 - Ca3) * r, y + (1 - Sa3) * r, + x + (1 - Ca2) * r, y + (1 - Sa2) * r); + + if(Corners & 2) // TR + ArrayF[NumItems++] = IGraphics::CFreeformItem( + x + w - r, y + r, + x + w - r + Ca1 * r, y + (1 - Sa1) * r, + x + w - r + Ca3 * r, y + (1 - Sa3) * r, + x + w - r + Ca2 * r, y + (1 - Sa2) * r); + + if(Corners & 4) // BL + ArrayF[NumItems++] = IGraphics::CFreeformItem( + x + r, y + h - r, + x + (1 - Ca1) * r, y + h - r + Sa1 * r, + x + (1 - Ca3) * r, y + h - r + Sa3 * r, + x + (1 - Ca2) * r, y + h - r + Sa2 * r); + + if(Corners & 8) // BR + ArrayF[NumItems++] = IGraphics::CFreeformItem( + x + w - r, y + h - r, + x + w - r + Ca1 * r, y + h - r + Sa1 * r, + x + w - r + Ca3 * r, y + h - r + Sa3 * r, + x + w - r + Ca2 * r, y + h - r + Sa2 * r); + } + + if(NumItems > 0) + QuadContainerAddQuads(ContainerIndex, ArrayF, NumItems); + + CQuadItem ArrayQ[9]; + NumItems = 0; + ArrayQ[NumItems++] = CQuadItem(x + r, y + r, w - r * 2, h - r * 2); // center + ArrayQ[NumItems++] = CQuadItem(x + r, y, w - r * 2, r); // top + ArrayQ[NumItems++] = CQuadItem(x + r, y + h - r, w - r * 2, r); // bottom + ArrayQ[NumItems++] = CQuadItem(x, y + r, r, h - r * 2); // left + ArrayQ[NumItems++] = CQuadItem(x + w - r, y + r, r, h - r * 2); // right + + if(!(Corners & 1)) + ArrayQ[NumItems++] = CQuadItem(x, y, r, r); // TL + if(!(Corners & 2)) + ArrayQ[NumItems++] = CQuadItem(x + w, y, -r, r); // TR + if(!(Corners & 4)) + ArrayQ[NumItems++] = CQuadItem(x, y + h, r, -r); // BL + if(!(Corners & 8)) + ArrayQ[NumItems++] = CQuadItem(x + w, y + h, -r, -r); // BR + + if(NumItems > 0) + QuadContainerAddQuads(ContainerIndex, ArrayQ, NumItems); + + QuadContainerUpload(ContainerIndex); + QuadContainerChangeAutomaticUpload(ContainerIndex, true); + + return ContainerIndex; +} + +void CGraphics_Threaded::DrawRect(float x, float y, float w, float h, ColorRGBA Color, int Corners, float Rounding) +{ + TextureClear(); + QuadsBegin(); + SetColor(Color); + DrawRectExt(x, y, w, h, Rounding, Corners); + QuadsEnd(); +} + +void CGraphics_Threaded::DrawRect4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding) +{ + TextureClear(); + QuadsBegin(); + DrawRectExt4(x, y, w, h, ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight, Rounding, Corners); + QuadsEnd(); +} + void CGraphics_Threaded::DrawCircle(float CenterX, float CenterY, float Radius, int Segments) { IGraphics::CFreeformItem aItems[32]; diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 8362d36ec..594131403 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -1127,6 +1127,11 @@ public: void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) override; void QuadsText(float x, float y, float Size, const char *pText) override; + void DrawRectExt(float x, float y, float w, float h, float r, int Corners) override; + void DrawRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners) override; + int CreateRectQuadContainer(float x, float y, float w, float h, float r, int Corners) override; + void DrawRect(float x, float y, float w, float h, ColorRGBA Color, int Corners, float Rounding) override; + void DrawRect4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding) override; void DrawCircle(float CenterX, float CenterY, float Radius, int Segments) override; const GL_STexCoord *GetCurTextureCoordinates() override diff --git a/src/engine/graphics.h b/src/engine/graphics.h index d77b7df44..c84524f8b 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -457,6 +457,11 @@ public: CORNER_ALL = CORNER_T | CORNER_B }; + virtual void DrawRectExt(float x, float y, float w, float h, float r, int Corners) = 0; + virtual void DrawRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners) = 0; + virtual int CreateRectQuadContainer(float x, float y, float w, float h, float r, int Corners) = 0; + virtual void DrawRect(float x, float y, float w, float h, ColorRGBA Color, int Corners, float Rounding) = 0; + virtual void DrawRect4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding) = 0; virtual void DrawCircle(float CenterX, float CenterY, float Radius, int Segments) = 0; struct CColorVertex diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 8be0ca1ef..a9625598d 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -1153,7 +1153,7 @@ void CChat::OnPrepareLines() { float Height = m_aLines[r].m_aYOffset[OffsetType]; Graphics()->SetColor(1, 1, 1, 1); - m_aLines[r].m_QuadContainerIndex = RenderTools()->CreateRoundRectQuadContainer(Begin, y, (AppendCursor.m_LongestLineWidth - TextBegin) + RealMsgPaddingX * 1.5f, Height, MESSAGE_ROUNDING, IGraphics::CORNER_ALL); + m_aLines[r].m_QuadContainerIndex = Graphics()->CreateRectQuadContainer(Begin, y, (AppendCursor.m_LongestLineWidth - TextBegin) + RealMsgPaddingX * 1.5f, Height, MESSAGE_ROUNDING, IGraphics::CORNER_ALL); } TextRender()->SetRenderFlags(CurRenderFlags); diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 49864bf71..a91fc4980 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -545,7 +545,7 @@ void CGameConsole::PossibleCommandsRenderCallback(int Index, const char *pStr, v if(pInfo->m_EnumCount == pInfo->m_WantedCompletion) { float tw = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_pFont, pInfo->m_Cursor.m_FontSize, pStr, -1, -1.0f); - pInfo->m_pSelf->RenderTools()->DrawRect(pInfo->m_Cursor.m_X - 2.5f, pInfo->m_Cursor.m_Y - 4.f / 2.f, tw + 5.f, pInfo->m_Cursor.m_FontSize + 4.f, ColorRGBA(229.0f / 255.0f, 185.0f / 255.0f, 4.0f / 255.0f, 0.85f), IGraphics::CORNER_ALL, pInfo->m_Cursor.m_FontSize / 3.f); + pInfo->m_pSelf->Graphics()->DrawRect(pInfo->m_Cursor.m_X - 2.5f, pInfo->m_Cursor.m_Y - 4.f / 2.f, tw + 5.f, pInfo->m_Cursor.m_FontSize + 4.f, ColorRGBA(229.0f / 255.0f, 185.0f / 255.0f, 4.0f / 255.0f, 0.85f), IGraphics::CORNER_ALL, pInfo->m_Cursor.m_FontSize / 3.f); // scroll when out of sight if(pInfo->m_Cursor.m_X < 3.0f) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 64e3ba896..fb359b9c4 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -206,7 +206,7 @@ void CHud::RenderScoreHud() Graphics()->SetColor(1.0f, 0.0f, 0.0f, 0.25f); else Graphics()->SetColor(0.0f, 0.0f, 1.0f, 0.25f); - m_aScoreInfo[t].m_RoundRectQuadContainerIndex = RenderTools()->CreateRoundRectQuadContainer(m_Width - ScoreWidthMax - ImageSize - 2 * Split, StartY + t * 20, ScoreWidthMax + ImageSize + 2 * Split, ScoreSingleBoxHeight, 5.0f, IGraphics::CORNER_L); + m_aScoreInfo[t].m_RoundRectQuadContainerIndex = Graphics()->CreateRectQuadContainer(m_Width - ScoreWidthMax - ImageSize - 2 * Split, StartY + t * 20, ScoreWidthMax + ImageSize + 2 * Split, ScoreSingleBoxHeight, 5.0f, IGraphics::CORNER_L); } Graphics()->TextureClear(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -386,7 +386,7 @@ void CHud::RenderScoreHud() Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f); else Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.25f); - m_aScoreInfo[t].m_RoundRectQuadContainerIndex = RenderTools()->CreateRoundRectQuadContainer(m_Width - ScoreWidthMax - ImageSize - 2 * Split - PosSize, StartY + t * 20, ScoreWidthMax + ImageSize + 2 * Split + PosSize, ScoreSingleBoxHeight, 5.0f, IGraphics::CORNER_L); + m_aScoreInfo[t].m_RoundRectQuadContainerIndex = Graphics()->CreateRectQuadContainer(m_Width - ScoreWidthMax - ImageSize - 2 * Split - PosSize, StartY + t * 20, ScoreWidthMax + ImageSize + 2 * Split + PosSize, ScoreSingleBoxHeight, 5.0f, IGraphics::CORNER_L); } Graphics()->TextureClear(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -578,7 +578,7 @@ void CHud::RenderVoting() if((!g_Config.m_ClShowVotesAfterVoting && !m_pClient->m_Scoreboard.Active() && m_pClient->m_Voting.TakenChoice()) || !m_pClient->m_Voting.IsVoting() || Client()->State() == IClient::STATE_DEMOPLAYBACK) return; - RenderTools()->DrawRect(-10, 60 - 2, 100 + 10 + 4 + 5, 46, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_ALL, 5.0f); + Graphics()->DrawRect(-10, 60 - 2, 100 + 10 + 4 + 5, 46, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_ALL, 5.0f); TextRender()->TextColor(1, 1, 1, 1); @@ -1288,7 +1288,7 @@ void CHud::RenderDummyActions() StartY -= 56; } - RenderTools()->DrawRect(StartX, StartY, BoxWidth, BoxHeight, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_L, 5.0f); + Graphics()->DrawRect(StartX, StartY, BoxWidth, BoxHeight, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_L, 5.0f); float y = StartY + 2; float x = StartX + 2; @@ -1358,7 +1358,7 @@ void CHud::RenderMovementInformation(const int ClientID) StartY -= 56; } - RenderTools()->DrawRect(StartX, StartY, BoxWidth, BoxHeight, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_L, 5.0f); + Graphics()->DrawRect(StartX, StartY, BoxWidth, BoxHeight, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_L, 5.0f); CNetObj_Character *pCharacter = &m_pClient->m_Snap.m_aCharacters[ClientID].m_Cur; const float TicksPerSecond = 50.0f; @@ -1480,7 +1480,7 @@ void CHud::RenderMovementInformation(const int ClientID) void CHud::RenderSpectatorHud() { // draw the box - RenderTools()->DrawRect(m_Width - 180.0f, m_Height - 15.0f, 180.0f, 15.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_TL, 5.0f); + Graphics()->DrawRect(m_Width - 180.0f, m_Height - 15.0f, 180.0f, 15.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_TL, 5.0f); // draw the text char aBuf[128]; @@ -1494,7 +1494,7 @@ void CHud::RenderLocalTime(float x) return; // draw the box - RenderTools()->DrawRect(x - 30.0f, 0.0f, 25.0f, 12.5f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_B, 3.75f); + Graphics()->DrawRect(x - 30.0f, 0.0f, 25.0f, 12.5f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_B, 3.75f); // draw the text char aTimeStr[6]; diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 6c0b4ae18..d4867a34f 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -940,7 +940,7 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre UI()->DoLabel(&Part, pContent, 20.0f, TEXTALIGN_CENTER); if(RenderLoadingBar) - RenderTools()->DrawRect(Box.x + 40, Box.y + Box.h - 75, (Box.w - 80) * Percent, 25, ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f), IGraphics::CORNER_ALL, 5.0f); + Graphics()->DrawRect(Box.x + 40, Box.y + Box.h - 75, (Box.w - 80) * Percent, 25, ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f), IGraphics::CORNER_ALL, 5.0f); Client()->UpdateAndSwap(); } diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 59e7ad8c9..02138b125 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -162,7 +162,7 @@ class CMenus : public CComponent Graphics()->SetColor(Color); CUIElement::SUIElementRect &NewRect = *UIElement.Get(i); - NewRect.m_UIRectQuadContainer = RenderTools()->CreateRoundRectQuadContainer(pRect->x, pRect->y, pRect->w, pRect->h, r, Corners); + NewRect.m_UIRectQuadContainer = Graphics()->CreateRectQuadContainer(pRect->x, pRect->y, pRect->w, pRect->h, r, Corners); NewRect.m_X = pRect->x; NewRect.m_Y = pRect->y; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index eca7d7d61..caba8bb73 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -2139,7 +2139,7 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool { const float SizeBorder = 5.0f; Graphics()->SetColor(ColorRGBA(0.15f, 0.15f, 0.15f, 1)); - int TmpCont = RenderTools()->CreateRoundRectQuadContainer(Preview.x - SizeBorder / 2.0f, Preview.y - SizeBorder / 2.0f, Preview.w + SizeBorder, Preview.h + SizeBorder, 4.0f + SizeBorder / 2.0f, IGraphics::CORNER_ALL); + int TmpCont = Graphics()->CreateRectQuadContainer(Preview.x - SizeBorder / 2.0f, Preview.y - SizeBorder / 2.0f, Preview.w + SizeBorder, Preview.h + SizeBorder, 4.0f + SizeBorder / 2.0f, IGraphics::CORNER_ALL); Graphics()->RenderQuadContainer(TmpCont, -1); Graphics()->DeleteQuadContainer(TmpCont); } @@ -2147,7 +2147,7 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool if(ClampedLight) RenderColorHSLA = RenderColorHSLA.UnclampLighting(); Graphics()->SetColor(color_cast(RenderColorHSLA)); - int TmpCont = RenderTools()->CreateRoundRectQuadContainer(Preview.x, Preview.y, Preview.w, Preview.h, 4.0f, IGraphics::CORNER_ALL); + int TmpCont = Graphics()->CreateRectQuadContainer(Preview.x, Preview.y, Preview.w, Preview.h, 4.0f, IGraphics::CORNER_ALL); Graphics()->RenderQuadContainer(TmpCont, -1); Graphics()->DeleteQuadContainer(TmpCont); @@ -2696,32 +2696,32 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) { str_format(aLineBuilder, sizeof(aLineBuilder), "*** '%s' entered and joined the game", aBuf); Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); + Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); TempY += RealOffsetY; } str_format(aLineBuilder, sizeof(aLineBuilder), "%sRandom Tee: Hey, how are you %s?", g_Config.m_ClShowIDs ? " 7: " : "", aBuf); Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); + Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); TempY += RealOffsetY; str_format(aLineBuilder, sizeof(aLineBuilder), "%sYour Teammate: Let's speedrun this!", g_Config.m_ClShowIDs ? "11: " : ""); Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); + Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); TempY += RealOffsetY; str_format(aLineBuilder, sizeof(aLineBuilder), "%s%sFriend: Hello there", g_Config.m_ClMessageFriend ? "♥ " : "", g_Config.m_ClShowIDs ? " 8: " : ""); Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); + Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); TempY += RealOffsetY; str_format(aLineBuilder, sizeof(aLineBuilder), "%sSpammer [6]: Hey fools, I'm spamming here!", g_Config.m_ClShowIDs ? " 9: " : ""); Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); + Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); TempY += RealOffsetY; Width = TextRender()->TextWidth(0, RealFontSize, "*** Echo command executed", -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); + Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL); Graphics()->QuadsEnd(); diff --git a/src/game/client/components/motd.cpp b/src/game/client/components/motd.cpp index 6fecd704a..d38e38439 100644 --- a/src/game/client/components/motd.cpp +++ b/src/game/client/components/motd.cpp @@ -41,7 +41,7 @@ void CMotd::OnRender() float x = Width / 2 - w / 2; float y = 150.0f; - RenderTools()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 40.0f); + Graphics()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 40.0f); TextRender()->Text(0, x + 40.0f, y + 40.0f, 32.0f, m_aServerMotd, w - 80.0f); } diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index d166cb680..886e128ae 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -57,7 +57,7 @@ void CScoreboard::RenderGoals(float x, float y, float w) { float h = 50.0f; - RenderTools()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 10.0f); + Graphics()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 10.0f); // render goals if(m_pClient->m_Snap.m_pGameInfoObj) @@ -87,7 +87,7 @@ void CScoreboard::RenderGoals(float x, float y, float w) void CScoreboard::RenderSpectators(float x, float y, float w, float h) { // background - RenderTools()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 10.0f); + Graphics()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 10.0f); // Headline y += 10.0f; @@ -173,7 +173,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch Corners = IGraphics::CORNER_L; else Corners = IGraphics::CORNER_ALL; - RenderTools()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), Corners, 17.0f); + Graphics()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), Corners, 17.0f); } char aBuf[128] = {0}; @@ -361,7 +361,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch Corners |= IGraphics::CORNER_TL | IGraphics::CORNER_TR; if(NextDDTeam != DDTeam) Corners |= IGraphics::CORNER_BL | IGraphics::CORNER_BR; - RenderTools()->DrawRect(x - 10.0f, y, w, LineHeight + Spacing, Color, Corners, RoundRadius); + Graphics()->DrawRect(x - 10.0f, y, w, LineHeight + Spacing, Color, Corners, RoundRadius); if(NextDDTeam != DDTeam) { @@ -393,7 +393,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch // background so it's easy to find the local player or the followed one in spectator mode if((!m_pClient->m_Snap.m_SpecInfo.m_Active && pInfo->m_Local) || (m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW && pInfo->m_Local) || (m_pClient->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientID == m_pClient->m_Snap.m_SpecInfo.m_SpectatorID)) { - RenderTools()->DrawRect(x, y, w - 20.0f, LineHeight, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, RoundRadius); + Graphics()->DrawRect(x, y, w - 20.0f, LineHeight, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, RoundRadius); } // score @@ -565,10 +565,10 @@ void CScoreboard::RenderRecordingNotification(float x) float w = TextRender()->TextWidth(0, 20.0f, aBuf, -1, -1.0f); // draw the box - RenderTools()->DrawRect(x, 0.0f, w + 60.0f, 50.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_B, 15.0f); + Graphics()->DrawRect(x, 0.0f, w + 60.0f, 50.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_B, 15.0f); // draw the red dot - RenderTools()->DrawRect(x + 20, 15.0f, 20.0f, 20.0f, ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), IGraphics::CORNER_ALL, 10.0f); + Graphics()->DrawRect(x + 20, 15.0f, 20.0f, 20.0f, ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), IGraphics::CORNER_ALL, 10.0f); TextRender()->Text(0, x + 50.0f, (50.f - 20.f) / 2.f, 20.0f, aBuf, -1.0f); } diff --git a/src/game/client/components/spectator.cpp b/src/game/client/components/spectator.cpp index d3c398c60..0741a9c1e 100644 --- a/src/game/client/components/spectator.cpp +++ b/src/game/client/components/spectator.cpp @@ -243,7 +243,7 @@ void CSpectator::OnRender() Graphics()->MapScreen(0, 0, Width, Height); - RenderTools()->DrawRect(Width / 2.0f - ObjWidth, Height / 2.0f - 300.0f, ObjWidth * 2, 600.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f), IGraphics::CORNER_ALL, 20.0f); + Graphics()->DrawRect(Width / 2.0f - ObjWidth, Height / 2.0f - 300.0f, ObjWidth * 2, 600.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f), IGraphics::CORNER_ALL, 20.0f); // clamp mouse position to selector area m_SelectorMouse.x = clamp(m_SelectorMouse.x, -(ObjWidth - 20.0f), ObjWidth - 20.0f); @@ -253,12 +253,12 @@ void CSpectator::OnRender() if((Client()->State() == IClient::STATE_DEMOPLAYBACK && m_pClient->m_DemoSpecID == SPEC_FREEVIEW) || m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW) { - RenderTools()->DrawRect(Width / 2.0f - (ObjWidth - 20.0f), Height / 2.0f - 280.0f, 270.0f, 60.0f, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, 20.0f); + Graphics()->DrawRect(Width / 2.0f - (ObjWidth - 20.0f), Height / 2.0f - 280.0f, 270.0f, 60.0f, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, 20.0f); } if(Client()->State() == IClient::STATE_DEMOPLAYBACK && m_pClient->m_DemoSpecID == SPEC_FOLLOW) { - RenderTools()->DrawRect(Width / 2.0f - (ObjWidth - 310.0f), Height / 2.0f - 280.0f, 270.0f, 60.0f, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, 20.0f); + Graphics()->DrawRect(Width / 2.0f - (ObjWidth - 310.0f), Height / 2.0f - 280.0f, 270.0f, 60.0f, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, 20.0f); } if(m_SelectorMouse.x >= -(ObjWidth - 20.0f) && m_SelectorMouse.x <= -(ObjWidth - 290 + 10.0f) && @@ -337,14 +337,14 @@ void CSpectator::OnRender() Corners |= IGraphics::CORNER_TL | IGraphics::CORNER_TR; if(NextDDTeam != DDTeam) Corners |= IGraphics::CORNER_BL | IGraphics::CORNER_BR; - RenderTools()->DrawRect(Width / 2.0f + x - 10.0f + BoxOffset, Height / 2.0f + y + BoxMove, 270.0f - BoxOffset, LineHeight, Color, Corners, RoundRadius); + Graphics()->DrawRect(Width / 2.0f + x - 10.0f + BoxOffset, Height / 2.0f + y + BoxMove, 270.0f - BoxOffset, LineHeight, Color, Corners, RoundRadius); } OldDDTeam = DDTeam; if((Client()->State() == IClient::STATE_DEMOPLAYBACK && m_pClient->m_DemoSpecID == m_pClient->m_Snap.m_apInfoByDDTeamName[i]->m_ClientID) || (Client()->State() != IClient::STATE_DEMOPLAYBACK && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == m_pClient->m_Snap.m_apInfoByDDTeamName[i]->m_ClientID)) { - RenderTools()->DrawRect(Width / 2.0f + x - 10.0f + BoxOffset, Height / 2.0f + y + BoxMove, 270.0f - BoxOffset, LineHeight, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, RoundRadius); + Graphics()->DrawRect(Width / 2.0f + x - 10.0f + BoxOffset, Height / 2.0f + y + BoxMove, 270.0f - BoxOffset, LineHeight, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, RoundRadius); } Selected = false; diff --git a/src/game/client/components/statboard.cpp b/src/game/client/components/statboard.cpp index 93fcc7e3e..f802b9049 100644 --- a/src/game/client/components/statboard.cpp +++ b/src/game/client/components/statboard.cpp @@ -189,7 +189,7 @@ void CStatboard::RenderGlobalStats() Graphics()->MapScreen(0, 0, StatboardWidth, StatboardHeight); - RenderTools()->DrawRect(x - 10.f, y - 10.f, StatboardContentWidth, StatboardContentHeight, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 17.0f); + Graphics()->DrawRect(x - 10.f, y - 10.f, StatboardContentWidth, StatboardContentHeight, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 17.0f); float tw; int px = 325; @@ -267,7 +267,7 @@ void CStatboard::RenderGlobalStats() if(m_pClient->m_Snap.m_LocalClientID == pInfo->m_ClientID || (m_pClient->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientID == m_pClient->m_Snap.m_SpecInfo.m_SpectatorID)) { // background so it's easy to find the local player - RenderTools()->DrawRect(x - 10, y + ContentLineOffset / 2, StatboardContentWidth, LineHeight - ContentLineOffset, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_NONE, 0.0f); + Graphics()->DrawRect(x - 10, y + ContentLineOffset / 2, StatboardContentWidth, LineHeight - ContentLineOffset, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_NONE, 0.0f); } CTeeRenderInfo Teeinfo = m_pClient->m_aClients[pInfo->m_ClientID].m_RenderInfo; diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index e1223f008..5d1f951b3 100644 --- a/src/game/client/render.cpp +++ b/src/game/client/render.cpp @@ -167,315 +167,6 @@ int CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float X, float return Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1); } -void CRenderTools::DrawRoundRectExt(float x, float y, float w, float h, float r, int Corners) -{ - int NumItems = 0; - const int Num = 8; - - IGraphics::CFreeformItem ArrayF[Num * 4]; - - for(int i = 0; i < Num; i += 2) - { - float a1 = i / (float)Num * pi / 2; - float a2 = (i + 1) / (float)Num * pi / 2; - float a3 = (i + 2) / (float)Num * pi / 2; - float Ca1 = cosf(a1); - float Ca2 = cosf(a2); - float Ca3 = cosf(a3); - float Sa1 = sinf(a1); - float Sa2 = sinf(a2); - float Sa3 = sinf(a3); - - if(Corners & 1) // TL - ArrayF[NumItems++] = IGraphics::CFreeformItem( - x + r, y + r, - x + (1 - Ca1) * r, y + (1 - Sa1) * r, - x + (1 - Ca3) * r, y + (1 - Sa3) * r, - x + (1 - Ca2) * r, y + (1 - Sa2) * r); - - if(Corners & 2) // TR - ArrayF[NumItems++] = IGraphics::CFreeformItem( - x + w - r, y + r, - x + w - r + Ca1 * r, y + (1 - Sa1) * r, - x + w - r + Ca3 * r, y + (1 - Sa3) * r, - x + w - r + Ca2 * r, y + (1 - Sa2) * r); - - if(Corners & 4) // BL - ArrayF[NumItems++] = IGraphics::CFreeformItem( - x + r, y + h - r, - x + (1 - Ca1) * r, y + h - r + Sa1 * r, - x + (1 - Ca3) * r, y + h - r + Sa3 * r, - x + (1 - Ca2) * r, y + h - r + Sa2 * r); - - if(Corners & 8) // BR - ArrayF[NumItems++] = IGraphics::CFreeformItem( - x + w - r, y + h - r, - x + w - r + Ca1 * r, y + h - r + Sa1 * r, - x + w - r + Ca3 * r, y + h - r + Sa3 * r, - x + w - r + Ca2 * r, y + h - r + Sa2 * r); - } - Graphics()->QuadsDrawFreeform(ArrayF, NumItems); - - IGraphics::CQuadItem ArrayQ[9]; - NumItems = 0; - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + r, y + r, w - r * 2, h - r * 2); // center - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + r, y, w - r * 2, r); // top - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + r, y + h - r, w - r * 2, r); // bottom - ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y + r, r, h - r * 2); // left - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + w - r, y + r, r, h - r * 2); // right - - if(!(Corners & 1)) - ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y, r, r); // TL - if(!(Corners & 2)) - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + w, y, -r, r); // TR - if(!(Corners & 4)) - ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y + h, r, -r); // BL - if(!(Corners & 8)) - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + w, y + h, -r, -r); // BR - - Graphics()->QuadsDrawTL(ArrayQ, NumItems); -} - -void CRenderTools::DrawRoundRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners) -{ - if(Corners == 0 || r == 0.0f) - { - Graphics()->SetColor4(ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight); - IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(x, y, w, h); - Graphics()->QuadsDrawTL(&ItemQ, 1); - return; - } - - int Num = 8; - for(int i = 0; i < Num; i += 2) - { - float a1 = i / (float)Num * pi / 2; - float a2 = (i + 1) / (float)Num * pi / 2; - float a3 = (i + 2) / (float)Num * pi / 2; - float Ca1 = cosf(a1); - float Ca2 = cosf(a2); - float Ca3 = cosf(a3); - float Sa1 = sinf(a1); - float Sa2 = sinf(a2); - float Sa3 = sinf(a3); - - if(Corners & 1) // TL - { - Graphics()->SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a); - IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( - x + r, y + r, - x + (1 - Ca1) * r, y + (1 - Sa1) * r, - x + (1 - Ca3) * r, y + (1 - Sa3) * r, - x + (1 - Ca2) * r, y + (1 - Sa2) * r); - Graphics()->QuadsDrawFreeform(&ItemF, 1); - } - - if(Corners & 2) // TR - { - Graphics()->SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a); - IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( - x + w - r, y + r, - x + w - r + Ca1 * r, y + (1 - Sa1) * r, - x + w - r + Ca3 * r, y + (1 - Sa3) * r, - x + w - r + Ca2 * r, y + (1 - Sa2) * r); - Graphics()->QuadsDrawFreeform(&ItemF, 1); - } - - if(Corners & 4) // BL - { - Graphics()->SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a); - IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( - x + r, y + h - r, - x + (1 - Ca1) * r, y + h - r + Sa1 * r, - x + (1 - Ca3) * r, y + h - r + Sa3 * r, - x + (1 - Ca2) * r, y + h - r + Sa2 * r); - Graphics()->QuadsDrawFreeform(&ItemF, 1); - } - - if(Corners & 8) // BR - { - Graphics()->SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a); - IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( - x + w - r, y + h - r, - x + w - r + Ca1 * r, y + h - r + Sa1 * r, - x + w - r + Ca3 * r, y + h - r + Sa3 * r, - x + w - r + Ca2 * r, y + h - r + Sa2 * r); - Graphics()->QuadsDrawFreeform(&ItemF, 1); - } - - if(Corners & 16) // ITL - { - Graphics()->SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a); - IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( - x, y, - x + (1 - Ca1) * r, y - r + Sa1 * r, - x + (1 - Ca3) * r, y - r + Sa3 * r, - x + (1 - Ca2) * r, y - r + Sa2 * r); - Graphics()->QuadsDrawFreeform(&ItemF, 1); - } - - if(Corners & 32) // ITR - { - Graphics()->SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a); - IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( - x + w, y, - x + w - r + Ca1 * r, y - r + Sa1 * r, - x + w - r + Ca3 * r, y - r + Sa3 * r, - x + w - r + Ca2 * r, y - r + Sa2 * r); - Graphics()->QuadsDrawFreeform(&ItemF, 1); - } - - if(Corners & 64) // IBL - { - Graphics()->SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a); - IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( - x, y + h, - x + (1 - Ca1) * r, y + h + (1 - Sa1) * r, - x + (1 - Ca3) * r, y + h + (1 - Sa3) * r, - x + (1 - Ca2) * r, y + h + (1 - Sa2) * r); - Graphics()->QuadsDrawFreeform(&ItemF, 1); - } - - if(Corners & 128) // IBR - { - Graphics()->SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a); - IGraphics::CFreeformItem ItemF = IGraphics::CFreeformItem( - x + w, y + h, - x + w - r + Ca1 * r, y + h + (1 - Sa1) * r, - x + w - r + Ca3 * r, y + h + (1 - Sa3) * r, - x + w - r + Ca2 * r, y + h + (1 - Sa2) * r); - Graphics()->QuadsDrawFreeform(&ItemF, 1); - } - } - - Graphics()->SetColor4(ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight); - IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(x + r, y + r, w - r * 2, h - r * 2); // center - Graphics()->QuadsDrawTL(&ItemQ, 1); - Graphics()->SetColor4(ColorTopLeft, ColorTopRight, ColorTopLeft, ColorTopRight); - ItemQ = IGraphics::CQuadItem(x + r, y, w - r * 2, r); // top - Graphics()->QuadsDrawTL(&ItemQ, 1); - Graphics()->SetColor4(ColorBottomLeft, ColorBottomRight, ColorBottomLeft, ColorBottomRight); - ItemQ = IGraphics::CQuadItem(x + r, y + h - r, w - r * 2, r); // bottom - Graphics()->QuadsDrawTL(&ItemQ, 1); - Graphics()->SetColor4(ColorTopLeft, ColorTopLeft, ColorBottomLeft, ColorBottomLeft); - ItemQ = IGraphics::CQuadItem(x, y + r, r, h - r * 2); // left - Graphics()->QuadsDrawTL(&ItemQ, 1); - Graphics()->SetColor4(ColorTopRight, ColorTopRight, ColorBottomRight, ColorBottomRight); - ItemQ = IGraphics::CQuadItem(x + w - r, y + r, r, h - r * 2); // right - Graphics()->QuadsDrawTL(&ItemQ, 1); - - if(!(Corners & 1)) - { - Graphics()->SetColor(ColorTopLeft.r, ColorTopLeft.g, ColorTopLeft.b, ColorTopLeft.a); - ItemQ = IGraphics::CQuadItem(x, y, r, r); // TL - Graphics()->QuadsDrawTL(&ItemQ, 1); - } - if(!(Corners & 2)) - { - Graphics()->SetColor(ColorTopRight.r, ColorTopRight.g, ColorTopRight.b, ColorTopRight.a); - ItemQ = IGraphics::CQuadItem(x + w, y, -r, r); // TR - Graphics()->QuadsDrawTL(&ItemQ, 1); - } - if(!(Corners & 4)) - { - Graphics()->SetColor(ColorBottomLeft.r, ColorBottomLeft.g, ColorBottomLeft.b, ColorBottomLeft.a); - ItemQ = IGraphics::CQuadItem(x, y + h, r, -r); // BL - Graphics()->QuadsDrawTL(&ItemQ, 1); - } - if(!(Corners & 8)) - { - Graphics()->SetColor(ColorBottomRight.r, ColorBottomRight.g, ColorBottomRight.b, ColorBottomRight.a); - ItemQ = IGraphics::CQuadItem(x + w, y + h, -r, -r); // BR - Graphics()->QuadsDrawTL(&ItemQ, 1); - } -} - -int CRenderTools::CreateRoundRectQuadContainer(float x, float y, float w, float h, float r, int Corners) -{ - int ContainerIndex = Graphics()->CreateQuadContainer(false); - - if(Corners == 0 || r == 0.0f) - { - IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(x, y, w, h); - Graphics()->QuadContainerAddQuads(ContainerIndex, &ItemQ, 1); - Graphics()->QuadContainerUpload(ContainerIndex); - Graphics()->QuadContainerChangeAutomaticUpload(ContainerIndex, true); - return ContainerIndex; - } - - IGraphics::CFreeformItem ArrayF[32]; - int NumItems = 0; - int Num = 8; - for(int i = 0; i < Num; i += 2) - { - float a1 = i / (float)Num * pi / 2; - float a2 = (i + 1) / (float)Num * pi / 2; - float a3 = (i + 2) / (float)Num * pi / 2; - float Ca1 = cosf(a1); - float Ca2 = cosf(a2); - float Ca3 = cosf(a3); - float Sa1 = sinf(a1); - float Sa2 = sinf(a2); - float Sa3 = sinf(a3); - - if(Corners & 1) // TL - ArrayF[NumItems++] = IGraphics::CFreeformItem( - x + r, y + r, - x + (1 - Ca1) * r, y + (1 - Sa1) * r, - x + (1 - Ca3) * r, y + (1 - Sa3) * r, - x + (1 - Ca2) * r, y + (1 - Sa2) * r); - - if(Corners & 2) // TR - ArrayF[NumItems++] = IGraphics::CFreeformItem( - x + w - r, y + r, - x + w - r + Ca1 * r, y + (1 - Sa1) * r, - x + w - r + Ca3 * r, y + (1 - Sa3) * r, - x + w - r + Ca2 * r, y + (1 - Sa2) * r); - - if(Corners & 4) // BL - ArrayF[NumItems++] = IGraphics::CFreeformItem( - x + r, y + h - r, - x + (1 - Ca1) * r, y + h - r + Sa1 * r, - x + (1 - Ca3) * r, y + h - r + Sa3 * r, - x + (1 - Ca2) * r, y + h - r + Sa2 * r); - - if(Corners & 8) // BR - ArrayF[NumItems++] = IGraphics::CFreeformItem( - x + w - r, y + h - r, - x + w - r + Ca1 * r, y + h - r + Sa1 * r, - x + w - r + Ca3 * r, y + h - r + Sa3 * r, - x + w - r + Ca2 * r, y + h - r + Sa2 * r); - } - - if(NumItems > 0) - Graphics()->QuadContainerAddQuads(ContainerIndex, ArrayF, NumItems); - - IGraphics::CQuadItem ArrayQ[9]; - NumItems = 0; - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + r, y + r, w - r * 2, h - r * 2); // center - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + r, y, w - r * 2, r); // top - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + r, y + h - r, w - r * 2, r); // bottom - ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y + r, r, h - r * 2); // left - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + w - r, y + r, r, h - r * 2); // right - - if(!(Corners & 1)) - ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y, r, r); // TL - if(!(Corners & 2)) - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + w, y, -r, r); // TR - if(!(Corners & 4)) - ArrayQ[NumItems++] = IGraphics::CQuadItem(x, y + h, r, -r); // BL - if(!(Corners & 8)) - ArrayQ[NumItems++] = IGraphics::CQuadItem(x + w, y + h, -r, -r); // BR - - if(NumItems > 0) - Graphics()->QuadContainerAddQuads(ContainerIndex, ArrayQ, NumItems); - - Graphics()->QuadContainerUpload(ContainerIndex); - Graphics()->QuadContainerChangeAutomaticUpload(ContainerIndex, true); - - return ContainerIndex; -} - void CRenderTools::DrawUIElRect(CUIElement::SUIElementRect &ElUIRect, const CUIRect *pRect, ColorRGBA Color, int Corners, float Rounding) { bool NeedsRecreate = false; @@ -494,7 +185,7 @@ void CRenderTools::DrawUIElRect(CUIElement::SUIElementRect &ElUIRect, const CUIR ElUIRect.m_QuadColor = Color; Graphics()->SetColor(Color); - ElUIRect.m_UIRectQuadContainer = CreateRoundRectQuadContainer(pRect->x, pRect->y, pRect->w, pRect->h, Rounding, Corners); + ElUIRect.m_UIRectQuadContainer = Graphics()->CreateRectQuadContainer(pRect->x, pRect->y, pRect->w, pRect->h, Rounding, Corners); Graphics()->SetColor(1, 1, 1, 1); } @@ -502,31 +193,14 @@ void CRenderTools::DrawUIElRect(CUIElement::SUIElementRect &ElUIRect, const CUIR Graphics()->RenderQuadContainer(ElUIRect.m_UIRectQuadContainer, -1); } -void CRenderTools::DrawRect(float x, float y, float w, float h, ColorRGBA Color, int Corners, float Rounding) -{ - Graphics()->TextureClear(); - Graphics()->QuadsBegin(); - Graphics()->SetColor(Color); - DrawRoundRectExt(x, y, w, h, Rounding, Corners); - Graphics()->QuadsEnd(); -} - void CRenderTools::DrawUIRect(const CUIRect *pRect, ColorRGBA Color, int Corners, float Rounding) { - DrawRect(pRect->x, pRect->y, pRect->w, pRect->h, Color, Corners, Rounding); -} - -void CRenderTools::DrawRect4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding) -{ - Graphics()->TextureClear(); - Graphics()->QuadsBegin(); - DrawRoundRectExt4(x, y, w, h, ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight, Rounding, Corners); - Graphics()->QuadsEnd(); + Graphics()->DrawRect(pRect->x, pRect->y, pRect->w, pRect->h, Color, Corners, Rounding); } void CRenderTools::DrawUIRect4(const CUIRect *pRect, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding) { - DrawRect4(pRect->x, pRect->y, pRect->w, pRect->h, ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight, Corners, Rounding); + Graphics()->DrawRect4(pRect->x, pRect->y, pRect->w, pRect->h, ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight, Corners, Rounding); } void CRenderTools::GetRenderTeeAnimScaleAndBaseSize(CAnimState *pAnim, CTeeRenderInfo *pInfo, float &AnimScale, float &BaseSize) diff --git a/src/game/client/render.h b/src/game/client/render.h index 704cf0d08..e68beb890 100644 --- a/src/game/client/render.h +++ b/src/game/client/render.h @@ -105,16 +105,8 @@ public: int QuadContainerAddSprite(int QuadContainerIndex, float X, float Y, float Width, float Height); // rects - void DrawRoundRectExt(float x, float y, float w, float h, float r, int Corners); - void DrawRoundRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners); - - int CreateRoundRectQuadContainer(float x, float y, float w, float h, float r, int Corners); - void DrawUIElRect(CUIElement::SUIElementRect &ElUIRect, const CUIRect *pRect, ColorRGBA Color, int Corners, float Rounding); - - void DrawRect(float x, float y, float w, float h, ColorRGBA Color, int Corners, float Rounding); void DrawUIRect(const CUIRect *pRect, ColorRGBA Color, int Corners, float Rounding); - 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); // larger rendering methods diff --git a/src/game/editor/layer_sounds.cpp b/src/game/editor/layer_sounds.cpp index 5d65316ea..279be18b1 100644 --- a/src/game/editor/layer_sounds.cpp +++ b/src/game/editor/layer_sounds.cpp @@ -53,12 +53,12 @@ void CLayerSounds::Render(bool Tileset) { float Width = fx2f(Source.m_Shape.m_Rectangle.m_Width); float Height = fx2f(Source.m_Shape.m_Rectangle.m_Height); - m_pEditor->RenderTools()->DrawRoundRectExt(fx2f(Source.m_Position.x) + OffsetX - Width / 2, fx2f(Source.m_Position.y) + OffsetY - Height / 2, + m_pEditor->Graphics()->DrawRectExt(fx2f(Source.m_Position.x) + OffsetX - Width / 2, fx2f(Source.m_Position.y) + OffsetY - Height / 2, Width, Height, 0.0f, IGraphics::CORNER_NONE); float Falloff = ((float)Source.m_Falloff / 255.0f); if(Falloff > 0.0f) - m_pEditor->RenderTools()->DrawRoundRectExt(fx2f(Source.m_Position.x) + OffsetX - Falloff * Width / 2, fx2f(Source.m_Position.y) + OffsetY - Falloff * Height / 2, + m_pEditor->Graphics()->DrawRectExt(fx2f(Source.m_Position.x) + OffsetX - Falloff * Width / 2, fx2f(Source.m_Position.y) + OffsetY - Falloff * Height / 2, Width * Falloff, Height * Falloff, 0.0f, IGraphics::CORNER_NONE); break; }