1. Anders Ruud
  2. love
  3. Issues


Issue #1248 open

Reset transform stack?

Kyle McLamb
created an issue

In the course of writing a game, sometimes I make mistakes. That's fine, because I can just run my game in protected mode, reset some things, and start love.run again to recover.

The one error that gums the works in this system is the max stack depth error, which happens when I forget to pop something I pushed, and sticks around even after I call love.graphics.reset(). Since reset is useful without tossing the stack, maybe an extra function like love.graphics.clearStack() could help?

Comments (6)

  1. Kyle McLamb reporter

    This is for live editing stuff: I don't plan to ship with love.graphics.clearStack(), but it'd be nice if I didn't have to restart my game all over for one specific mistake

  2. Raidho

    In meantime you can try the following:

    _lgpush, _lgpop, _counter = love.graphics.push, love.graphics.pop, 0
    love.graphics.push = function ( ) _counter = _counter + 1; _lgpush ( ) end
    love.graphics.pop = function ( ) _counter = _counter - 1; _lgpop ( ) end
    love.graphics.clearstack = function ( ) while _counter > 0 do love.graphics.pop ( ) end
  3. M D

    Alternatively, you can do this.

    function resetTransformStack()
        while pcall(function() love.graphics.pop() end) do end

    This pops the stack until it encounters an error, and then it discards the error immediately.

  4. Log in to comment