Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help,
read this.
-
Dashchan
- Prole
- Posts: 4
- Joined: Sun Sep 15, 2013 10:46 am
Post
by Dashchan »
Code: Select all
function love.load()
love.window.setMode(800,450)
local src = [[
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc)
{
return vec4(tc.x, tc.y, 1.0, 1.0);
}
]]
effect = love.graphics.newShader(src)
img = love.graphics.newImage("img.png")
end
function love.draw()
love.graphics.setShader()
love.graphics.setColor(255, 255, 255)
--love.graphics.draw(bg, 0, 0)
love.graphics.setShader(effect)
love.graphics.draw(img, 400, 200)
love.graphics.rectangle('fill',0, 0, 200, 200)
end
function love.update(dt)
if love.keyboard.isDown('escape') then
love.event.quit()
end
end
http://puu.sh/6gT59.jpg
it works on img but doesnt work on rectangle
can anyone help me?
Last edited by
Dashchan on Sun Jan 12, 2014 11:29 am, edited 1 time in total.
-
veethree
- Inner party member
- Posts: 877
- Joined: Sat Dec 10, 2011 7:18 pm
Post
by veethree »
Draw the image and the rectangle to a
canvas, Apply the shader to the canvas.
-
slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
-
Contact:
Post
by slime »
The texture coordinates for primitive shapes (rectangles, etc.) are always 0,0.
-
Dashchan
- Prole
- Posts: 4
- Joined: Sun Sep 15, 2013 10:46 am
Post
by Dashchan »
Thank you guys!
I'll try using a canvas.
Users browsing this forum: No registered users and 3 guests