mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Fix menu checker background on wide resolutions and optimize it
The maximum width and height were swapped as the loop bounds, so the menu checker background did not have the correct width on very wide resolutions. This was not noticed on common resolutions because twice as many quads as necessary were also being rendered for each row of the background. The bounds of the inner loop are adjusted and only every second x-value is iterated, which reduced the total number of quads for the checker background rendering by more than half.
This commit is contained in:
parent
23fb01f9dd
commit
5bd0b06c52
|
@ -2234,11 +2234,13 @@ void CMenus::RenderBackground()
|
||||||
const float OffsetTime = std::fmod(Client()->GlobalTime() * 0.15f, 2.0f);
|
const float OffsetTime = std::fmod(Client()->GlobalTime() * 0.15f, 2.0f);
|
||||||
IGraphics::CQuadItem aCheckerItems[64];
|
IGraphics::CQuadItem aCheckerItems[64];
|
||||||
size_t NumCheckerItems = 0;
|
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++;
|
NumCheckerItems++;
|
||||||
if(NumCheckerItems == std::size(aCheckerItems))
|
if(NumCheckerItems == std::size(aCheckerItems))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue