mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Return the quad offset of the first added quad, when adding new quads
This commit is contained in:
parent
298287fb4e
commit
b8da817716
|
@ -1470,12 +1470,14 @@ void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex)
|
|||
}
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num)
|
||||
int CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num)
|
||||
{
|
||||
SQuadContainer &Container = m_QuadContainers[ContainerIndex];
|
||||
|
||||
if((int)Container.m_Quads.size() > Num + CCommandBuffer::CCommandBuffer::MAX_VERTICES)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
int RetOff = (int)Container.m_Quads.size();
|
||||
|
||||
for(int i = 0; i < Num; ++i)
|
||||
{
|
||||
|
@ -1514,14 +1516,18 @@ void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CQuadItem *pA
|
|||
|
||||
if(Container.m_AutomaticUpload)
|
||||
QuadContainerUpload(ContainerIndex);
|
||||
|
||||
return RetOff;
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num)
|
||||
int CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num)
|
||||
{
|
||||
SQuadContainer &Container = m_QuadContainers[ContainerIndex];
|
||||
|
||||
if((int)Container.m_Quads.size() > Num + CCommandBuffer::CCommandBuffer::MAX_VERTICES)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
int RetOff = (int)Container.m_Quads.size();
|
||||
|
||||
for(int i = 0; i < Num; ++i)
|
||||
{
|
||||
|
@ -1551,6 +1557,8 @@ void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CFreeformItem
|
|||
|
||||
if(Container.m_AutomaticUpload)
|
||||
QuadContainerUpload(ContainerIndex);
|
||||
|
||||
return RetOff;
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::QuadContainerReset(int ContainerIndex)
|
||||
|
|
|
@ -1141,8 +1141,8 @@ public:
|
|||
int CreateQuadContainer(bool AutomaticUpload = true) override;
|
||||
void QuadContainerChangeAutomaticUpload(int ContainerIndex, bool AutomaticUpload) override;
|
||||
void QuadContainerUpload(int ContainerIndex) override;
|
||||
void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) override;
|
||||
void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) override;
|
||||
int QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) override;
|
||||
int QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) override;
|
||||
void QuadContainerReset(int ContainerIndex) override;
|
||||
void DeleteQuadContainer(int ContainerIndex) override;
|
||||
void RenderQuadContainer(int ContainerIndex, int QuadDrawNum) override;
|
||||
|
|
|
@ -422,8 +422,8 @@ public:
|
|||
virtual int CreateQuadContainer(bool AutomaticUpload = true) = 0;
|
||||
virtual void QuadContainerChangeAutomaticUpload(int ContainerIndex, bool AutomaticUpload) = 0;
|
||||
virtual void QuadContainerUpload(int ContainerIndex) = 0;
|
||||
virtual void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) = 0;
|
||||
virtual void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) = 0;
|
||||
virtual int QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) = 0;
|
||||
virtual int QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) = 0;
|
||||
virtual void QuadContainerReset(int ContainerIndex) = 0;
|
||||
virtual void DeleteQuadContainer(int ContainerIndex) = 0;
|
||||
virtual void RenderQuadContainer(int ContainerIndex, int QuadDrawNum) = 0;
|
||||
|
|
|
@ -190,6 +190,10 @@ void CItems::RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCu
|
|||
m_pClient->m_Effects.PowerupShine(Pos, vec2(96, 18));
|
||||
Pos.x -= 10.0f;
|
||||
}
|
||||
else if(c[pCurrent->m_Type] >= SPRITE_PICKUP_ARMOR_SHOTGUN && c[pCurrent->m_Type] <= SPRITE_PICKUP_ARMOR_NINJA)
|
||||
{
|
||||
QuadOffset = m_WeaponArmorQuadOffset + (c[pCurrent->m_Type] - SPRITE_PICKUP_ARMOR_SHOTGUN);
|
||||
}
|
||||
}
|
||||
|
||||
Graphics()->QuadsSetRotation(Angle);
|
||||
|
@ -563,7 +567,7 @@ void CItems::OnInit()
|
|||
|
||||
RenderTools()->GetSpriteScale(SPRITE_PICKUP_ARMOR_SHOTGUN, ScaleX, ScaleY);
|
||||
Graphics()->QuadsSetSubset(0, 0, 1, 1);
|
||||
RenderTools()->QuadContainerAddSprite(m_ItemsQuadContainerIndex, 64.f * ScaleX, 64.f * ScaleY);
|
||||
m_WeaponArmorQuadOffset = RenderTools()->QuadContainerAddSprite(m_ItemsQuadContainerIndex, 64.f * ScaleX, 64.f * ScaleY);
|
||||
RenderTools()->GetSpriteScale(SPRITE_PICKUP_ARMOR_GRENADE, ScaleX, ScaleY);
|
||||
Graphics()->QuadsSetSubset(0, 0, 1, 1);
|
||||
RenderTools()->QuadContainerAddSprite(m_ItemsQuadContainerIndex, 64.f * ScaleX, 64.f * ScaleY);
|
||||
|
|
|
@ -15,6 +15,8 @@ class CItems : public CComponent
|
|||
|
||||
int m_ItemsQuadContainerIndex;
|
||||
|
||||
int m_WeaponArmorQuadOffset = 0;
|
||||
|
||||
public:
|
||||
virtual int Sizeof() const override { return sizeof(*this); }
|
||||
virtual void OnRender() override;
|
||||
|
|
|
@ -129,28 +129,28 @@ void CRenderTools::DrawSprite(float x, float y, float ScaledWidth, float ScaledH
|
|||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
}
|
||||
|
||||
void CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float x, float y, float Size)
|
||||
int CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float x, float y, float Size)
|
||||
{
|
||||
IGraphics::CQuadItem QuadItem(x, y, Size, Size);
|
||||
Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1);
|
||||
return Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1);
|
||||
}
|
||||
|
||||
void CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float Size)
|
||||
int CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float Size)
|
||||
{
|
||||
IGraphics::CQuadItem QuadItem(-(Size) / 2.f, -(Size) / 2.f, (Size), (Size));
|
||||
Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1);
|
||||
return Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1);
|
||||
}
|
||||
|
||||
void CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float Width, float Height)
|
||||
int CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float Width, float Height)
|
||||
{
|
||||
IGraphics::CQuadItem QuadItem(-(Width) / 2.f, -(Height) / 2.f, (Width), (Height));
|
||||
Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1);
|
||||
return Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1);
|
||||
}
|
||||
|
||||
void CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float X, float Y, float Width, float Height)
|
||||
int CRenderTools::QuadContainerAddSprite(int QuadContainerIndex, float X, float Y, float Width, float Height)
|
||||
{
|
||||
IGraphics::CQuadItem QuadItem(X, Y, Width, Height);
|
||||
Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1);
|
||||
return Graphics()->QuadContainerAddQuads(QuadContainerIndex, &QuadItem, 1);
|
||||
}
|
||||
|
||||
void CRenderTools::DrawRoundRectExt(float x, float y, float w, float h, float r, int Corners)
|
||||
|
|
|
@ -82,10 +82,10 @@ public:
|
|||
|
||||
void DrawSprite(float x, float y, float size);
|
||||
void DrawSprite(float x, float y, float ScaledWidth, float ScaledHeight);
|
||||
void QuadContainerAddSprite(int QuadContainerIndex, float x, float y, float size);
|
||||
void QuadContainerAddSprite(int QuadContainerIndex, float size);
|
||||
void QuadContainerAddSprite(int QuadContainerIndex, float Width, float Height);
|
||||
void QuadContainerAddSprite(int QuadContainerIndex, float X, float Y, float Width, float Height);
|
||||
int QuadContainerAddSprite(int QuadContainerIndex, float x, float y, float size);
|
||||
int QuadContainerAddSprite(int QuadContainerIndex, float size);
|
||||
int QuadContainerAddSprite(int QuadContainerIndex, float Width, float Height);
|
||||
int QuadContainerAddSprite(int QuadContainerIndex, float X, float Y, float Width, float Height);
|
||||
|
||||
// rects
|
||||
void DrawRoundRect(float x, float y, float w, float h, float r);
|
||||
|
|
Loading…
Reference in a new issue