Lately, I’ve had a lot of trouble concentrating on my research work, so I’ve been trying to take a little “development” break to feel like I’m still a bit active!
So I started writing a port of the G’MIC display system (which is actually handled by the CImgDisplay class in the underlying CImg library) to make it use SDL (Simple DirectMedia Layer Library), version 3 (latest).
The main interests of doing that are:
SDL provides a native Wayland implementation, so G’MIC won’t require a X11 compatibility layer when it will be compiled on future (Wayland-based) Linux distros.
SDL also has an implementation that run on OSX, so G’MIC filters that use interactive windows could work on Mac too!
Of course, it’s still WIP, but most of the display features are already implemented and seem to work.
I’ve added an entry make sdl in the Makefile to compile the G’MIC cli tool with SDL3 support. Beware, it won’t work with SDL version 2 !
The main things missing at the moment are:
Fullscreen mode is not managed yet.
Screenshot (via command screen) is not functionnal yet.
There are still a few glitches and bugs when moving display windows.
I’ll try to improve it little by little!
What’s also nice is that it forced me to go back to my X11 code, which was a bit old, and I was able to improve a few things in the X11 code too.
So there should be a first “SDL-friendly” version of G’MIC for the next release (version 3.5.4)!
All this is currently only available in the develop branch of the CImg/G’MIC source code. When it’s more or less stable, I’ll do a pre-release.
Hmm, I checked SDL a bit. Recently found that it has native clipboard support, which is something I’d like to bridge Python and G’MIC for a few use case, as well as getting a image via clipboard instead of having to save it on my drive. Are those possible?
Probably. The problem is I’m not fan of implementing a feature that would be specific to the use of SDL. Users of other display systems wouldn’t be able to use this feature.
Pour éviter une erreur de compilation la ligne 12539 de CImg.h est ‘supprimée’:
//cimg::unused(x0,y0,x1,y1,img);
La compilation donne un exécutable faisant bien appel à SDL3.dll
Lors des tests, l’affichage des effets de filtre(s) est bon mais le curseur de la souris bloque la fenêtre dès qu’elle est sélectionnée (erreur).
Il y a encore quelques problèmes avec certaines options de gmic demos mais c’est une très grosse amélioration depuis ma dernière compilation. Merci :o)
Tous les filtres de gmic demos sont testés et les 3 erreurs constatées sont:
Hough-transform
[gmic] *** Error in ./demos/*local/*do/ *** List of images is in an inconsistent state (8 images for 9 image names). It could be caused by concurrent threads manipulating the image list at the same time.
Paint et Color Curves
Blocage de applications (Ne répond pas)
On OSX no demo (gmic demos) works with SDL3 display besides the choice window. Any hope for progress here?
The most frequent error:
Assertion failed: (NSViewIsCurrentlyBuildingLayerTreeForDisplay() != currentlyBuildingLayerTree), function NSViewSetCurrentlyBuildingLayerTreeForDisplay, file NSView.m, line 13477.
RIght now, I’m a bit stuck with SDL3 when it comes to multi-threading code.
It appears that you cannot open a new window in a thread that is not the main thread, and this causes a lot of issues for G’MIC, because in G’MIC you need to be able to create new display windows from threads (which is what demos does by the way).
Right now, I don’t have any solution to improve this.
I’m a bit disappointed because I spent some time understanding the logic behind SDL3, and now I think it’s not that adapted for providing a new display system for CImg/G’MIC.