Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/msvc/olcPGE3_BuildSH/olcPGE3_BuildSH.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<ClCompile Include="..\..\..\examples\olcPGE3_Mouse.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\examples\olcPGE3_PixelShaders.cpp">
Expand Down
29 changes: 23 additions & 6 deletions dev/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}


Expand Down
4 changes: 4 additions & 0 deletions dev/src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions dev/src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions dev/src/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions dev/src/sh_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~
Expand Down
9 changes: 8 additions & 1 deletion dev/src/vector2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
//! END CUSTOMHEADER

//! START DECLARATION
#if !defined(PGE_VECTOR2D_DECLARED)

#if !defined(PGE_NUMERIC_CONCEPT_DECLARED)
namespace olc
{
template <typename T>
concept numeric = std::integral<T> || std::floating_point<T>;
}
#define PGE_NUMERIC_CONCEPT_DECLARED 1
#endif

#if !defined(PGE_VECTOR2D_DECLARED)
namespace olc
{
/*
A complete 2D geometric vector structure, with a variety
of useful utility functions and operator overloads
Expand Down
62 changes: 53 additions & 9 deletions olcPixelGameEngine3.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -678,12 +679,19 @@ namespace olc
#define PGE_PIXEL_DECLARED 1
#endif

#if !defined(PGE_VECTOR2D_DECLARED)

#if !defined(PGE_NUMERIC_CONCEPT_DECLARED)
namespace olc
{
template <typename T>
concept numeric = std::integral<T> || std::floating_point<T>;
}
#define PGE_NUMERIC_CONCEPT_DECLARED 1
#endif

#if !defined(PGE_VECTOR2D_DECLARED)
namespace olc
{
/*
A complete 2D geometric vector structure, with a variety
of useful utility functions and operator overloads
Expand Down Expand Up @@ -2921,6 +2929,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(
Expand Down Expand Up @@ -4435,6 +4448,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
Expand Down Expand Up @@ -4492,6 +4507,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);
Expand Down Expand Up @@ -18322,6 +18339,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
Expand Down Expand Up @@ -20054,10 +20081,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();
Expand Down Expand Up @@ -20338,12 +20385,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;
}


Expand Down
7 changes: 6 additions & 1 deletion utilities/olcUTIL3_Camera2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -361,7 +366,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;
Expand Down
Loading