GUI – OS & Hardware Cross-Platform, Written In C –

Nordmann said:
I looked into OpenGL but I want strictly C coding

The OpenGL API is in C, so what’s your issue with it? It’s not that i’m 100% sure there aren’t any, as i moved to C++ before starting using OpenGL IIRC.
Vulkan is C too. (Just to let you know – not recommended for anything meant to be practically simple.)

Usually you want to separate your GUI from rendering it. To render, a GUI lib only needs a small number of callbacks to draw primitives like lines, triangles, eventually with texture for text, and scissor rectangles for clipping. Any gfx lib supports those, and it should be easy to use your GUI with any rendering backend.

ImGui is a good example (,​ it comes with examples of integration to OpenGL. VK and DX. Those examples themselves utilize application frameworks to abstract OS and gfx content creation, which might be interesting too as it helps to get started while focusing on things that actually matter. ImGui is pretty C style too, maybe you can use just that.

Nordmann said:
Is it impossible to write cross-platform GUI exclusively in C or is this information strictly esoteric?

It’s possible, there just seems no need for it. You can mix C and C++. There is no reason to restrict yourself to only C. Doing so has no benefit for learning, and likely you only make it hard and cumbersome for yourself in some cases.

Personally i started with C after using some crap like Basic on home computers, and i loved it. It was the perfect language. I have learned C++ too pretty quickly, but it did not really change my programming. Did not like things like Inheritance for example. So i remained a C programmer at heart for decades. I used some C++ features, e.g. class methods, but not so much more. This is true for many, and i think this practice even has a name: ‘C with Classes’.
Only in recent years i try to catch up a bit with modern C++. I realize i have missed a lot, and it really really helps with producibility. Still, i would recommend to get started with C, focus on problem solving / algorithms, and dive into language features a bit later / on demand.
IMO that’s good practice, but when it gets to the point so it becomes hard to use libraries, then you are pedantic and restricting yourself for no benefit.

Leave a Reply

Your email address will not be published. Required fields are marked *