OSX/Metal people: do you know of any guide how to create a simple window with a metal layer from code? I have a MTKView but it seems I cannot do things like while(running) { repaint(); } on it. Do I need it to event based? Can I fake it?(OSX noob here)
-
-
As you observe, Cocoa generally wants to be event-driven, so you wouldn’t want to redraw in a tight loop because (1) you’ll starve the runloop event processing mechanism and (2) you’re going to wind up blocking in -[CAMetalLayer nextDrawable] if you try to run too far ahead.
-
Right! I suspected I needed to go event driven somehow. But how do you usually implement a game loop with that? Trigger a new request for a draw when the last one finishes?
-
Perhaps. There are of course many, many ways to tackle synchronization, but in the simplest case, you’d run a CVDisplayLink at your target frame rate and kick off rendering from the callback.
End of conversation
New conversation -
-
-
I'd be interested to see any proof-of-concept / minimal code that does this *cleanly*. (I tackled the same problem a few months ago with no Cocoa knowledge at all and ended up with a solution that I found... gross)
-
I don't think I have done it cleanly enough, but I will try to pull it out of framework and get some code posted later. Focus for me right now is rendering abstraction and not game loop/window management, sorry
-
Understood. Feel free to get in touch if I can help down the line.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.