From 561bce3f944386d4a2a4bcf9a3491d00779b6c58 Mon Sep 17 00:00:00 2001 From: williamhCode Date: Tue, 5 Nov 2024 18:23:54 -0500 Subject: [PATCH] fix resize --- src/gfx/renderer.cpp | 14 +++++++++----- src/gfx/renderer.hpp | 4 +++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gfx/renderer.cpp b/src/gfx/renderer.cpp index 76eabf5..cafefea 100644 --- a/src/gfx/renderer.cpp +++ b/src/gfx/renderer.cpp @@ -125,13 +125,15 @@ Renderer::Renderer(const SizeHandler& sizes) { }); } -void Renderer::Resize(const SizeHandler& sizes) { +void Renderer::Resize(const SizeHandler& _sizes) { + sizes = _sizes; + camera.Resize(sizes.size); OtherFinalRenderTexture() = RenderTexture(sizes.uiSize, sizes.dpiScale, TextureFormat::RGBA8UnormSrgb); OtherFinalRenderTexture().UpdatePos(sizes.offset); - resized = true; + resize = true; auto stencilTextureView = utils::CreateRenderTexture(ctx.device, {sizes.uiFbSize, TextureFormat::Stencil8}) @@ -480,10 +482,12 @@ void Renderer::RenderWindows( ) { // increment frameIndex = (frameIndex + 1) % 2; - if (resized) { + if (resize) { // resize other texture, since we're using the current one now - OtherFinalRenderTexture() = CurrFinalRenderTexture(); - resized = false; + OtherFinalRenderTexture() = + RenderTexture(sizes.uiSize, sizes.dpiScale, TextureFormat::RGBA8UnormSrgb); + OtherFinalRenderTexture().UpdatePos(sizes.offset); + resize = false; } windowsRPD.cColorAttachments[0].view = CurrFinalRenderTexture().textureView; diff --git a/src/gfx/renderer.hpp b/src/gfx/renderer.hpp index 04b24ee..9789b4d 100644 --- a/src/gfx/renderer.hpp +++ b/src/gfx/renderer.hpp @@ -37,9 +37,11 @@ struct Renderer { Ortho2D camera; + SizeHandler sizes; + bool resize = false; + int frameIndex = 1; std::array finalRenderTextures; - bool resized = false; auto& CurrFinalRenderTexture() { return finalRenderTextures[frameIndex]; }