ABRG-Models / morphologica

A library of supporting code for numerical modelling (JSON config, HDF5 data, Modern OpenGL visualization)
https://abrg-models.github.io/morphologica/
Apache License 2.0
251 stars 29 forks source link

Make morphologica Qt compatible! #116

Closed sebjameswml closed 1 year ago

sebjameswml commented 1 year ago

It would widen interest in morphologica if it could be used to draw OpenGL inside Qt windows.

Right now, the design of morphologica's morph::Visual specifies that Visual is the 'top level' thing. One Visual relates to one window on the desktop. Each Visual launches a window using GLFW3 and uses GLFW function calls.

You write programs that create a Visual object, add VisualModels to it, then you call Visual::render() when you want to redraw all your models, and do any computations and resulting changes to the VisualModels you want to between calls to Visual::render().

In Qt, this has to change a bit. Qt manages windows and emits render events. I still want the one window-per Visual link to remain. I don't quite know how one would run a simulation but I'll get to that. The Qt render event for a window should call Visual::render().

There's some re-plumbing to do, and I'll aim for this to have minimal impact on morphologica programs that use the GLFW3 way (as I won't be using Qt in my own day-to-day use of the library).

See branch redesign/qtcompatibility for progress.

sebjameswml commented 1 year ago

I imagine you found an alternative solution @LorenzoCane

sebjameswml commented 1 year ago

I've made good progress on this branch. I've now got a test program (it's in an external repository at the moment: https://github.com/sebjameswml/opengl_examples and see this file: https://github.com/sebjameswml/opengl_examples/blob/qtmorphologica/qt/opengl41/qtmorph/widget.cpp in branch qtmorphologica) which draws a graph in a QOpenGLWidget, with some mouse events wired up. Still work in progress, but promising. As part of this work, I've redesigned the API for creating VisualModels, and so I'll do a morphologica release as a "pre-Qt release", since there have been a lot of updates since the unique_ptr release.