fix(ios): pin voxel render target scale
Adrian Castro · 2026-08-01 ·
parent eb231d221e
fix(ios): pin voxel render target scale
Changed files
lib/PixelCanvas.lua | 9 +++++++++
lib/ShadowMap.lua | 2 +-
lib/TiltShift.lua | 6 ++++--
lib/Voxel3D.lua | 3 ++-
4 files changed, 16 insertions(+), 4 deletions(-)
Diff
diff --git a/lib/PixelCanvas.lua b/lib/PixelCanvas.lua
new file mode 100644
index 0000000..ca25769
--- /dev/null
+++ b/lib/PixelCanvas.lua
@@ -0,0 +1,9 @@
+local V = ...
+
+local PixelCanvas = {}
+
+function PixelCanvas.new(w, h)
+ return pcall(love.graphics.newCanvas, w, h, { dpiscale = 1 })
+end
+
+return PixelCanvas
diff --git a/lib/ShadowMap.lua b/lib/ShadowMap.lua
index 18ceffd..d5afc76 100644
--- a/lib/ShadowMap.lua
+++ b/lib/ShadowMap.lua
@@ -186,7 +186,7 @@ end
local function getCanvas(res)
if canvas == false then return nil end
if canvas and canvasRes == res then return canvas end
- local ok, c = pcall(love.graphics.newCanvas, res, res)
+ local ok, c = V.require("PixelCanvas").new(res, res)
if not (ok and c) then
canvas = false
return nil
diff --git a/lib/TiltShift.lua b/lib/TiltShift.lua
index d95c10e..a94081b 100644
--- a/lib/TiltShift.lua
+++ b/lib/TiltShift.lua
@@ -25,6 +25,7 @@
-- failure -- headless, no shader support) apply() hands the canvas back
-- untouched, so every other path is byte-for-byte what it always was.
+local V = ...
local TiltShift = {}
TiltShift.level = 0
@@ -85,9 +86,10 @@ end
local function getCanvases(w, h)
if not ping or cw ~= w or ch ~= h then
- local ok, a = pcall(love.graphics.newCanvas, w, h)
+ local PixelCanvas = V.require("PixelCanvas")
+ local ok, a = PixelCanvas.new(w, h)
if not ok then return nil end
- local okB, b = pcall(love.graphics.newCanvas, w, h)
+ local okB, b = PixelCanvas.new(w, h)
if not okB then return nil end
-- the gaussian's fractional tap offsets need linear filtering
a:setFilter("linear", "linear")
diff --git a/lib/Voxel3D.lua b/lib/Voxel3D.lua
index 471a688..d16dc71 100644
--- a/lib/Voxel3D.lua
+++ b/lib/Voxel3D.lua
@@ -33,6 +33,7 @@ local WorldCurve = V.require("WorldCurve")
local Sky = V.require("Sky")
local DayNight = V.require("DayNight")
local GlassMask = V.require("GlassMask")
+local PixelCanvas = V.require("PixelCanvas")
local Voxel3D = {}
@@ -640,7 +641,7 @@ function Voxel3D.beginScene(w, h, cx, cy, vw, vh, sky, slot)
local name = slot or "world"
local slotHeld = slots[name]
if not (slotHeld and slotHeld.w == w and slotHeld.h == h) then
- local ok, c = pcall(love.graphics.newCanvas, w, h)
+ local ok, c = PixelCanvas.new(w, h)
if not ok then return false end
c:setFilter("nearest", "nearest")
if slotHeld then releaseSlot(slotHeld) end