Screen goes black half of the time love.graphics.present()

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.
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: Screen goes black half of the time love.graphics.present()

Post by Croutonix »

Ok thanks!
I adapted love.run to my purposes it's ok I still have events.
But do I need to process even events I don't need?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Screen goes black half of the time love.graphics.present()

Post by Nixola »

You most likely need every event. If you don't need them, there's nearly no overhead - you'd have more if you tried to figure out what events you need, I think.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: Screen goes black half of the time love.graphics.present()

Post by Croutonix »

Is there something wrong in this? I used it to replace love.graphics.present()
Everything drawn is drawn in the canvas.

Code: Select all

love.graphics.setCanvas()       -- Set target to screen
love.graphics.draw(canvas)      -- Draw canvas to screen
love.graphics.present()         -- Refresh screen
love.graphics.setCanvas(canvas) -- Set target to canvas
I only get black screen
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Screen goes black half of the time love.graphics.present()

Post by Nixola »

You don't need to replace anything or to alter love.run. Just draw whatever needs to stay to a canvas, then draw the canvas itself to screen:

Code: Select all

love.draw = function()
  love.graphics.setCanvas(canvas)
  --do whatever;draw a line, draw a circle, an image, whatever you need
  love.graphics.setCanvas()
  love.graphics.draw(canvas)
end
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: Screen goes black half of the time love.graphics.present()

Post by Croutonix »

I changed it to

Code: Select all

love.graphics.setColor(255, 255, 255, 255)
love.graphics.setCanvas()       -- Set target to screen
love.graphics.draw(canvas)      -- Draw canvas to screen
love.graphics.present()         -- Refresh screen
love.graphics.setCanvas(canvas) -- Set target to canvas
It works well now
Croutonix
Prole
Posts: 34
Joined: Fri Aug 12, 2016 12:49 pm

Re: Screen goes black half of the time love.graphics.present()

Post by Croutonix »

Hey when I use love.graphics.scale or scale on love.graphics.draw(canvas), sometimes love.exe crashes randomly. Sometimes when I quit the program it crashes but sometimes it crashes in the middle of it? This is not a memory crash.

Also when I use my zoom in function, the screen gets refreshed after window is resize and I can often see the whole frame flashing upside down beneath the normal frame? There is no rotation anywhere in my code why does this happen?

EDIT: the crash always happens when I quit the program and if the window was resized by the program during execution.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests