aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2014-04-03 09:49:16 +0200
committerpiernov <piernov@piernov.org>2014-04-03 09:49:16 +0200
commit1fe07b8aace16fc3b4d933d16333de2bad7a0d11 (patch)
treeaf7c0d29f0cb48dcd48562b44113d5ed21ce722c
parent3e04ba752c316335765551a983e4e3bdcb2c1aeb (diff)
downloadlove2d-fakecanvas-1fe07b8aace16fc3b4d933d16333de2bad7a0d11.tar.gz
love2d-fakecanvas-1fe07b8aace16fc3b4d933d16333de2bad7a0d11.tar.bz2
love2d-fakecanvas-1fe07b8aace16fc3b4d933d16333de2bad7a0d11.tar.xz
love2d-fakecanvas-1fe07b8aace16fc3b4d933d16333de2bad7a0d11.zip
Port to LÖVE 0.9 and delete vflip
-rw-r--r--fakecanvas.lua50
1 files changed, 5 insertions, 45 deletions
diff --git a/fakecanvas.lua b/fakecanvas.lua
index 2b34dca..e5cb7b4 100644
--- a/fakecanvas.lua
+++ b/fakecanvas.lua
@@ -24,12 +24,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
--]]
-assert(love._version:match "^0.8", "fakecanvas requires LOVE 0.8")
+assert(love._version:match "^0.9", "fakecanvas requires LOVE 0.9")
assert(debug, "fake canvases require access to the debug library")
local canvas_supported = love.graphics.isSupported "canvas"
local npot_supported = love.graphics.isSupported "npot"
-local pixeleffect_supported = love.graphics.isSupported "pixeleffect"
+local shader_supported = love.graphics.isSupported "shader"
local function nextpo2 (x) return 2^math.ceil(math.log(x) / math.log(2)) end
local function prevpo2 (x) return 2^math.floor(math.log(x) / math.log(2)) end
@@ -40,16 +40,6 @@ local canvasmt = { __index = canvas }
local canvases = setmetatable({ }, { __mode = "k" })
-local options = {
- -- flip fake canvas images vertically (then unflip with quad) in order to
- -- match real canvas orientation. this only makes a difference inside
- -- shaders, when using the canvas' texture coordinates. if you do not need
- -- to use this information, you can get a performance boost by disabling
- -- this option. you can enable or disable vflipping for individual fake
- -- canvases by placing setOption() calls around the newCanvas() call.
- vflip = true,
-}
-
local blank
function canvas:clear (...)
local nargs = select("#", ...)
@@ -128,11 +118,6 @@ local function Canvas (width, height)
c._imagedata = love.image.newImageData(w, h)
c._image = love.graphics.newImage(c._imagedata)
c._quad = love.graphics.newQuad(0, 0, w, h, w, h)
- c._vflip = options.vflip
-
- if options.vflip then
- c._quad:flip(false, true) -- flip vertically part 0
- end
local p = newproxy(true)
@@ -158,16 +143,6 @@ local function screenshot (state)
local drawn = love.graphics.newScreenshot()
- if canvas._vflip then -- flip vertically (unfortunately) so it can later be drawn unflipped in order to match texcoords of real canvases. part 1
- love.graphics.setBackgroundColor(0, 0, 0, 0)
- love.graphics.clear()
-
- local flipped = love.graphics.newImage(drawn)
- love.graphics.draw(flipped, 0, canvas._imagedata:getHeight(), 0, 1, -1)
-
- drawn = love.graphics.newScreenshot()
- end
-
canvas._imagedata:paste(drawn, 0, 0, 0, 0, canvas._imagedata:getWidth(), canvas._imagedata:getHeight())
canvas._image = love.graphics.newImage(canvas._imagedata) -- apparently images don't update when their imagedata changes, so
@@ -229,7 +204,6 @@ local _love_funcs = {
newCanvas = love.graphics.newCanvas,
draw = love.graphics.draw,
- drawq = love.graphics.drawq,
pe_send = pixeleffect_supported and registry.PixelEffect.send,
--technically sendCanvas should also be wrapped but that's not officially exposed
@@ -241,17 +215,11 @@ local _wrap_funcs = {
draw = function (obj, x, y, r, sx, sy, ox, oy, kx, ky)
if canvases[obj] then
- return _love_funcs.drawq(obj:_getImage(), obj:_getQuad(), x or 0, y or 0, r, sx, sy, ox, oy, kx, ky) -- flip texcoords part 2
+ return _love_funcs.draw(obj:_getImage(), obj:_getQuad(), x or 0, y or 0, r, sx, sy, ox, oy, kx, ky) -- flip texcoords part 2
end
return _love_funcs.draw(obj, x, y, r, sx, sy, ox, oy, kx, ky)
end,
- drawq = function (obj, q, x, y, r, sx, sy, ox, oy, kx, ky)
- if canvases[obj] then
- return _love_funcs.drawq(obj:_getImage(), q or obj:_getQuad(), x, y, r, sx, sy, ox, oy, kx, ky)
- end
- return _love_funcs.drawq(obj, q, x, y, r, sx, sy, ox, oy, kx, ky)
- end,
-
+
pe_send = function (pe, name, data)
if canvases[data] then
return _love_funcs.pe_send(pe, name, data:_getImage())
@@ -307,16 +275,8 @@ function M.getMaxCanvasSize (hw, hh)
end
end
-function M.setOption (name, value)
- options[name] = value
-end
-
-function M.getOption (name)
- return options[name]
-end
-
blank = love.image.newImageData(M.getMaxCanvasSize())
M.enable()
-return M \ No newline at end of file
+return M