Merge pull request #8663 from Robyt3/Menus-Checker-Fix-Optimization

Smoother menu checker background scrolling on loading screens, fix menu checker background on wide resolutions and optimize it
This commit is contained in:
Dennis Felsing 2024-07-28 22:19:19 +00:00 committed by GitHub
commit 83c9b6cae6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View file

@ -3820,6 +3820,7 @@ void CClient::UpdateAndSwap()
Input()->Update();
Graphics()->Swap();
Graphics()->Clear(0, 0, 0);
m_GlobalTime = (time_get() - m_GlobalStartTime) / (float)time_freq();
}
void CClient::ServerBrowserUpdate()

View file

@ -2231,14 +2231,16 @@ void CMenus::RenderBackground()
Graphics()->QuadsBegin();
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.045f);
const float Size = 15.0f;
const float OffsetTime = std::fmod(LocalTime() * 0.15f, 2.0f);
const float OffsetTime = std::fmod(Client()->GlobalTime() * 0.15f, 2.0f);
IGraphics::CQuadItem aCheckerItems[64];
size_t NumCheckerItems = 0;
for(int y = -2; y < (int)(ScreenWidth / Size); y++)
const int NumItemsWidth = std::ceil(ScreenWidth / Size);
const int NumItemsHeight = std::ceil(ScreenHeight / Size);
for(int y = -2; y < NumItemsHeight; y++)
{
for(int x = -2; x < (int)(ScreenHeight / Size); x++)
for(int x = 0; x < NumItemsWidth + 4; x += 2)
{
aCheckerItems[NumCheckerItems] = IGraphics::CQuadItem((x - OffsetTime) * Size * 2 + (y & 1) * Size, (y + OffsetTime) * Size, Size, Size);
aCheckerItems[NumCheckerItems] = IGraphics::CQuadItem((x - 2 * OffsetTime + (y & 1)) * Size, (y + OffsetTime) * Size, Size, Size);
NumCheckerItems++;
if(NumCheckerItems == std::size(aCheckerItems))
{