Heaps multiple windows

I’m trying to have multiple windows running in Heaps and I’m having difficulties. Taking Canasse’s comment about it into account I tried stuff but I’m only managing at having the latest window rendering and never both at the same time.

Here’s files for a simple reproduction of an attempt at doing that, is there something wrong with this approach ? Comments ?

Tbh I haven’t tested multiple windows setup for a long time. It was initially designed to work but there might be some code that was changed since then.
But you should change hxd.System.mainLoop that currently only calls present () on the current engine

The present() function was the last piece of the puzzle ! There are some bugs that I’ll try to figure out later but I at least managed to have 2 windows rendering at the same time. Finally.

I’ll give more details later when I have time.

I have modified the repo.

I managed to have multiple windows rendering and made so that events are handled properly. I have one big problem and I haven’t learned enough of OpenGL and SDL yet to have a good idea of why they are happening. The other problems that I’m having are also tied to that function.

The big problem is that SDL_GL_MakeCurrent is veeery slow when swapping window.


And one other problem that I have is that my mainLoop is actually not doing things in the right order it seems. Currently, if a new App is created in the update function of another App (L.53 of App.hx), SDL automatically makes the new window the current target window, so when calling present() (L.64 of App.hx) which calls SDL_GL_SwapWindow, an error is made that says that the window that’s having its buffer swapped isn’t the current target, but it automatically sets the window as current I guess since nothing breaks.
The thing is, when I’m trying to not trigger that error by making sure that the right target is set after L.53 using renderTo() (see commented lines 55-57), SDL doesn’t emit an error but the rendering breaks, the windows become black.

Uncommenting L.35 of App.hx will break rendering too for some reason.

Welp, that’s how far I can go for now with my current knowledge. I’ll come back to it after understanding what’s happening in h3d.impl.GlDriver.hx I guess.

Edit : Oh, and there’s a hashlink build and the profiler file in the repo.