Difference between revisions of "love.graphics.setShader"

(Created page with "{{newin|0.9.0|090|type=function}} Sets or resets a Shader as the current pixel effect or vertex shaders. All drawing operations until the next ''love.graphics.setShader'...")
 
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{newin|[[0.9.0]]|090|type=function}}
+
{{newin|[[0.9.0]]|090|type=function|text=It has been renamed from [[love.graphics.setPixelEffect]]}}
  
 
Sets or resets a [[Shader]] as the current pixel effect or vertex shaders. All drawing operations until the next ''love.graphics.setShader'' will be drawn using the [[Shader]] object specified.
 
Sets or resets a [[Shader]] as the current pixel effect or vertex shaders. All drawing operations until the next ''love.graphics.setShader'' will be drawn using the [[Shader]] object specified.
Line 43: Line 43:
 
     -- boring white
 
     -- boring white
 
     love.graphics.setShader()
 
     love.graphics.setShader()
     love.graphics.rectangle('fill', 10,10,790,285)
+
     love.graphics.rectangle('fill', 10,10,780,285)
  
 
     -- LOOK AT THE PRETTY COLORS!
 
     -- LOOK AT THE PRETTY COLORS!
 
     love.graphics.setShader(effect)
 
     love.graphics.setShader(effect)
     love.graphics.rectangle('fill', 10,305,790,285)
+
     love.graphics.rectangle('fill', 10,305,780,285)
 
end
 
end
  

Latest revision as of 18:13, 13 January 2014

Available since LÖVE 0.9.0
It has been renamed from love.graphics.setPixelEffect.


Sets or resets a Shader as the current pixel effect or vertex shaders. All drawing operations until the next love.graphics.setShader will be drawn using the Shader object specified.

Function

Synopsis

love.graphics.setShader( shader )

Arguments

Shader shader
The new shader.

Returns

Nothing.

Notes

Sets the current shader to a specified Shader. All drawing operations until the next love.graphics.setShader will be drawn using the Shader object specified.

Function

Synopsis

love.graphics.setShader( )

Arguments

None.

Returns

Nothing.

Notes

Disables shaders, allowing unfiltered drawing operations.

Examples

Drawing a rectangle using a pixel effect shader

function love.load()
    effect = love.graphics.newShader [[
        extern number time;
        vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
        {
            return vec4((1.0+sin(time))/2.0, abs(cos(time)), abs(sin(time)), 1.0);
        }
    ]]
end

function love.draw()
    -- boring white
    love.graphics.setShader()
    love.graphics.rectangle('fill', 10,10,780,285)

    -- LOOK AT THE PRETTY COLORS!
    love.graphics.setShader(effect)
    love.graphics.rectangle('fill', 10,305,780,285)
end

local t = 0
function love.update(dt)
    t = t + dt
    effect:send("time", t)
end

See Also


Other Languages