Siwin backend improvements#156
Conversation
It still crashes when calling any GL commands, weird.
Awesome! Nah I've been wanting to add a Siwin backend but figured I'd wait to see what you got. I am planning to start working MacOS support for Siwin which apparently is broken. It'd be nice to default to Siwin in the future. Also my work on adding the new rendering backend changes the windowing API a bit. It's the same methods, but the objects change a bit and will conflict with this PR. It should be pretty easy to fix though. |
| return ClipboardStr("") | ||
|
|
||
| method run*(renderer: RendererSiwin) = | ||
| renderer.window.run( |
There was a problem hiding this comment.
This will break things as the Figuro Renderer needs to control things and poll for events. It has it's own event system which controls when rendering needs to occur.
Windy/Windex had a poll and exposes a swapBuffer. It looks like Siwin doesn't expose a poll method, but has some swapBuffer methods.
I'm going to create an issue for Siwin about it.
There was a problem hiding this comment.
Actually looks like it does have a way to do it! It'd just be using the firstStep and step methods. See: https://github.com/levovix0/siwin/blob/db2dfb2de848c2fb4f7e7950bb86ee229ebca9f5/src/siwin/platforms/any/window.nim#L402
Siwin's run proc is just:
proc run*(window: sink Window, makeVisible = true) =
## run whole window main loops
window.firstStep(makeVisible)
while window.opened:
window.step()There was a problem hiding this comment.
Probably what would be needed on the Figuro side is to change the runRendererLoop or maybe the pollAndRender. Something like this:
proc runRendererLoop*(renderer: Renderer) =
threadEffects:
RenderThread
siwinWindw.eventHandler.onRender = proc () =
renderer.pollAndRender()
siwinWindow.firstStep() # first step
while app.running:
siwinWindow.redraw() # request redraw
siwinWindow.step()
os.sleep(renderer.duration.inMilliseconds)
redraw
|
@xTrayambak I'd recommend looking at my PR that refactors the render to be swappable. Also checkout my PR comments I left on the code. That'll save you a lot of headaches. The swappable renderer in this PR might make it easier to integrate: https://github.com/elcritch/figuro/pull/155/files The PR makes both a Renderer and a WindowRenderer objects: I can also modify that PR to make it easier to support Siwin as it's a bit different than Windy/Windex. Maybe it'll have to be something fun like the window and the renderer having |
|
Yeah, that seems to make it a bit easier. I'll just wait until you merge that MR, then I'll continue work on this. |
@xTrayambak I just merged the PR refactoring the renderer. |
Hiya, I saw that you've implemented a Siwin backend. It doesn't compile yet though (as it's mostly a skeleton, as you mentioned).
This PR aims to add a proper backend that uses Siwin.
Please don't merge it right now - it's still very much a work in progress!