From 203dc66527f96c3b90a1903394d683d2e80a2638 Mon Sep 17 00:00:00 2001 From: dibas Date: Thu, 24 May 2018 20:27:52 +0200 Subject: [PATCH] WHBGfx - Separate ClearColor() and allow custom colors. --- src/libwhb/include/whb/gfx.h | 3 +++ src/libwhb/src/gfx.c | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/libwhb/include/whb/gfx.h b/src/libwhb/include/whb/gfx.h index fba9597..fe21c16 100644 --- a/src/libwhb/include/whb/gfx.h +++ b/src/libwhb/include/whb/gfx.h @@ -37,6 +37,9 @@ WHBGfxBeginRender(); void WHBGfxFinishRender(); +void +WHBGfxClearColor(float r, float g, float b, float a); + void WHBGfxBeginRenderDRC(); diff --git a/src/libwhb/src/gfx.c b/src/libwhb/src/gfx.c index a0c2020..165c446 100644 --- a/src/libwhb/src/gfx.c +++ b/src/libwhb/src/gfx.c @@ -64,6 +64,9 @@ sTvContextState = NULL; static GX2ContextState * sDrcContextState = NULL; +static BOOL +sDrawingTv = FALSE; + static BOOL sGpuTimedOut = FALSE; @@ -489,13 +492,25 @@ WHBGfxFinishRender() GX2SetDRCEnable(TRUE); } +void +WHBGfxClearColor(float r, float g, float b, float a) +{ + if (sDrawingTv) { + GX2ClearColor(&sTvColourBuffer, r, g, b, a); + GX2ClearDepthStencilEx(&sTvDepthBuffer, sTvDepthBuffer.depthClear, sTvDepthBuffer.stencilClear, GX2_CLEAR_FLAGS_DEPTH | GX2_CLEAR_FLAGS_STENCIL); + GX2SetContextState(sTvContextState); + } else { + GX2ClearColor(&sDrcColourBuffer, r, g, b, a); + GX2ClearDepthStencilEx(&sDrcDepthBuffer, sDrcDepthBuffer.depthClear, sDrcDepthBuffer.stencilClear, GX2_CLEAR_FLAGS_DEPTH | GX2_CLEAR_FLAGS_STENCIL); + GX2SetContextState(sDrcContextState); + } +} + void WHBGfxBeginRenderDRC() { GX2SetContextState(sDrcContextState); - GX2ClearColor(&sDrcColourBuffer, 0.0f, 1.0f, 0.0f, 1.0f); - GX2ClearDepthStencilEx(&sDrcDepthBuffer, sDrcDepthBuffer.depthClear, sDrcDepthBuffer.stencilClear, GX2_CLEAR_FLAGS_DEPTH | GX2_CLEAR_FLAGS_STENCIL); - GX2SetContextState(sDrcContextState); + sDrawingTv = FALSE; } void @@ -508,9 +523,7 @@ void WHBGfxBeginRenderTV() { GX2SetContextState(sTvContextState); - GX2ClearColor(&sTvColourBuffer, 1.0f, 0.0f, 0.0f, 1.0f); - GX2ClearDepthStencilEx(&sTvDepthBuffer, sTvDepthBuffer.depthClear, sTvDepthBuffer.stencilClear, GX2_CLEAR_FLAGS_DEPTH | GX2_CLEAR_FLAGS_STENCIL); - GX2SetContextState(sTvContextState); + sDrawingTv = TRUE; } void