1. Anders Ruud
  2. love
  3. Issues

Issues

Issue #1003 resolved

Separate stencil buffer from Canvas

Alex Szpakowski
created an issue

It can be useful sometimes to reuse the same stencil buffer with multiple different Canvases. The current API is also unintuitive when using multiple active Canvases (MRTs), since there can only be one active stencil buffer so LÖVE currently chooses the one that belongs to the first Canvas in the list.

Comments (8)

  1. Alex Szpakowski reporter

    In the current implementation (which has been mostly the same since stenciling was added to LÖVE), each Canvas has its own stencil buffer and that buffer can't be shared. Sometimes it might be useful to have one stencil buffer shared between multiple Canvases (of the same size), which might be accomplished with something like Canvas:getStencilBuffer and Canvas:setStencilBuffer, or similar.

  2. Pablo Mayobre

    Getting the stencil buffer may be useful to what I was commenting at #1156, I would love if we could do this with the main stencil buffer too and not only for canvas, say love.graphics.[g/s]etStencilBuffer

  3. Alex Szpakowski reporter

    This would just get a reference to the stencil buffer so it could be re-used in multiple Canvases (as long as they have the same dimensions). Unfortunately OpenGL doesn't allow doing that with the main screen. Either way this proposal wouldn't let you get the actual values.

    One thing I have to figure out before implementing this is that, currently, when you switch away from a Canvas its stencil buffer's contents are always trashed for performance reasons on mobile devices. If the stencil buffer is shared that will not always be desirable (and I guess in some cases it's not always desirable right now anyway). Also, love.graphics.clear will always clear the stencil buffer, which again might not always be wanted if it's shared.

  4. Alex Szpakowski reporter

    I've now moved my line of thinking more towards separating out stencil buffers from Canvas objects entirely, so you might specify stencil=true or something in (a new equivalent of) love.graphics.setCanvas, which would automatically reuse from a cache of LÖVE-internal stencil buffers, and you could create your own Lua-facing one and specify stencil=mystencilbuffer or something in setCanvas instead if you wanted.

  5. Alex Szpakowski reporter

    Add a new “stencil8” pixel format for Canvases (resolves issue #1003).

    Also fixed Canvas MSAA (resolves issue #1271).

    stencil-formatted Canvases can’t be drawn, and can only be used as the value for a new ‘depthstencil’ field to the table-argument variant of love.graphics.setCanvas.

    → <<cset 4413f8ebda32>>

  6. Log in to comment