Re: LÖVE 11.0 released!
Posted: Mon Apr 09, 2018 8:48 pm
The point is that when playback is suspended at the very beginning, the paused and stopped "states" are basically equivalent. pause is always halt playback, stop is always halt playback and rewind, and rewind is always seek(0).
I was also able to recreate the effect by drawing a given sprite additional time(s) after calling `love.graphics.setBlendMode('add')`. I don't know a lot about shaders or alternate pixel formats, so I don't have any conception of whether this is more or less computationally expensive than either of those approaches.Iori Branford wrote: ↑Mon Apr 09, 2018 9:58 pm Indeed the behavior my project relies on was against spec, and in 11.0 requires a pixel shader (or one of the floating point pixel formats but no idea how widely supported they are).
Shaders are running all the time, therefore using a shader should be computationally cheaper than drawing the sprite multiple times.shru wrote: ↑Tue Apr 10, 2018 7:18 am I was also able to recreate the effect by drawing a given sprite additional time(s) after calling `love.graphics.setBlendMode('add')`. I don't know a lot about shaders or alternate pixel formats, so I don't have any conception of whether this is more or less computationally expensive than either of those approaches.
Code: Select all
local shader = love.graphics.newShader[[
// Based on the default shader code at https://love2d.org/wiki/love.graphics.newShader
extern number colour[4];
vec4 effect(vec4 ignored, Image texture, vec2 texture_coords, vec2 screen_coords)
{
vec4 texturecolor = Texel(texture, texture_coords);
return texturecolor * (vec4(colour[0], colour[1], colour[2], colour[3])*(1.0/255.0));
}
]]
love.graphics.setShader(shader)
function mySetColour(r, g, b, a) -- in this example it's global; you may want to put it inside a module or object.
if g == nil then assert(type(r) == "table"); g = r[2]; b = r[3]; a = r[4]; r = r[1] end
if a == nil then a = 255 end
assert(type(r) == "number" and type(g) == "number" and type(b) == "number" and type(a) == "number")
shader:send('colour', r, g, b, a)
end
-- example usage:
local img = love.graphics.newImage('image1.jpg')
function love.draw()
mySetColour(511, 255, 255) -- draw redder than normal
love.graphics.draw(img)
end
Code: Select all
--love version >11 fix colors
if api.getVersion() >= 11 then
local oldSetColor = love.graphics.setColor
love.graphics.setColor = function (r, g, b, a)
if type(r)=="table" then
g = r[2] / 255
b = r[3] / 255
a = (r[4] or 255) / 255
r = r[1] / 255
else
r = r / 255
g = g / 255
b = b / 255
a = (a or 255) / 255
end
oldSetColor(r,g,b,a)
end
end