Skip to content

Commit

Permalink
3DS: Fix scissor coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Aug 4, 2024
1 parent f80b696 commit 8024360
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/render/n3ds/SDL_render_n3ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,22 @@ N3DS_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vert
case SDL_RENDERCMD_SETCLIPRECT: {
const SDL_Rect *rect = &cmd->data.cliprect.rect;
if (cmd->data.cliprect.enabled) {
C3D_SetScissor(GPU_SCISSOR_NORMAL, rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
unsigned int x = SDL_max(0, rect->x), w = rect->w;
unsigned int y = SDL_max(0, rect->y), h = rect->h;

if (data->boundTarget) {
C3D_SetScissor(GPU_SCISSOR_NORMAL,
SDL_min(data->renderTarget->frameBuf.width, x),
SDL_min(data->renderTarget->frameBuf.height, y),
SDL_min(data->renderTarget->frameBuf.width, x + w),
SDL_min(data->renderTarget->frameBuf.height, y + h));
} else {
C3D_SetScissor(GPU_SCISSOR_NORMAL,
SDL_max(0, data->renderTarget->frameBuf.width - (rect->y + rect->h)),
SDL_max(0, data->renderTarget->frameBuf.height - (rect->x + rect->w)),
SDL_max(0, data->renderTarget->frameBuf.width - rect->y),
SDL_max(0, data->renderTarget->frameBuf.height - rect->x));
}
} else {
C3D_SetScissor(GPU_SCISSOR_DISABLE, 0, 0, 0, 0);
}
Expand Down

0 comments on commit 8024360

Please sign in to comment.