mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Don't render fully transparent quads
This commit is contained in:
parent
505656313c
commit
288a18fa95
|
@ -3329,6 +3329,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadLayer(const CCommandBuff
|
|||
|
||||
int QuadsLeft = pCommand->m_QuadNum;
|
||||
size_t QuadOffset = 0;
|
||||
// the extra offset is not related to the information from the command, but an actual offset in the buffer
|
||||
size_t QuadOffsetExtra = pCommand->m_QuadOffset;
|
||||
|
||||
vec4 aColors[m_MaxQuadsPossible];
|
||||
vec2 aOffsets[m_MaxQuadsPossible];
|
||||
|
@ -3348,8 +3350,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadLayer(const CCommandBuff
|
|||
pProgram->SetUniformVec4(pProgram->m_LocColors, ActualQuadCount, (float *)aColors);
|
||||
pProgram->SetUniformVec2(pProgram->m_LocOffsets, ActualQuadCount, (float *)aOffsets);
|
||||
pProgram->SetUniform(pProgram->m_LocRotations, ActualQuadCount, (float *)aRotations);
|
||||
pProgram->SetUniform(pProgram->m_LocQuadOffset, (int)QuadOffset);
|
||||
glDrawElements(GL_TRIANGLES, ActualQuadCount * 6, GL_UNSIGNED_INT, (void *)(QuadOffset * 6 * sizeof(unsigned int)));
|
||||
pProgram->SetUniform(pProgram->m_LocQuadOffset, (int)(QuadOffset + QuadOffsetExtra));
|
||||
glDrawElements(GL_TRIANGLES, ActualQuadCount * 6, GL_UNSIGNED_INT, (void *)((QuadOffset + QuadOffsetExtra) * 6 * sizeof(unsigned int)));
|
||||
|
||||
QuadsLeft -= ActualQuadCount;
|
||||
QuadOffset += (size_t)ActualQuadCount;
|
||||
|
|
|
@ -1220,7 +1220,7 @@ void CGraphics_Threaded::RenderBorderTileLines(int BufferContainerIndex, float *
|
|||
}
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum)
|
||||
void CGraphics_Threaded::RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum, int QuadOffset)
|
||||
{
|
||||
if(QuadNum == 0)
|
||||
return;
|
||||
|
@ -1229,6 +1229,7 @@ void CGraphics_Threaded::RenderQuadLayer(int BufferContainerIndex, SQuadRenderIn
|
|||
CCommandBuffer::SCommand_RenderQuadLayer Cmd;
|
||||
Cmd.m_State = m_State;
|
||||
Cmd.m_QuadNum = QuadNum;
|
||||
Cmd.m_QuadOffset = QuadOffset;
|
||||
Cmd.m_BufferContainerIndex = BufferContainerIndex;
|
||||
|
||||
Cmd.m_pQuadInfo = (SQuadRenderInfo *)AllocCommandBufferData(QuadNum * sizeof(SQuadRenderInfo));
|
||||
|
|
|
@ -398,6 +398,7 @@ public:
|
|||
int m_BufferContainerIndex;
|
||||
SQuadRenderInfo *m_pQuadInfo;
|
||||
int m_QuadNum;
|
||||
int m_QuadOffset;
|
||||
};
|
||||
|
||||
struct SCommand_RenderText : public SCommand
|
||||
|
@ -1092,7 +1093,7 @@ public:
|
|||
void RenderTileLayer(int BufferContainerIndex, float *pColor, char **pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet) override;
|
||||
void RenderBorderTiles(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, int JumpIndex, unsigned int DrawNum) override;
|
||||
void RenderBorderTileLines(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, unsigned int IndexDrawNum, unsigned int RedrawNum) override;
|
||||
void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum) override;
|
||||
void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum, int QuadOffset) override;
|
||||
void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, float *pTextColor, float *pTextoutlineColor) override;
|
||||
|
||||
// opengl 3.3 functions
|
||||
|
|
|
@ -253,7 +253,7 @@ public:
|
|||
virtual void RenderTileLayer(int BufferContainerIndex, float *pColor, char **pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet) = 0;
|
||||
virtual void RenderBorderTiles(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, int JumpIndex, unsigned int DrawNum) = 0;
|
||||
virtual void RenderBorderTileLines(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, unsigned int IndexDrawNum, unsigned int RedrawNum) = 0;
|
||||
virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum) = 0;
|
||||
virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum, int QuadOffset) = 0;
|
||||
virtual void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, float *pTextColor, float *pTextoutlineColor) = 0;
|
||||
|
||||
// opengl 3.3 functions
|
||||
|
|
|
@ -1388,6 +1388,8 @@ void CMapLayers::RenderQuadLayer(int LayerIndex, CMapItemLayerQuads *pQuadLayer,
|
|||
static std::vector<SQuadRenderInfo> s_QuadRenderInfo;
|
||||
|
||||
s_QuadRenderInfo.resize(pQuadLayer->m_NumQuads);
|
||||
size_t QuadsRenderCount = 0;
|
||||
size_t CurQuadOffset = 0;
|
||||
for(int i = 0; i < pQuadLayer->m_NumQuads; ++i)
|
||||
{
|
||||
CQuad *q = &pQuads[i];
|
||||
|
@ -1412,13 +1414,24 @@ void CMapLayers::RenderQuadLayer(int LayerIndex, CMapItemLayerQuads *pQuadLayer,
|
|||
Rot = aChannels[2] / 180.0f * pi;
|
||||
}
|
||||
|
||||
SQuadRenderInfo &QInfo = s_QuadRenderInfo[i];
|
||||
mem_copy(QInfo.m_aColor, aColor, sizeof(aColor));
|
||||
QInfo.m_aOffsets[0] = OffsetX;
|
||||
QInfo.m_aOffsets[1] = OffsetY;
|
||||
QInfo.m_Rotation = Rot;
|
||||
if(aColor[3] > 0)
|
||||
{
|
||||
SQuadRenderInfo &QInfo = s_QuadRenderInfo[QuadsRenderCount++];
|
||||
mem_copy(QInfo.m_aColor, aColor, sizeof(aColor));
|
||||
QInfo.m_aOffsets[0] = OffsetX;
|
||||
QInfo.m_aOffsets[1] = OffsetY;
|
||||
QInfo.m_Rotation = Rot;
|
||||
}
|
||||
else
|
||||
{
|
||||
// render quads of the current offset directly(cancel batching)
|
||||
Graphics()->RenderQuadLayer(Visuals.m_BufferContainerIndex, &s_QuadRenderInfo[0], QuadsRenderCount, CurQuadOffset);
|
||||
QuadsRenderCount = 0;
|
||||
// since this quad is ignored, the offset is the next quad
|
||||
CurQuadOffset = i + 1;
|
||||
}
|
||||
}
|
||||
Graphics()->RenderQuadLayer(Visuals.m_BufferContainerIndex, &s_QuadRenderInfo[0], pQuadLayer->m_NumQuads);
|
||||
Graphics()->RenderQuadLayer(Visuals.m_BufferContainerIndex, &s_QuadRenderInfo[0], QuadsRenderCount, CurQuadOffset);
|
||||
}
|
||||
|
||||
void CMapLayers::LayersOfGroupCount(CMapItemGroup *pGroup, int &TileLayerCount, int &QuadLayerCount, bool &PassedGameLayer)
|
||||
|
|
|
@ -115,6 +115,9 @@ void CRenderTools::ForceRenderQuads(CQuad *pQuads, int NumQuads, int RenderFlags
|
|||
a = aChannels[3];
|
||||
}
|
||||
|
||||
if(a <= 0)
|
||||
continue;
|
||||
|
||||
bool Opaque = false;
|
||||
/* TODO: Analyze quadtexture
|
||||
if(a < 0.01f || (q->m_aColors[0].a < 0.01f && q->m_aColors[1].a < 0.01f && q->m_aColors[2].a < 0.01f && q->m_aColors[3].a < 0.01f))
|
||||
|
|
Loading…
Reference in a new issue