@smith.adriane - your canvas example is really good and is probably the way to go at first. I would rather use an imageview than a canvas but some people will want to use a canvas so they can render the 3d scene and then use canvas to render text and various 2d graphics on top. I guess the thing to test is the performance of the canvas at 60fps to render an HD image to the screen. If it is negligable (<< 16ms) then canvas may be the best way.
As a 3d person all I want to start with is the :draw
callback.
There are two different overall modes for rendering; one for interactive mode when a mouse click means select object or perhaps rotate scene all rendering is done via callbacks from user interaction. The second mode is a playback mode where you are playing animations or whatever and spacebar pauses/plays the scene.
The first mode I think it is clear how it works but the second mode I am not so sure really. I am also not sure the performance implications of rendering a writable image to a canvas as opposed to setting it as the image behind an imageview. So a few things to test 🙂.
ouch. resizable isn't a property and requires derivation to work with.
I have a resizable canvas in Reveal
https://github.com/vlaaad/reveal/blob/master/src/vlaaad/reveal/canvas.clj
I think I still needed to wrap it in something like stack-pane for some reason... Here https://github.com/vlaaad/reveal/blob/master/src/vlaaad/reveal/output_panel.clj#L462
In case you didn't have enough options, there are also similar examples for https://github.com/phronmophobic/membrane/blob/master/src/membrane/skija.clj which uses lwgl and glfw rather than cljfx.
I also don't know what the performance implications, but I would be interested to hear your results since I do a similar thing to implement offscreen rendering for clj-cef: • https://github.com/phronmophobic/clj-cef/blob/main/examples/htmltoimage/src/clj_cef/htmltoimage.clj#L36 • https://github.com/phronmophobic/clj-cef/blob/main/examples/browser/src/clj_cef/browser.clj#L46