I created a branch of the love mercurial repository called
love-glsl. As you might have guessed this aims to include GLSL-Shader support to LÖVE.
It is based on the patch in this thread but has a different API:
status = love.graphics.hasShaders()
true if shaders are supported (GL version >= 2.0 and GL_ARB_shader_objects present)
version = love.graphics.getGLSLVersion()
Returns the GLSL version.
shader = love.graphics.newShader()
Creates a new Shader(-program, to be exact)
love.graphics.setShader( shader )
Sets the current shader to 'shader' or uses no shader if argument is nil or omitted.
(equivalent to the previous program:use() and program:unuse())
status = Shader:addCode(type, code)
Adds shader code to the program.
type has to be one of 'vertex' or 'fragment' and determines the shader type (duh)
code has to be a string containing GLSL code
status is true if everything went fine, false otherwise. For how to get compile errors, see Shader:compile()
Shader:compile()
Tries to compile (actually link) the shader. Will throw an error with compiler and linker messages if anything went wrong.
log = Shader:infolog()
Returns the a string with error and warning messages of the compile process.
Shader:setUniform(name, u1, u2, u3, u4)
Sets the uniform value with name
name to (u1,u2,u3,u4). u2 to u4 can be omitted.
The uniform type is assumed to be float.
Shader:setUniform(name, type, u1, u2, u3, u4)
Same as above, but with type either being "float" or "int".
Shader:setUniformMatrix(name, rows, cols, u1,u2,...u[rows*cols])
Sets a uniform matrix. You need to supply exactly rows*cols numbers.
Shader:setSampler(name, image, unit)
Sets uniform sampler ("uniform sampler2D") value to the texture of the Image object image.
unit can be omitted in which case it defaults to 0.
u1,u2,...,u16 = Shader:getSampler(name, type)
Returns the value of a named uniform. Unused values will be
nan or
3735928559 if type is int.
type is either float or int but can be omitted in which case float is assumed.
I attached an updated version of the particles with shaders thing.
Please post any issues/feature requests to the bitbucket repo at
http://bitbucket.org/vrld/love-glsl