Skip to content

Commit 4d16f3f

Browse files
Fix composite rendering glitches
1 parent 7a683cf commit 4d16f3f

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/libprojectM/Renderer/Renderer.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -838,26 +838,21 @@ void Renderer::UvToMathSpace(float u, float v, float* rad, float* ang)
838838
void Renderer::InitCompositeShaderVertex() {
839839

840840
// BUILD VERTEX LIST for final composite blit
841-
// note the +0.5-texel offset!
842-
// (otherwise, a 1-pixel-wide line of the image would wrap at the top and left edges).
843841
memset(m_comp_verts, 0, sizeof(composite_shader_vertex)*FCGSX*FCGSY);
844-
845-
float fHalfTexelW = 0.5f / (float)vw; // 2.5: 2 pixels bad @ bottom right
846-
float fHalfTexelH = 0.5f / (float)vh;
847842
float fDivX = 1.0f / (float)(FCGSX-2);
848843
float fDivY = 1.0f / (float)(FCGSY-2);
849844
for (int j=0; j<FCGSY; j++)
850845
{
851846
int j2 = j - j/(FCGSY/2);
852847
float v = j2*fDivY;
853848
v = SquishToCenter(v, 3.0f);
854-
float sy = -((v-fHalfTexelH)*2-1);//fOnePlusInvHeight*v*2-1;
849+
float sy = -((v)*2-1);
855850
for (int i=0; i<FCGSX; i++)
856851
{
857852
int i2 = i - i/(FCGSX/2);
858853
float u = i2*fDivX;
859854
u = SquishToCenter(u, 3.0f);
860-
float sx = (u-fHalfTexelW)*2-1;//fOnePlusInvWidth*u*2-1;
855+
float sx = (u)*2-1;
861856
composite_shader_vertex* pComp = &m_comp_verts[i + j*FCGSX];
862857
pComp->x = sx;
863858
pComp->y = sy;
@@ -932,17 +927,22 @@ void Renderer::InitCompositeShaderVertex() {
932927
{
933928
*(cur_index+0) = (y )*FCGSX + (x );
934929
*(cur_index+1) = (y )*FCGSX + (x+1);
935-
*(cur_index+2) = (y+1)*FCGSX + (x );
930+
*(cur_index+2) = (y+1)*FCGSX + (x+1);
936931
*(cur_index+3) = (y+1)*FCGSX + (x+1);
932+
*(cur_index+4) = (y+1)*FCGSX + (x );
933+
*(cur_index+5) = (y )*FCGSX + (x );
937934
}
938935
else
939936
{
940937
*(cur_index+0) = (y+1)*FCGSX + (x );
941938
*(cur_index+1) = (y )*FCGSX + (x );
942-
*(cur_index+2) = (y+1)*FCGSX + (x+1);
939+
*(cur_index+2) = (y )*FCGSX + (x+1);
943940
*(cur_index+3) = (y )*FCGSX + (x+1);
941+
*(cur_index+4) = (y+1)*FCGSX + (x+1);
942+
*(cur_index+5) = (y+1)*FCGSX + (x );
944943
}
945-
cur_index += 4;
944+
945+
cur_index += 6;
946946
}
947947
}
948948
}
@@ -996,7 +996,7 @@ void Renderer::CompositeShaderOutput(const Pipeline &pipeline, const PipelineCon
996996
}
997997

998998

999-
int primCount = (FCGSX-2)*(FCGSY-2)*4;
999+
int primCount = (FCGSX-2)*(FCGSY-2)*6;
10001000
composite_shader_vertex tempv[primCount];
10011001
memset(tempv, 0, sizeof(composite_shader_vertex) * primCount);
10021002
int src_idx = 0;
@@ -1017,7 +1017,7 @@ void Renderer::CompositeShaderOutput(const Pipeline &pipeline, const PipelineCon
10171017
glBindVertexArray(m_vao_CompositeShaderOutput);
10181018

10191019
// Now do the final composite blit, fullscreen;
1020-
glDrawArrays(GL_TRIANGLE_STRIP, 0, primCount);
1020+
glDrawArrays(GL_TRIANGLES, 0, primCount);
10211021

10221022
glBindVertexArray(0);
10231023

src/libprojectM/Renderer/Renderer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Renderer
157157
float SquishToCenter(float x, float fExp);
158158
void UvToMathSpace(float u, float v, float* rad, float* ang);
159159
composite_shader_vertex m_comp_verts[FCGSX*FCGSY];
160-
int m_comp_indices[(FCGSX-2)*(FCGSY-2)*4];
160+
int m_comp_indices[(FCGSX-2)*(FCGSY-2)*6];
161161

162162
};
163163

0 commit comments

Comments
 (0)