Backing up and restoring Scissor state

Issue #709 resolved
John Kaniarz
created an issue

Here's the minimum code for what I'm trying to do

function myDrawSubFunction()
    local x,y,w,h = --backup scissor
    --draw stuff,y,w,h) --restore scissor

I get a nil parameter error from setScissor() because, naturally, nil is not a valid scissor value. It would be nice if the returns from getScissor() were always valid to pass to setScissor(). (say, by making nils disable scissor)

This same problem also applies to get/setFont (and probably others), but at least with the font function once you set a default font, you're good for the run. Not so with scissor which is breaks whenever scissor is disabled.

Comments (4)

  1. Alex Szpakowski

    Fixed and to not error if a single nil argument is given (resolves issue #709)

    → <<cset d42d1079f2ba>>

    With fonts, I don't think it really makes sense to disable the font entirely, even though it's lazy-loaded.

  2. John Kaniarz reporter

    I haven't tested the fix yet, but I expected the solution to check for exactly 4 nills. And shouldn't 1,2, or 3 parameters (nil or not) be an error?

    As for the font, perhaps getFont() when unitialized should create a default font and return it.

  3. Log in to comment