This commit is contained in:
Flyinghead 2018-05-17 11:17:51 +02:00
parent 99bc20220e
commit d596f988c8
2 changed files with 24 additions and 5 deletions

View File

@ -68,6 +68,9 @@ const static u32 SrcBlendGL[] =
GL_ONE_MINUS_DST_ALPHA
};
extern int screen_width;
extern int screen_height;
PipelineShader* CurrentShader;
u32 gcflip;
@ -99,8 +102,24 @@ s32 SetTileClip(u32 val, bool set)
if (csx <= 0 && csy <= 0 && cex >= 640 && cey >= 480)
return 0;
if (set)
if (set && clip_mode) {
csx *= scale_x;
csy *= scale_y;
cex *= scale_x;
cey *= scale_y;
if (!pvrrc.isRTT) {
float t = cey;
cey = 480 - csy;
csy = 480 - t;
float dc2s_scale_h = screen_height / 480.0f;
float ds2s_offs_x = (screen_width - dc2s_scale_h * 640) / 2;
csx = csx * dc2s_scale_h + ds2s_offs_x;
cex = cex * dc2s_scale_h + ds2s_offs_x;
csy = csy * dc2s_scale_h;
cey = cey * dc2s_scale_h;
}
glUniform4f(CurrentShader->pp_ClipTest, csx, csy, cex, cey);
}
return clip_mode;
}

View File

@ -271,14 +271,14 @@ void main() \n\
{ \n\
// Clip outside the box \n\
#if pp_ClipTestMode==1 \n\
if (vtx_xyz.x < pp_ClipTest.x || vtx_xyz.x > pp_ClipTest.z \n\
|| vtx_xyz.y < pp_ClipTest.y || vtx_xyz.y > pp_ClipTest.w) \n\
if (gl_FragCoord.x < pp_ClipTest.x || gl_FragCoord.x > pp_ClipTest.z \n\
|| gl_FragCoord.y < pp_ClipTest.y || gl_FragCoord.y > pp_ClipTest.w) \n\
discard; \n\
#endif \n\
// Clip inside the box \n\
#if pp_ClipTestMode==-1 \n\
if (vtx_xyz.x >= pp_ClipTest.x && vtx_xyz.x <= pp_ClipTest.z \n\
&& vtx_xyz.y >= pp_ClipTest.y && vtx_xyz.y <= pp_ClipTest.w) \n\
if (gl_FragCoord.x >= pp_ClipTest.x && gl_FragCoord.x <= pp_ClipTest.z \n\
&& gl_FragCoord.y >= pp_ClipTest.y && gl_FragCoord.y <= pp_ClipTest.w) \n\
discard; \n\
#endif \n\
\n\