From 36aa55fb8470a91d730570e60327e13292c96cb4 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Thu, 21 Mar 2024 22:10:24 -0300 Subject: [PATCH] tests: add graphics tests for y direction in canvases --- .../expected/love.test.graphics.Canvas-3.png | Bin 0 -> 327 bytes .../expected/love.test.graphics.Canvas-4.png | Bin 0 -> 327 bytes testing/tests/graphics.lua | 30 ++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 testing/output/expected/love.test.graphics.Canvas-3.png create mode 100644 testing/output/expected/love.test.graphics.Canvas-4.png diff --git a/testing/output/expected/love.test.graphics.Canvas-3.png b/testing/output/expected/love.test.graphics.Canvas-3.png new file mode 100644 index 0000000000000000000000000000000000000000..d3e9c37f8bc3899bba97bfaff675fbbb0688b8f6 GIT binary patch literal 327 zcmeAS@N?(olHy`uVBq!ia0vp^DImb-_`K-hvc z2O=7cd8UX$I1Z7Go0w8rPjO8VmC!C|gL7~zJ;pUBalslSeN<6Of&&mro0vOln7by4 SrzHRbh{4m<&t;ucLK6USId^;j literal 0 HcmV?d00001 diff --git a/testing/output/expected/love.test.graphics.Canvas-4.png b/testing/output/expected/love.test.graphics.Canvas-4.png new file mode 100644 index 0000000000000000000000000000000000000000..d3e9c37f8bc3899bba97bfaff675fbbb0688b8f6 GIT binary patch literal 327 zcmeAS@N?(olHy`uVBq!ia0vp^DImb-_`K-hvc z2O=7cd8UX$I1Z7Go0w8rPjO8VmC!C|gL7~zJ;pUBalslSeN<6Of&&mro0vOln7by4 SrzHRbh{4m<&t;ucLK6USId^;j literal 0 HcmV?d00001 diff --git a/testing/tests/graphics.lua b/testing/tests/graphics.lua index b8e9e8185..2ad615835 100644 --- a/testing/tests/graphics.lua +++ b/testing/tests/graphics.lua @@ -201,6 +201,36 @@ love.test.graphics.Canvas = function(test) local imgdata2 = love.graphics.readbackTexture(canvas) test:compareImg(imgdata2) + -- check y-down + local shader1 = love.graphics.newShader[[ + vec4 effect(vec4 c, Image tex, vec2 tc, vec2 pc) { + return vec4(tc, 0.0, 1.0); + } + ]] + local shader2 = love.graphics.newShader[[ + vec4 effect(vec4 c, Image tex, vec2 tc, vec2 pc) { + return vec4(pc / love_ScreenSize.xy, 0.0, 1.0); + } + ]] + local img = love.graphics.newImage(love.image.newImageData(1, 1)) + + love.graphics.push("all") + love.graphics.setCanvas(canvas) + love.graphics.setShader(shader1) + love.graphics.draw(img, 0, 0, 0, canvas:getDimensions()) + love.graphics.pop() + local imgdata3 = love.graphics.readbackTexture(canvas) + test:compareImg(imgdata3) + + love.graphics.push("all") + love.graphics.setCanvas(canvas) + love.graphics.setShader(shader2) + love.graphics.draw(img, 0, 0, 0, canvas:getDimensions()) + love.graphics.pop() + local imgdata4 = love.graphics.readbackTexture(canvas) + test:compareImg(imgdata4) + + -- check depth samples local dcanvas = love.graphics.newCanvas(100, 100, { type = '2d',