Skip to content

Commit

Permalink
OpenGL2: Fix sun rays being affected by the viewport size
Browse files Browse the repository at this point in the history
Using r_drawSunRays 1, r_hdr 0, cg_viewsize 50 caused the sun rays to
only draw properly in the bottom right quarter of the world viewport.

The scissor rectangle for the world viewport was applied to the first
FBO_FastBlit() in RB_SunRays().

Set glScissor() in FBO_FastBlit() as it's done in FBO_Blit() and
FBO_BlitFromTexture(). Sun rays probably worked correctly with r_hdr 1
because the blit for HDR changed the scissor state.
  • Loading branch information
zturtleman committed Feb 8, 2024
1 parent 93abc60 commit 7426ac2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions code/renderergl2/tr_fbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,30 @@ void FBO_FastBlit(FBO_t *src, ivec4_t srcBox, FBO_t *dst, ivec4_t dstBox, int bu
int width = dst ? dst->width : glConfig.vidWidth;
int height = dst ? dst->height : glConfig.vidHeight;

qglScissor(0, 0, width, height);

VectorSet4(dstBoxFinal, 0, 0, width, height);
}
else
{
ivec4_t scissorBox;

Vector4Copy(dstBox, scissorBox);

if (scissorBox[2] < 0)
{
scissorBox[0] += scissorBox[2];
scissorBox[2] = fabsf(scissorBox[2]);
}

if (scissorBox[3] < 0)
{
scissorBox[1] += scissorBox[3];
scissorBox[3] = fabsf(scissorBox[3]);
}

qglScissor(scissorBox[0], scissorBox[1], scissorBox[2], scissorBox[3]);

VectorSet4(dstBoxFinal, dstBox[0], dstBox[1], dstBox[0] + dstBox[2], dstBox[1] + dstBox[3]);
}

Expand Down

0 comments on commit 7426ac2

Please sign in to comment.