
Ask HN: Any minimalist cross-platform low-level C graphic library? - skywal_l
I often find myself needing a canvas to experiment things. In the Javascript world it&#x27;s pretty easy: open a tab, open the dev console, append a &lt;canvas&gt; to your DOM and that&#x27;s it.<p>What could be the equivalent in C ?<p>My requirements are:
1. Can create a window and push pixel to it.
2. No dependencies, especially not OpenGL.
3. Some drawing capabilities (lines, shapes, 2d transformation).
4. Can wait for user inputs (in a blocking way ideally).
5. Appreciated: Single header.
6. Optional: Some text drawing capability.<p>Note that I am not looking for a GUI&#x2F;widget library like Nuklear. I just need to push pixels into a window. The obvious closest would be SDL (or something like raylib) but it depends on OpenGL and offer way more than I need (3d capabilities, sound, etc).<p>Although minimalist, I still want that library to handle the underlying window system (X11 on linux, Windows shell, Quartz) so I don&#x27;t worry about portability.
======
strangecasts
It's not been maintained for a while, but TinyPTC
([https://sourceforge.net/projects/tinyptc/](https://sourceforge.net/projects/tinyptc/))
might be worth a look - it's specifically intended for small demos, does not
depend on OpenGL (aside from being an option on Linux), and will let you "push
pixels" to a window.

I would urge you to reconsider SDL though - it's going to be a lot easier to
port to other platforms, and it's going to be maintained for a long time.

e: You don't _have_ to use SDL's audio/rendering subsystems either - it is
possible to just treat it as a pure window/event management library.

------
chunkles
I don't know if it meets all your criteria, but you might look at imgui,
specifically cimgui which is just the autogenerated c-api wrapper for imgui.

[https://github.com/ocornut/imgui](https://github.com/ocornut/imgui)
[https://github.com/cimgui/cimgui](https://github.com/cimgui/cimgui)

~~~
strangecasts
Imgui doesn't handle window creation/graphics - it's a GUI library which
depends on another window/graphics library being in place already :(

