About Monkey 2 › Forums › Monkey 2 Programming Help › Window drag pausing
This topic contains 3 replies, has 3 voices, and was last updated by
Hezkore
1 year, 1 month ago.
-
AuthorPosts
-
March 1, 2018 at 12:14 am #13784
I’m trying to get rid of the pause that happens when you drag the window.
I really just need the logic to keep going in the background, rendering isn’t as important.
Anyone got any clues to how I could do this without altering any of the Mojo code?March 1, 2018 at 9:05 am #13792Not sure how much I can help, but if monkey2 has a way to utilize timeout functions that run on a separate thread – then I have one idea off the top of my head.
Since your main thread stops when being dragged, the code only needs to be executed in whatever function is most appropriate (I’d assume render in a window is).
Psuedo code:
1. make timer2. pass timer a function
3. when timer timeout it will execute function
4. in the render method, keep resetting the timeout to something reasonable
5. now whenever the main method is paused the timer will eventually run out and you can loop it!—
This is fairly unorthodox and there are more SDL2 like ways. Here’s a thread I found that kind of covers that topic: https://www.gamedev.net/forums/topic/527683-sdl-dragging-window-problem/March 3, 2018 at 3:46 am #13829You’ll need to stick your update code into OnRender to do this as this is the only callback that continues to be processed while windows goes ‘modal’.
March 3, 2018 at 1:41 pm #13835I haven’t been able to get this working, no matter what I try.
I’ve tried timers, I’ve tried fibers and I’ve tried altering the Mojo App code.I at first thought the timer method worked, but it just catches up real fast when you release the window.
It doesn’t actually keep running while you’re dragging it.I’m playing/reading/processing some music files, and I need it to keep doing so even when you drag the window around.
If it pauses and catches up when you release the window, it will just play every instrument and sample in a mess.@Mark Sibly
I’ve got my update code in OnRender.Monkey12345678910111213141516171819202122#Import "<mojo>"Using mojo..Class MyWindow Extends WindowField counter:FloatMethod New()Super.New( "drag pause", 320, 240, WindowFlags.Resizable )EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()counter+=0.01canvas.DrawText( counter, 8, 8 )EndEndFunction Main()New AppInstance;New MyWindowApp.Run()End -
AuthorPosts
You must be logged in to reply to this topic.