Different result when using a framebuffer

Issue #94 invalid
created an issue
  • Love 0.7.0
  • Mac OS X 10.6.3 (MacBook Pro 2010)

Repro 1:

Run the attached main.lua

A circle is rendered using a framebuffer

Press space to toggle framebuffer on/off

With framebuffer on, the circle has dark shaded areas that kind of outline the circle segments.

Expected: Identical results with or without framebuffer

Repro 2:

Run the attached main.lua

Press 'r' to switch to a rectangle rendered at fractional coordinates

Press space to toggle framebuffer on/off

With framebuffer on, the red rectangle is slightly darker and is offset slightly compared to without framebuffer.

Expected: Identical results with or without framebuffer



-- main.lua

usefb = true usecircle = true

function love.load() fb = love.graphics.newFramebuffer() end

function love.draw() if usefb then love.graphics.setRenderTarget(fb) end love.graphics.setBackgroundColor(0, 0, 0, 255) love.graphics.setColor(255, 255, 255, 255) love.graphics.rectangle("fill", 0, 0, 200, 200) love.graphics.setColor(255, 0, 0, 235) love.graphics.setLineWidth(16) if usecircle then love.graphics.circle("line", 100, 100, 70, 32) else love.graphics.rectangle("fill", 10.5, 10.5, 180.5, 180.5) end if usefb then love.graphics.setRenderTarget() love.graphics.setColor(255, 255, 255, 255) love.graphics.draw(fb) end end

function love.keypressed(key) if key == "escape" then love.event.push("q") end

if key == "r" then
    usecircle = not usecircle

if key == " " then
    usefb = not usefb

end }}}

Comments (5)

  1. jonaskje reporter

    If I replace



    	love.graphics.setBackgroundColor(255, 255, 255, 255)

    then the shaded areas seem to go away, but the result is still different.

    Seems like the fb contains parts where alpha != 255, but I can't figure out how that happens...

  2. Matthias Richter

    Rendering the framebuffer is affected by the current color, which explains the result. In your example, if you don't set the color back to white before drawing the fbo, the color is (255, 0, 0, 235). The result should be a more redish and translucent image than the original.

    Automatically setting the color to white before drawing the framebuffer would mean that you loose the ability to tint the image. I suppose you could reset the color with setting the rendertarget, but that may lead to other unexpected side effects.

    So... invalid?

  3. jonaskje reporter

    Got it. However in my use case I want to draw the framebuffer as an opaque image. Would it make sense to add another blend mode, say "opaque", with glBlendFunc(GL_ZERO, GL_ONE), or glDisable(GL_BLEND)?

    Also, is the fact that the shapes of the rectangle and circle are different when rendering to a frame buffer an issue that should be looked further into? The rectangle is one pixel taller and the circle's segments are slightly smaller when rendering to a framebuffer.

  4. Log in to comment