From 3f99bad5a0856f13bf5d38060d7bbd3c6170e340 Mon Sep 17 00:00:00 2001 From: Javidx9 <25419386+OneLoneCoder@users.noreply.github.com> Date: Fri, 23 Oct 2026 14:54:49 +0100 Subject: [PATCH 1/7] Initialised camera track position when no target supplied --- utilities/olcUTIL3_Camera2D.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/olcUTIL3_Camera2D.h b/utilities/olcUTIL3_Camera2D.h index f645510f..d839c9e3 100644 --- a/utilities/olcUTIL3_Camera2D.h +++ b/utilities/olcUTIL3_Camera2D.h @@ -361,7 +361,7 @@ namespace olc::utils // Target Vector2D object camera should follow (either ref or ptr) olc::vf2d* m_pTarget = nullptr; - olc::vf2d m_vLocalTarget; + olc::vf2d m_vLocalTarget = { 0,0 }; // World Boundary bool m_bWorldBoundary = false; From e9d307d69f2e55650046cc9149cff3270776585c Mon Sep 17 00:00:00 2001 From: Javidx9 <25419386+OneLoneCoder@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:05:58 +0100 Subject: [PATCH 2/7] Added jam stragglers --- dev/src/sh_template.h | 5 +++-- olcPixelGameEngine3.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dev/src/sh_template.h b/dev/src/sh_template.h index a7444a0d..b02f7117 100644 --- a/dev/src/sh_template.h +++ b/dev/src/sh_template.h @@ -118,8 +118,9 @@ olcCodeJam 2026 - Beta Testers - Big Thanks! (itch account names shown) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - KrossX, Zalambdodont, mgnooj, bblodget, bootsec, tgd20, AJSquirrel, Linh, pm1001 - tobiasrox, mitchdev1, u2084511felix, BenKyd, Beefpants, objectname, MrB, raoul632 + KrossX, Zalambdodont, mgnooj, bblodget, bootsec, tgd20, AJSquirrel, Linh, pm1001, + tobiasrox, mitchdev1, u2084511felix, BenKyd, Beefpants, objectname, MrB, raoul632, + yolicap, JustBrailey, AlfaDrottning Version History ~~~~~~~~~~~~~~~ diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 2a0e918d..432649b4 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -118,8 +118,9 @@ olcCodeJam 2026 - Beta Testers - Big Thanks! (itch account names shown) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - KrossX, Zalambdodont, mgnooj, bblodget, bootsec, tgd20, AJSquirrel, Linh, pm1001 - tobiasrox, mitchdev1, u2084511felix, BenKyd, Beefpants, objectname, MrB, raoul632 + KrossX, Zalambdodont, mgnooj, bblodget, bootsec, tgd20, AJSquirrel, Linh, pm1001, + tobiasrox, mitchdev1, u2084511felix, BenKyd, Beefpants, objectname, MrB, raoul632, + yolicap, JustBrailey, AlfaDrottning Version History ~~~~~~~~~~~~~~~ From 0f94af5b89c1c38a9e30a6b5b89c9b0f556b2713 Mon Sep 17 00:00:00 2001 From: Javidx9 <25419386+OneLoneCoder@users.noreply.github.com> Date: Fri, 23 Oct 2026 18:07:17 +0100 Subject: [PATCH 3/7] Added OnUserSize() hook and fixed an OOB error during resize events --- dev/src/core.cpp | 29 +++++++++++++++++++++++------ dev/src/core.h | 4 ++++ olcPixelGameEngine3.h | 33 +++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/dev/src/core.cpp b/dev/src/core.cpp index c3af8ab5..11ded44f 100644 --- a/dev/src/core.cpp +++ b/dev/src/core.cpp @@ -107,10 +107,30 @@ namespace olc return true; } + void PGEWindow::OnUserResize(const olc::vi2d vNewWindowSize) + { + return; + } + bool PGEWindow::olc_WindowUpdate(const float fElapsedTime, const float fTotalElapsedTime) { float fDT = fElapsedTime; + // This synchronises resizes of windows so we dont draw + // to screens that have changed size + if (bWindowResizeRequest) + { + if(config.bRealWindow) + GetScreen().Resize(vWindowResizeRequest); + + SetWindowSize(vWindowResizeRequest); + bWindowResizeRequest = false; + + // Allow user to react if they want + OnUserResize(vWindowResizeRequest); + } + + // Input Changes mouse.UpdateState(); keyboard.UpdateState(); @@ -391,12 +411,9 @@ namespace olc bool PGEWindow::olc_OnWindowSize(const olc::vi2d& vSize) { - if (config.bRealWindow) - { - GetScreen().Resize(vSize); - } - - return SetWindowSize(vSize); + bWindowResizeRequest = true; + vWindowResizeRequest = vSize; + return true; } diff --git a/dev/src/core.h b/dev/src/core.h index 43e1a767..6fa588b6 100644 --- a/dev/src/core.h +++ b/dev/src/core.h @@ -90,6 +90,8 @@ namespace olc virtual bool OnUserUpdate(float fElapsedTime); // Return true if window is to close virtual bool OnUserDestroy(); + + virtual void OnUserResize(const olc::vi2d vNewWindowSize); public: // olc::Image Handling @@ -147,6 +149,8 @@ namespace olc olc::imload::ImageLoader* pImageLoader = nullptr; olc::vi2d vViewPos = { 0,0 }; olc::vi2d vViewSize = { 0,0 }; + bool bWindowResizeRequest = false; + olc::vi2d vWindowResizeRequest = { 0,0 }; protected: // Extensions bool InstallWindowExtension(olc::PGEWindowExtension* pgex); diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 432649b4..fe2361af 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -4436,6 +4436,8 @@ namespace olc virtual bool OnUserUpdate(float fElapsedTime); // Return true if window is to close virtual bool OnUserDestroy(); + + virtual void OnUserResize(const olc::vi2d vNewWindowSize); public: // olc::Image Handling @@ -4493,6 +4495,8 @@ namespace olc olc::imload::ImageLoader* pImageLoader = nullptr; olc::vi2d vViewPos = { 0,0 }; olc::vi2d vViewSize = { 0,0 }; + bool bWindowResizeRequest = false; + olc::vi2d vWindowResizeRequest = { 0,0 }; protected: // Extensions bool InstallWindowExtension(olc::PGEWindowExtension* pgex); @@ -20055,10 +20059,30 @@ namespace olc return true; } + void PGEWindow::OnUserResize(const olc::vi2d vNewWindowSize) + { + return; + } + bool PGEWindow::olc_WindowUpdate(const float fElapsedTime, const float fTotalElapsedTime) { float fDT = fElapsedTime; + // This synchronises resizes of windows so we dont draw + // to screens that have changed size + if (bWindowResizeRequest) + { + if(config.bRealWindow) + GetScreen().Resize(vWindowResizeRequest); + + SetWindowSize(vWindowResizeRequest); + bWindowResizeRequest = false; + + // Allow user to react if they want + OnUserResize(vWindowResizeRequest); + } + + // Input Changes mouse.UpdateState(); keyboard.UpdateState(); @@ -20339,12 +20363,9 @@ namespace olc bool PGEWindow::olc_OnWindowSize(const olc::vi2d& vSize) { - if (config.bRealWindow) - { - GetScreen().Resize(vSize); - } - - return SetWindowSize(vSize); + bWindowResizeRequest = true; + vWindowResizeRequest = vSize; + return true; } From e9ebc8d2355d0943461ab132d0ac7bfb1a7a3db9 Mon Sep 17 00:00:00 2001 From: Javidx9 <25419386+OneLoneCoder@users.noreply.github.com> Date: Fri, 23 Oct 2026 19:47:20 +0100 Subject: [PATCH 4/7] Added ScreenSize setter to Camera2D --- utilities/olcUTIL3_Camera2D.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utilities/olcUTIL3_Camera2D.h b/utilities/olcUTIL3_Camera2D.h index d839c9e3..48ed0a38 100644 --- a/utilities/olcUTIL3_Camera2D.h +++ b/utilities/olcUTIL3_Camera2D.h @@ -101,6 +101,11 @@ namespace olc::utils return m_nMode; } + inline void SetScreenSize(const olc::vf2d& vScreenSize) + { + m_vViewSize = vScreenSize / m_vViewScale; + } + // Get the position of the target being tracked by this camera inline const olc::vf2d& GetTarget() const { From 1378b65b5410f17e4c62a7b7c77f48314e2d9681 Mon Sep 17 00:00:00 2001 From: Javidx9 <25419386+OneLoneCoder@users.noreply.github.com> Date: Fri, 23 Oct 2026 21:23:39 +0100 Subject: [PATCH 5/7] Added some additional scale functions Fixed omitted reference in OnSize() --- .../olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj | 2 +- dev/src/core.cpp | 2 +- dev/src/core.h | 2 +- dev/src/draw.cpp | 10 ++++++++++ dev/src/draw.h | 5 +++++ olcPixelGameEngine3.h | 19 +++++++++++++++++-- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj b/dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj index 930e8044..06f66a84 100644 --- a/dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj +++ b/dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj @@ -92,7 +92,7 @@ false false - false + true false diff --git a/dev/src/core.cpp b/dev/src/core.cpp index 11ded44f..ce776f74 100644 --- a/dev/src/core.cpp +++ b/dev/src/core.cpp @@ -107,7 +107,7 @@ namespace olc return true; } - void PGEWindow::OnUserResize(const olc::vi2d vNewWindowSize) + void PGEWindow::OnUserResize(const olc::vi2d& vNewWindowSize) { return; } diff --git a/dev/src/core.h b/dev/src/core.h index 6fa588b6..d9336e2e 100644 --- a/dev/src/core.h +++ b/dev/src/core.h @@ -91,7 +91,7 @@ namespace olc // Return true if window is to close virtual bool OnUserDestroy(); - virtual void OnUserResize(const olc::vi2d vNewWindowSize); + virtual void OnUserResize(const olc::vi2d& vNewWindowSize); public: // olc::Image Handling diff --git a/dev/src/draw.cpp b/dev/src/draw.cpp index bd2e362c..9fb9f8cd 100644 --- a/dev/src/draw.cpp +++ b/dev/src/draw.cpp @@ -229,6 +229,16 @@ olc::vf2d olc::Draw::ScreenToWorld(const olc::vf2d& v) const return transformAffine.inverse(v); } +olc::vf2d olc::Draw::SizeInWorld(const olc::vf2d& v) const +{ + return v / transformAffine.scale(); +} + +olc::vf2d olc::Draw::SizeOnScreen(const olc::vf2d& v) const +{ + return transformAffine.scale() * v; +} + void Draw::Pixel(const olc::vf2d& pos, const olc::Pixel col, const olc::Pixel tint) { // Check if in bounds diff --git a/dev/src/draw.h b/dev/src/draw.h index 9b92460e..2f9f9c44 100644 --- a/dev/src/draw.h +++ b/dev/src/draw.h @@ -226,6 +226,11 @@ namespace olc olc::vf2d WorldToScreen(const olc::vf2d& v) const; olc::vf2d ScreenToWorld(const olc::vf2d& v) const; + // Scale a size in screen pixels to world units + // (essentially scale only, no offsets or rotations) + olc::vf2d SizeInWorld(const olc::vf2d& v) const; + olc::vf2d SizeOnScreen(const olc::vf2d& v) const; + public: // Primitive Drawing Functions // Plot a single pixel void Pixel( diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index fe2361af..4048d70b 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -2922,6 +2922,11 @@ namespace olc olc::vf2d WorldToScreen(const olc::vf2d& v) const; olc::vf2d ScreenToWorld(const olc::vf2d& v) const; + // Scale a size in screen pixels to world units + // (essentially scale only, no offsets or rotations) + olc::vf2d SizeInWorld(const olc::vf2d& v) const; + olc::vf2d SizeOnScreen(const olc::vf2d& v) const; + public: // Primitive Drawing Functions // Plot a single pixel void Pixel( @@ -4437,7 +4442,7 @@ namespace olc // Return true if window is to close virtual bool OnUserDestroy(); - virtual void OnUserResize(const olc::vi2d vNewWindowSize); + virtual void OnUserResize(const olc::vi2d& vNewWindowSize); public: // olc::Image Handling @@ -18327,6 +18332,16 @@ olc::vf2d olc::Draw::ScreenToWorld(const olc::vf2d& v) const return transformAffine.inverse(v); } +olc::vf2d olc::Draw::SizeInWorld(const olc::vf2d& v) const +{ + return v / transformAffine.scale(); +} + +olc::vf2d olc::Draw::SizeOnScreen(const olc::vf2d& v) const +{ + return transformAffine.scale() * v; +} + void Draw::Pixel(const olc::vf2d& pos, const olc::Pixel col, const olc::Pixel tint) { // Check if in bounds @@ -20059,7 +20074,7 @@ namespace olc return true; } - void PGEWindow::OnUserResize(const olc::vi2d vNewWindowSize) + void PGEWindow::OnUserResize(const olc::vi2d& vNewWindowSize) { return; } From 51200b075e1c90d7b81c821ab1e2339275ed4c18 Mon Sep 17 00:00:00 2001 From: Javidx9 <25419386+OneLoneCoder@users.noreply.github.com> Date: Sat, 31 Oct 2026 14:43:24 +0000 Subject: [PATCH 6/7] Isolated the olc::numeric concept to remove its dependency on 2D vector being declared --- dev/src/vector2d.h | 6 +++++- olcPixelGameEngine3.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dev/src/vector2d.h b/dev/src/vector2d.h index 90d71cc5..ba74e2e3 100644 --- a/dev/src/vector2d.h +++ b/dev/src/vector2d.h @@ -13,12 +13,16 @@ //! END CUSTOMHEADER //! START DECLARATION -#if !defined(PGE_VECTOR2D_DECLARED) + namespace olc { template concept numeric = std::integral || std::floating_point; +} +#if !defined(PGE_VECTOR2D_DECLARED) +namespace olc +{ /* A complete 2D geometric vector structure, with a variety of useful utility functions and operator overloads diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 4048d70b..d273407c 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -679,12 +679,16 @@ namespace olc #define PGE_PIXEL_DECLARED 1 #endif -#if !defined(PGE_VECTOR2D_DECLARED) + namespace olc { template concept numeric = std::integral || std::floating_point; +} +#if !defined(PGE_VECTOR2D_DECLARED) +namespace olc +{ /* A complete 2D geometric vector structure, with a variety of useful utility functions and operator overloads From d46ffe9e4ac190359b8b79927011ed84692cc63f Mon Sep 17 00:00:00 2001 From: Javidx9 <25419386+OneLoneCoder@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:01:59 +0000 Subject: [PATCH 7/7] guarded that too. weird personal project throwing up some conflicts --- dev/src/vector2d.h | 3 +++ olcPixelGameEngine3.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dev/src/vector2d.h b/dev/src/vector2d.h index ba74e2e3..cf50552b 100644 --- a/dev/src/vector2d.h +++ b/dev/src/vector2d.h @@ -14,11 +14,14 @@ //! START DECLARATION +#if !defined(PGE_NUMERIC_CONCEPT_DECLARED) namespace olc { template concept numeric = std::integral || std::floating_point; } +#define PGE_NUMERIC_CONCEPT_DECLARED 1 +#endif #if !defined(PGE_VECTOR2D_DECLARED) namespace olc diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index d273407c..f8736315 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -680,11 +680,14 @@ namespace olc #endif +#if !defined(PGE_NUMERIC_CONCEPT_DECLARED) namespace olc { template concept numeric = std::integral || std::floating_point; } +#define PGE_NUMERIC_CONCEPT_DECLARED 1 +#endif #if !defined(PGE_VECTOR2D_DECLARED) namespace olc