4 ms·
I attempted to implement my own windowing library after studying winit and SDL2. The missing feature I need is supporting detachable tabs (like what chrome and
by billconan 4y ago
I attempted to implement my own windowing library after studying winit and SDL2.
The missing feature I need is supporting detachable tabs (like what chrome and sublime text have).
I think for productivity apps, this is very important. But implementing a windowing lib from scratch is not easy.
- zachrip 4y agoWhat are some of the difficulties?
- billconan 4y agoyou mean what are some of the difficulties of implementing detachable tabs using existing libraries? For example, they don't give you the correct mouse coordinates once your mouse cursor is outside a window. I heard this is impossible to do if the underlining system is wayland.
- billconan 4y agoAlso, do you think if multi-channel signed distance field is a good approach for GUI text rendering? I understand, for games, it can support extreme zooming with small textures. But for GUI (for example a text editor), we only occasionally resize fonts. I looked at some of the open source projects (mostly terminal emulators), they simply rasterize fonts onto a texture map using CPU. I wonder if signed distance field is really necessary.
- raphlinus 4y agoI'm not a fan of distance fields for GUI text rendering. Their main advantage in games is super-easy integration into the rendering pipeline (they're basically just a texture and a simple shader), but the quality is not quite as good as standard font rendering. There are other issues, including fairly large texture RAM requirements for CJK fonts, and no easy way to do do variable fonts. My main work these days is piet-gpu, which is intended to do 2D graphics (including font rendering) "the right way." In the meantime, using existing platform glyph rendering capabilities makes sense and will certainly give the best visual match to platform text.
- modeless 4y agoThe best GPU accelerated text rendering I know of is https://sluglibrary.com/ https://sluglibrary.com/. Not based on distance fields. Unfortunately not open source, though it is a one-man project. Maybe someday one of the big tech companies will pay him a whole ton of money to open source it.
- pcwalton 4y agoFor most text rendering in the 2D UI use case, I'm not sure there is that much to solve anymore. Aggressive caching of rendered glyphs solves almost all the problems in practice. From what I can tell, Slug is targeted at games and 3D, where there are still interesting problems, but those aren't the 2D UI case.
- moonchild 4y agoEven in 2-d, it is nice to have smooth zoom in/out. The only way to do this that I know of that doesn't compromise on quality is to re-render every frame, and the only way I know to do that fast is to use the gpu. I believe pathfinder can do it (correct me if I'm wrong). I know I'm working on something that can do it too. Moving a bit farther from the strictly 'text' realm there are authoring tools for vector graphics, where you would like to be able to view the changes you make in real time. CPU can do it (since it's probably the only complex thing onscreen, and changes are likely localised anyway if you really need the extra cycles), but GPU can do it better.
- modeless 4y agoYeah, existing techniques work fine if you want to make something similar to existing systems. But it's a shame to write a whole new GUI library and still have the same old limitations. Zooming is underused in existing systems, probably related to the fact that it's hard to make it work well with commonly used techniques.
- pcwalton 4y agoHonestly, there are so few different glyphs on a typical page, and CPUs are so fast, that it usually isn't that hard to just rerender every glyph on CPU and aggressively reuse glyph images in order to hit 60 FPS during pinch zoom, at least for Latin text. CJK may be a different story, but I kind of doubt it. In 2022, smooth font rendering during pinch zoom is yet another case in which we in the software field dropped the ball, but it didn't matter because hardware picked up the slack.
- modeless 4y agoDear Imgui has an impressive implementation of detachable tabs. https://github.com/ocornut/imgui/wiki/Multi-Viewports https://github.com/ocornut/imgui/wiki/Multi-Viewports
- billconan 4y agoThat was the reason I studied SDL2 in the first place. It's working on linux (with x11), but buggy on Mac.