mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix quad shader
This commit is contained in:
parent
e25ecef906
commit
54d937d88d
|
@ -9,6 +9,8 @@ uniform mat4x2 gPos;
|
||||||
uniform vec2 gOffsets[TW_MAX_QUADS];
|
uniform vec2 gOffsets[TW_MAX_QUADS];
|
||||||
uniform float gRotations[TW_MAX_QUADS];
|
uniform float gRotations[TW_MAX_QUADS];
|
||||||
|
|
||||||
|
uniform int gQuadOffset;
|
||||||
|
|
||||||
noperspective out vec4 QuadColor;
|
noperspective out vec4 QuadColor;
|
||||||
flat out int QuadIndex;
|
flat out int QuadIndex;
|
||||||
#ifdef TW_QUAD_TEXTURED
|
#ifdef TW_QUAD_TEXTURED
|
||||||
|
@ -19,7 +21,7 @@ void main()
|
||||||
{
|
{
|
||||||
vec2 FinalPos = vec2(inVertex.xy);
|
vec2 FinalPos = vec2(inVertex.xy);
|
||||||
|
|
||||||
int TmpQuadIndex = int(gl_VertexID / 4);
|
int TmpQuadIndex = int(gl_VertexID / 4) - gQuadOffset;
|
||||||
|
|
||||||
if(gRotations[TmpQuadIndex] != 0.0)
|
if(gRotations[TmpQuadIndex] != 0.0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2348,6 +2348,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
||||||
m_pQuadProgram->m_LocColors = m_pQuadProgram->GetUniformLoc("gVertColors");
|
m_pQuadProgram->m_LocColors = m_pQuadProgram->GetUniformLoc("gVertColors");
|
||||||
m_pQuadProgram->m_LocRotations = m_pQuadProgram->GetUniformLoc("gRotations");
|
m_pQuadProgram->m_LocRotations = m_pQuadProgram->GetUniformLoc("gRotations");
|
||||||
m_pQuadProgram->m_LocOffsets = m_pQuadProgram->GetUniformLoc("gOffsets");
|
m_pQuadProgram->m_LocOffsets = m_pQuadProgram->GetUniformLoc("gOffsets");
|
||||||
|
m_pQuadProgram->m_LocQuadOffset = m_pQuadProgram->GetUniformLoc("gQuadOffset");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CGLSL VertexShader;
|
CGLSL VertexShader;
|
||||||
|
@ -2370,6 +2371,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
||||||
m_pQuadProgramTextured->m_LocColors = m_pQuadProgramTextured->GetUniformLoc("gVertColors");
|
m_pQuadProgramTextured->m_LocColors = m_pQuadProgramTextured->GetUniformLoc("gVertColors");
|
||||||
m_pQuadProgramTextured->m_LocRotations = m_pQuadProgramTextured->GetUniformLoc("gRotations");
|
m_pQuadProgramTextured->m_LocRotations = m_pQuadProgramTextured->GetUniformLoc("gRotations");
|
||||||
m_pQuadProgramTextured->m_LocOffsets = m_pQuadProgramTextured->GetUniformLoc("gOffsets");
|
m_pQuadProgramTextured->m_LocOffsets = m_pQuadProgramTextured->GetUniformLoc("gOffsets");
|
||||||
|
m_pQuadProgramTextured->m_LocQuadOffset = m_pQuadProgramTextured->GetUniformLoc("gQuadOffset");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
CGLSL VertexShader;
|
CGLSL VertexShader;
|
||||||
|
@ -3346,6 +3348,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadLayer(const CCommandBuff
|
||||||
pProgram->SetUniformVec4(pProgram->m_LocColors, ActualQuadCount, (float *)aColors);
|
pProgram->SetUniformVec4(pProgram->m_LocColors, ActualQuadCount, (float *)aColors);
|
||||||
pProgram->SetUniformVec2(pProgram->m_LocOffsets, ActualQuadCount, (float *)aOffsets);
|
pProgram->SetUniformVec2(pProgram->m_LocOffsets, ActualQuadCount, (float *)aOffsets);
|
||||||
pProgram->SetUniform(pProgram->m_LocRotations, ActualQuadCount, (float *)aRotations);
|
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)));
|
glDrawElements(GL_TRIANGLES, ActualQuadCount * 6, GL_UNSIGNED_INT, (void *)(QuadOffset * 6 * sizeof(unsigned int)));
|
||||||
|
|
||||||
QuadsLeft -= ActualQuadCount;
|
QuadsLeft -= ActualQuadCount;
|
||||||
|
|
|
@ -132,6 +132,7 @@ public:
|
||||||
int m_LocColors;
|
int m_LocColors;
|
||||||
int m_LocOffsets;
|
int m_LocOffsets;
|
||||||
int m_LocRotations;
|
int m_LocRotations;
|
||||||
|
int m_LocQuadOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGLSLTileProgram : public CGLSLTWProgram
|
class CGLSLTileProgram : public CGLSLTWProgram
|
||||||
|
|
Loading…
Reference in a new issue