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 -
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.