Skip to content

Commit d09cdf9

Browse files
authored
Merge pull request #303 from fjtrujy/improve_sceGuViewport
Fix `sceGuVIewport` with odd center values
2 parents be9540d + 7373322 commit d09cdf9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/gu/sceGuViewport.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010

1111
void sceGuViewport(int cx, int cy, int width, int height)
1212
{
13-
sendCommandf(VIEWPORT_X_SCALE, (float)(width >> 1));
14-
sendCommandf(VIEWPORT_Y_SCALE, (float)((-height) >> 1));
15-
sendCommandf(VIEWPORT_X_CENTER, (float)cx);
16-
sendCommandf(VIEWPORT_Y_CENTER, (float)cy);
13+
float sx, sy, tx, ty;
14+
sx = (float)(width) * 0.5f;
15+
sy = (float)(height) * -0.5f;
16+
tx = (float)cx;
17+
ty = (float)cy;
18+
19+
sendCommandf(VIEWPORT_X_SCALE, sx);
20+
sendCommandf(VIEWPORT_Y_SCALE, sy);
21+
sendCommandf(VIEWPORT_X_CENTER, tx);
22+
sendCommandf(VIEWPORT_Y_CENTER, ty);
1723
}

0 commit comments

Comments
 (0)