3456: Fix quad shader r=def- a=Jupeyy

OGL 3.3 only

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
bors[bot] 2020-12-29 07:58:27 +00:00 committed by GitHub
commit 1211fcdfef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -9,6 +9,8 @@ uniform mat4x2 gPos;
uniform vec2 gOffsets[TW_MAX_QUADS];
uniform float gRotations[TW_MAX_QUADS];
uniform int gQuadOffset;
noperspective out vec4 QuadColor;
flat out int QuadIndex;
#ifdef TW_QUAD_TEXTURED
@ -19,7 +21,7 @@ void main()
{
vec2 FinalPos = vec2(inVertex.xy);
int TmpQuadIndex = int(gl_VertexID / 4);
int TmpQuadIndex = int(gl_VertexID / 4) - gQuadOffset;
if(gRotations[TmpQuadIndex] != 0.0)
{

View file

@ -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_LocRotations = m_pQuadProgram->GetUniformLoc("gRotations");
m_pQuadProgram->m_LocOffsets = m_pQuadProgram->GetUniformLoc("gOffsets");
m_pQuadProgram->m_LocQuadOffset = m_pQuadProgram->GetUniformLoc("gQuadOffset");
}
{
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_LocRotations = m_pQuadProgramTextured->GetUniformLoc("gRotations");
m_pQuadProgramTextured->m_LocOffsets = m_pQuadProgramTextured->GetUniformLoc("gOffsets");
m_pQuadProgramTextured->m_LocQuadOffset = m_pQuadProgramTextured->GetUniformLoc("gQuadOffset");
}
{
CGLSL VertexShader;
@ -3346,6 +3348,7 @@ 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)));
QuadsLeft -= ActualQuadCount;

View file

@ -132,6 +132,7 @@ public:
int m_LocColors;
int m_LocOffsets;
int m_LocRotations;
int m_LocQuadOffset;
};
class CGLSLTileProgram : public CGLSLTWProgram