Hacker News new | ask | show | jobs
by ianseyler 1279 days ago
Does this support writing to a linear frame buffer? Would be interesting to port to run on my OS if so.
3 comments

It does. I've done it, starting with their x11_rawfb demo. It's pretty nice, but I've personally switched to using LVGL (https://github.com/lvgl/lvgl) for the OS I work on, as I find it a better fit for the purpose. I do still have a soft spot for Nuklear though, and depending on what you're trying to do with your OS, could also be a good fit. Really not hard to get it going if you don't mind implementing your own keyboard/mouse driver layer.
Nuklear returns a bunch of vertices, vertex-indices and draw commands, so it plugs best into a 3D API (like GL, D3D, Metal, Vulkan...). To render into a frame buffer you'd need to implement a simple software rasterizer with texturing support.
One of their demos already has a software rasterizer. I've used it to draw directly to a frame buffer for a custom OS that didn't support accelerated graphics. It's in the demo directory under x11_rawfb. I made some tweaks to that (getting rid of all X11 stuff) and wrote my own fb/tty/mouse/keyboard driver and got it working great without any graphics API layer between it and the pixels that get drawn directly to video memory and the screen.
I have backend for the Hisilicon SoC from 2016, its about 1500 lines of C code, few calls to 2D API and copypasta of the triangle rasterizer. Dunno about modern version requirements.