NEED A HELP WITH "love2D mutiplicative blend mode "

Discuss any ports of LÖVE to different platforms.
Post Reply
dnjswns951
Prole
Posts: 1
Joined: Thu Jul 02, 2015 5:41 am

NEED A HELP WITH "love2D mutiplicative blend mode "

Post by dnjswns951 »

Code: Select all

Background = love.graphics.newImage("background.png")
LightTexture = love.graphics.newImage("light_texture.png")
LightCanvas = {}

function love.draw()
	love.graphics.setBlendMode("alpha")	
	love.graphics.setColor(255,0,255)
	love.graphics.draw( LightCanvas.canvas, LightCanvas.quad, 0, 0)
	
	love.graphics.setBlendMode("multiplicative")	
	love.graphics.setColor(255,255,255)
	love.graphics.draw(Background, 0, 0)
end

function love.load()   
   love.window.setTitle("light engine implementation")
   
   love.window.setMode(800, 600)
   
   LightCanvas.canvas = love.graphics.newCanvas(love.window.getWidth(), love.window.getHeight())
   LightCanvas.canvas:clear( 0, 0, 0 )
   LightCanvas.quad = love.graphics.newQuad(0, 0, LightCanvas.canvas:getWidth(), LightCanvas.canvas:getHeight(), LightCanvas.canvas:getWidth(), LightCanvas.canvas:getHeight())
   
   love.graphics.setBackgroundColor( 0, 0, 0 ) 
end

function love.update(dt)
	 LightCanvas.canvas:clear( 0, 0, 0 )
	LightCanvas.canvas:renderTo(function()
			love.graphics.draw(LightTexture, 0, 0)
		end)
end

Im trying to make a 2D lighting by using mutipicative blending mode. but when I run this code, screen is just all black and nothing appears.

it works fine when I use just texture itself but when I use canvas, it just doesn't work.
can anyone help with it?
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: NEED A HELP WITH "love2D mutiplicative blend mode "

Post by T-Bone »

Why did you post this in the "Ports" section? Are you running this on a Löve port, and if so, which?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest