Skip to content

Commit

Permalink
port: use a separate fb for fullscreen menu background
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfdsfgs committed Nov 16, 2024
1 parent 08ec8e5 commit 3d8f63d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/game/menugfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
#define PXTOBYTES(val) ((val) * 2)

#ifndef PLATFORM_N64
static s32 g_MenuBlurFb = 0;
static s32 g_MenuBlurFb = -1;
static s32 g_MenuScreenFb = -1;
static bool g_MenuBlurDone = false;
#endif

Expand Down Expand Up @@ -124,8 +125,9 @@ void menugfxCreateBlur(void)

g_ScaleX = 1;
#else
if (g_MenuBlurFb == 0) {
if (g_MenuBlurFb < 0) {
g_MenuBlurFb = videoCreateFramebuffer(BLURIMG_WIDTH, BLURIMG_HEIGHT, true, false);
g_MenuScreenFb = videoCreateFramebuffer(0, 0, false, true);
}
// copy full viewport and downscale to 40x30
videoCopyFramebuffer(g_MenuBlurFb, 0, -1, -1);
Expand All @@ -151,14 +153,13 @@ Gfx *menugfxRenderBgBlur(Gfx *gdl, u32 colour, s16 arg2, s16 arg3)
#ifndef PLATFORM_N64
width = viGetWidth();
height = viGetHeight();
if (g_MenuBlurFb && !g_MenuBlurDone) {
if (g_MenuBlurFb >= 0 && !g_MenuBlurDone) {
// blit the small blur texture onto a screen-sized framebuffer while blurring it
g_MenuBlurDone = true;
g_BlurFbDirty = true;
gdl = bviewPrepareStaticRgba16(gdl, 0xffffffff, 0xff);
gDPSetTextureFilter(gdl++, G_TF_BLUR_EXT);
gDPSetFramebufferTextureEXT(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, BLURIMG_WIDTH, g_MenuBlurFb);
gDPSetFramebufferTargetEXT(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, g_BlurFb);
gDPSetFramebufferTargetEXT(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, g_MenuScreenFb);
gSPImageRectangleEXT(gdl++, 0, 0, 0, 0, width << 2, height << 2, BLURIMG_WIDTH, BLURIMG_HEIGHT, 0, BLURIMG_WIDTH, BLURIMG_HEIGHT);
gDPSetFramebufferTargetEXT(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, 0);
gDPSetFramebufferTextureEXT(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, BLURIMG_WIDTH, 0);
Expand All @@ -177,7 +178,7 @@ Gfx *menugfxRenderBgBlur(Gfx *gdl, u32 colour, s16 arg2, s16 arg3)

#ifndef PLATFORM_N64
// LoadTextureBlock will set up the sizes, but we'll use the framebuffer instead of g_BlurBuffer
gDPSetFramebufferTextureEXT(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, g_BlurFb);
gDPSetFramebufferTextureEXT(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, g_MenuScreenFb);
#endif

gDPPipeSync(gdl++);
Expand Down

0 comments on commit 3d8f63d

Please sign in to comment.