From 6002a03761e123b6204394722f078e6a1535d64f Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Thu, 21 Mar 2024 18:12:44 -0300 Subject: [PATCH] tests: add a test to make sure the front face is correct --- ...ove.test.graphics.setFrontFaceWinding-1.png | Bin 0 -> 84 bytes testing/tests/graphics.lua | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 testing/output/expected/love.test.graphics.setFrontFaceWinding-1.png diff --git a/testing/output/expected/love.test.graphics.setFrontFaceWinding-1.png b/testing/output/expected/love.test.graphics.setFrontFaceWinding-1.png new file mode 100644 index 0000000000000000000000000000000000000000..acc6f693255144e16ce567085660a80f5dc8180b GIT binary patch literal 84 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!D3?x-;bCrM;bAV5XE5m;VlehybfLtC=7srr_ dImrnMyg;4-1EW~ytcySvgQu&X%Q~loCICv#5Q6{! literal 0 HcmV?d00001 diff --git a/testing/tests/graphics.lua b/testing/tests/graphics.lua index b55764444..b8e9e8185 100644 --- a/testing/tests/graphics.lua +++ b/testing/tests/graphics.lua @@ -2123,6 +2123,23 @@ love.test.graphics.setFrontFaceWinding = function(test) test:assertEquals('ccw', love.graphics.getFrontFaceWinding(), 'check ffw ccw set') love.graphics.setFrontFaceWinding(original) -- @TODO better graphics drawing specific test + + local shader = love.graphics.newShader[[ +vec4 effect(vec4 c, Image tex, vec2 tc, vec2 pc) { + return gl_FrontFacing ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); +} + ]] + local dummyimg = love.graphics.newImage(love.image.newImageData(1, 1)) + + local canvas = love.graphics.newCanvas(16, 16) + love.graphics.push("all") + love.graphics.setCanvas(canvas) + love.graphics.setShader(shader) + love.graphics.draw(dummyimg, 0, 0, 0, 16, 16) + love.graphics.pop() + + local imgdata = love.graphics.readbackTexture(canvas) + test:compareImg(imgdata) end