Page 1 of 1

Rendering flicker

Posted: Sun Dec 20, 2015 9:18 am
by chimmihc
So with my current project I am making it with two rendering levels. "world objects" and "screen objects", world objects are rendered relative to the "camera" object's orientation, screen objects are relative to the screen.

The camera effects on the world objects are handled with the graphics coordinate system functions, so to avoid doing a bunch of math to "reverse" the effects when rendering the screen objects I am just editing the love.run function.

Original:

Code: Select all

love.graphics.clear()
love.graphics.origin()
if love.draw then love.draw() end
love.graphics.present()
Mine:

Code: Select all

love.graphics.clear()
love.graphics.origin()
if draw then -- draw is a function that handles world object drawing
	draw()
	love.graphics.present()
end
if drawScreen then -- drawScreen is a function that handles screen object drawing
	love.graphics.origin() -- reset the camera effects
	drawScreen() -- draw them
	love.graphics.present() -- render them
end
Now, as is, only the world objects are rendered smoothly, the screen objects are flickering for some reason.

What is causing this? And how can it be fixed?
Version 0.9.2

Re: Rendering flicker

Posted: Sun Dec 20, 2015 9:53 am
by Nixola
Why can't you just do this?

Code: Select all

 function love.draw()
  draw() 
  lg.origin()
  drawScreen() 
end

Anyway, check out [wiki]love.graphics.push[/wiki] and [wiki]love.graphics.pop[/wiki], they might be useful ;)
If you need/want to keep the code that way, you need to call love.graphics.present only once, after all of the drawing is done

Re: Rendering flicker

Posted: Sun Dec 20, 2015 10:16 am
by chimmihc
Nixola wrote:If you need/want to keep the code that way, you need to call love.graphics.present only once, after all of the drawing is done
That actually fixed it, thanks. I wasn't sure if it the double rendering was needed or not so I just did it.