C-API setDrawMode() returns previous mode

There's no way to localise a change in drawing mode. I guess you could globally store whatever the default is on start, and then track every change.

But the API already knows the current mode.

If it returned the previous mode when calling setDrawMode(), code could then make temporary changes before restoring it.


LCDBitmapDrawMode current_mode = playdate->graphics->setDrawMode( kDrawModeInverted );
// ... draw an inverted bitmap, e.g. pressed button

//restore draw mode
playdate->graphics->setDrawMode( current_mode );

Right now I have to guess the previous mode was kDrawModeCopy. It's dodgy.

That's a great idea! The "normal" way you'd preserve the current draw mode is to push a new context with a NULL target, do your drawing, then pop the context, but if all you're worried about is the draw mode then this would save a bit of moving data back and forth. I've filed that, and hope to get it in there soon. Thanks!

1 Like