Is Mojo screen always accumulative/persistant?
Monkey Forums/Monkey Programming/Is Mojo screen always accumulative/persistant?
| ||
It seems we're allowed to use the Mojo screen as an accumulative surface. I've tested on the IOS emulator, HTML5 and GLFW, and it seems I can accumulate drawing ops (and alpha) by drawing on top of what I drew before in previous OnRender(), if I don't clear the screen. Can we count on this behavior on all targets? Example: Strict Import mojo Class Accum Extends App Method OnCreate:Int() SetUpdateRate 60 End Method OnRender:Int() SetColor Rnd(255),Rnd(255),Rnd(255) SetAlpha 0.03 ' ok for ios , 0.01 is to low for ios but ok for HTML5 DrawRect(Rnd(DeviceWidth())-100,Rnd(DeviceHeight())-100,200,200) End End Function Main:Int() New Accum End |
| ||
I think you can skip clear on all targets but I'm not 100%, but what kind of effect do you want to create with that? |
| ||
I have used that in Flash successfully, I just displayed a bunch of buttons and only rendered once. So the flash app doesnt use any CPU resources. for a Big Lebowski soundboard: http://www.realmofdarkness.net/pc/sb/movies/lebowski/3 |
| ||
Can we count on this behavior on all targets? No. XNA won't allow this and OpenGL implementations seem to vary. |
| ||
No. XNA won't allow this and OpenGL implementations seem to vary. Ok, but for HTML5 and iOS maybe? |
| ||
You'd have to read the Canvas spec to see if it's stipulated behaviour. It's certainly persistent in the cases I've tried and the style of rendering model isn't one that would suggest any behind the scenes buffer clearing and swapping is likely. I don't have an iOS device, so I don't know about that either. iOS is OpenGL, but if Apple's desire for consistency is in effect then I'd assume that if it works for one device then it works for all. I doubt that the same is true for Android. |
| ||
I just noticed that Mark has posted an official answer here: http://www.monkeycoder.co.nz/Community/post.php?topic=1579&post=14727 It's basically "Never count on persistence, always use Cls" |
| ||
Well it's more a case of you can't count on persistence from mojo because mojo can't guarantee the behaviour of the final target. If you understand the target you're delivering on, and that target allows persistence of buffer contents across frames, then you're good to go. |