UI programming with only C or C++

I just want to post this so people who code in C and or C++ know about his. Forget about using QT for fast gui applications or Electron for good looking ones. This library literary makes small executable, is one single header file, is cross platform, and makes fast applications and does not eat up resources.

If i only knew about it before...

library: github.com/vurtun/nuklear

Attached: b04acd4c-e249-11e5-8fd2-ad7744a5b446.png (1200x800, 108K)

Other urls found in this thread:

github.com/ocornut/imgui
github.com/vurtun/nuklear#example
github.com/vurtun/nuklear/tree/master/demo
twitter.com/SFWRedditImages

Also posting Imgui
github.com/ocornut/imgui

you realize that immediate mode is an entirely different approach than the conventional event-based method?
immediate mode guis rerender your window at a fixed rate like a video game.
event-based guis rerender when they need to (i.e. when an event causes rerendering)

immediate mode is nice, but it might not be the right tool for you gui.

Probably explains why Steam's UI updates every frame, since it runs on half life's VGUI

yeah but does it really make a big difference? Either way there is going to be a loop checking whether or not to update anyways

Can confirm that C is fast as fuck. I'm building my own OS. It could easily be run headless for servers, but then it's literally no different from any other research OS that boots you to a text console. I felt that it needs a solid GUI to be useful. So I started with a display server that's actually a kernel module (since it's a microkernel). GUI components all run as kernel mode for now but could very easily be tossed into userspace for security reasons. Basically the display server does similar stuff to Xorg, in that it loads up a compositing window manager, but another kernel server does display memory management for the compositor, but eventually will be merged with the main display server. Behind that is another application that displays an image or color as the background, but can only tile for now. I'm also tinkering with a top panel that loads as another app, for menus and stuff so that I don't need keyboard shortcuts to open the console app. Ideally this panel would also display free space, CPU load, and time/date.

This is all written in C aside from the svg images that are loaded from a folder on disk, with a config file that tells what goes where and how it should be sized in proportion to the display resolution. Everything is extremely fast, and if/when I ever port this OS to ARM or other stuff, it's going to absolutely fly on every toaster.

C is best lang.

Attached: autism.png (1024x768, 17K)

looks good

thanks

Pls tell me more, sounds really interesting. Is it a LFS fork? or a totally DIY OS like TempleOS.

You are welcome. I'm working on my own OS for some time as well (it's done in C++, I know I know, it will get hate, but I do it for myself primarily, not taking it that much seriously) and I could initialize the vga and everything but had really big troubles with fonts etc. It's really nice to see that people who actually can do this thing are doing something different with their own views and approaches.

what a fucking idiot!

yeah that's actually very cool, continue on that shit. do you have anything on github?

Now we only need a form builder made using this same library.

why you fuck

pleb shit but yeah sure would be nice

Mostly DIY, but it's a bit of a mixed bag. Basically I wanted to build my own Unix-like OS and started implementing scheduling and memory and other stuff in a monolithic design. I wasn't too happy with how bloated it was, so I went with a microkernel instead. I took some inspiration from the designs of MINIX and L4 so that it won't be slow. I've worked on slimming down the communications between servers and removing unnecessary abstractions.

But as far as other code goes, I've ported a few GNU and BSD userland utilities. No networking or sound at all yet. Thinking of ripping the networking from NetBSD for it, since it would be 99% compatible and simple to get running. Otherwise I'm using Bash, Nano, mksh (main shell for now) EXT4, and some other things.

The display server and window manager can both utilize true type fonts. The one in the image is called Terminus, and is the best bitmap font I know of.

Nothing open sourced yet. I'm keeping it to myself for now.

>why you fuck
It's human nature to fuck. It feels great, too. You should try it one day.

>incel

no, in event-based process can just sleep until OS wakes it with new event message

>incel...
...I am!

If you're an incel that must suck. No sex for you!

I'm not sure about it though

And to add to that other GUI, I'll probably have the panel application ready in an hour or maybe a day. I have the free disk space app that can be called to print that info on the panel. CPU monitoring is bad, only showing max speed. Time is there too, can be printed from the time server.

Right now I just compiled what I've got and I'm trying to run it with errors. Will report back in like 10 minutes hopefully with a rough panel screenshot.

I'm a voluntary celibate. OS dev is better than sex.

>incel2
feelsbadman

yeah post that shit i wanna see it

I'd love to see the code if you have it hosted somewhere. I wouldn't even know where to begin writing an OS

all of my work on doing GUI now is basically the opposite of this, you get some faggy command stack (common in industrial applications) and have to make it hardware accelerated and shit, and it sucks. This basically provides that, the faggy part, but doesn't solve the business goal of supporting something that already exists (eg a library of symbols or fonts for some piece of shit not in any way standard system that shouldn't exist)

Wow that's really impressive user, please keep us up to date, really happy to see great diy projects made by anons!

Immediate mode GUIs are great.
I have just one problem with nuklear, it compiles too slowly.
I wish there was an easy way to remove some features from it, for faster compilation.

Is there a guide on how to use nuklear? I can't get the examples to build

It would make your life so much easier man, nobody wants to waste 5 mins just setting up a windows and colors and shits .

In every file that uses nuklear, you #include "nuklear.h",
and in one file you also add #define NK_IMPLEMENTATION
Thats it. Then compile it via your C compiler.

also there are lots of includes that are missing from the example files

Okay, so the panel barely works. The programs and file system buttons are fake and do nothing, but ideally the programs button would open up an apps menu to launch programs, maybe a file explorer window full of app shortcuts. File system would open the file explorer to the root dir, but that's not even ready yet. Disk space is showing the shard VBox root dir of the host. I gave this VM 4GB but I guess it's picking up shared folders to measure overall disk size. I don't know why. Also the CPU speed meter is just showing the max clock speed. Time says there's an error when asking the time server to print the time and update every 10 seconds, but it showed up and seems to work okay. So basically, the time is the only thing on the panel that works right (sort of).

Also please ignore my really autistic debug messages. Error messages show up as "big fucky wucky" because I've programmed like 65% of this while shitfaced.

Attached: 1.png (1024x768, 19K)

what does this actually do because there's nothing in the code that draws anything

Attached: 1528480307607.jpg (500x332, 31K)

>because there's nothing in the code that draws anything
Yes, there is.

What does it relies on for rendering?

I failed to find it after about 10 minutes of searching, which source file should i check?

should be opengl

Attached: fuckjews.png (292x83, 3K)

>No dependencies (not even the standard library if not wanted)

There is only one source file, nuklear.h

wait how the fuck do you run the files in the demo folder.

Oh yeah, small thing but I also added a minimize button that hides the windows. I recover them with control+b, which brings up all minimized windows. It was simple to implement and is required for multitasking effectively. I've also added click animations to the window control buttons, so that you get some nice feedback from clicking a UI element. In pic related see the close button in the top left that's pressed.

Also, what's good desktop color aside from white? I was playing with a color selector and found #71869D

Attached: 2.png (1024x768, 15K)

just do a dark theme like the Tomorrow theme on Jow Forums

>an elaborate troll goes too far

Okay. I'll work on that later today and I'll just invert the colors of all the images in GIMP and get a nice dark gray background color. Will post in a few hours if I get around to it, since I have to be somewhere in like an hour.

thanks bud

From what I've seen things like nuklear may be immediate mode but look much nicer than any other framework I've seen.

Qt Quick maybe comes close, but they all look ancient and uncustomizable.

So where do I get a nuklear look in an openGL context without having to break the bank on rendering?

>This library literary makes small executable, is one single header file, is cross platform, and makes fast applications and does not eat up resources.
and literally doesn't draw anything to the screen

desu i'd love it if you kept it white, makes it stand out, much like templeOS

Theming it isn't that hard. I'm just going to keep both themes and maybe experiment with other colors. The white theme will always be an option, and most likely the default. I might change the default wallpaper to a blue-gray color.

>I recover them with control+b, which brings up all minimized windows.
UI design tip: Try using your OS with the keyboard unplugged. Also try using it without a mouse. If a feature can only be accessed by one of these two input devices, reconsider its design.

wait, how do you run the demo files?

I'm aware that the design is pretty rough. The shortcuts are there in place of a meaningful launcher or menu, which has yet to be implemented. These shortcuts may stay or be changed or be removed, but this isn't the finished product. It's a research OS that's being put together piece by piece.

Good man. Just remember that research has never produced anything of value. It's a parasite riding on the coattails of industry. Promise me you'll turn this into a salable product someday and we're good.

how the fuck do i get this to run??

github.com/vurtun/nuklear#example

>research has never produced anything of value
>what is Unix and all the derivatives
That aside, it will be a stable and somewhat usable OS in a year or two. My goal is to have a website up with downloads to at least the install media by the end of this year.

HOLY FUCK CAN ANYBODY HELP WITH THIS CANCER:

github.com/vurtun/nuklear#example
github.com/vurtun/nuklear#example
github.com/vurtun/nuklear#example
github.com/vurtun/nuklear#example
github.com/vurtun/nuklear#example
github.com/vurtun/nuklear#example

did you #include everything that is necessary ?
do you have opengl ?

how the fuck am i supposed to know what #includes are necessary. It doesn't say it anywhere in the readme.

just how do i get that example to work the fuck is it left like that on the git hub for if you cannot run the fucking code.

>begging this much
>the absolute state of github users in 2018
how about you actually read the docs instead of just copying and pasting random code and expecting it to work

no. there isn't any actual drawing done by the lib; it is up to the user to glue the lib and whatever display technology you are using. You can check here for examples of how this is done: github.com/vurtun/nuklear/tree/master/demo

>glew
>opengl
>underlying API of your choice in which you will need to implemet all the drawing yourself
>"No dependencies"
Of course it "makes fast applications and does not eat up resources" since it does exactly nothing itself.

Not him but you're wrong. A tutorial should be exactly that: copy and paste.

I could be mistaken but it seems obvious that the input side has the same issue (unless he's reading mouse through pci? madman?)
granted getting mouse coordinates and button presses hooked up is somewhat more trivial than implementing the code to actually draw from his vector format, but still, it's that much more useless.

#include "nuklear.h"
It is in the previous section.

Can someone explain the difference between and immediate mode framework and a typical event driven one for a brainlet

Yep, all the input/clipboard handling/etc is done through underlying system API calls too.

no you're wrong because it's clearly not a tutorial

UI programming is done with html/css/js now gramps.

This is the software-as-a-service era where you want your application accessible everywhere. But you also want to lock customers into your subscription service. So you have your program run on your server and charge them for access, forcing them to pay each month.

It's not good for consumers, but it's the correct way to run a software business.

Attached: 1510761978002.png (233x216, 7K)

That screenshot looks like shit I would create on Garry's Mod using Wiremod's EGP.

Already explained here on this thread.

web ui is absolute suffering, especially when the browsers re inconsistent.

if he had done iso c like a sane person at least he could probably use a WASM compiler

This.
Web development in general is fucking horrible and it makes me want to kill myself.
I fucking hate CSS+HTML.

fug my bad

whoopee

>I have just one problem with nuklear, it compiles too slowly.
Disable optimizations or build with tcc, examples will be built in a breeze.

I really like the way it looks but I would rather use gtk.

Attached: Screenshot from 2018-07-14 16-16-48.png (1366x768, 34K)

What's the point of the examples if they don't work?

nuklear is garbage, the examples don't run and it's not clear at all how to actually use the damn thing

It does, a gui should eat up as little of CPU as possible to leave CPU for the actual software. Also to be noted that a LOT of application still do a large part of work in the main thread (if you're looking at single-header C gui library, you might think threads are a hassle). Otherwise, you have to somehow do that interprocess sync and have a clean MVC that can feed the GUI content and all hell breaks loose. It's kinda ok for game small menus (like showcased) or simple scripting embedding, but not for larger softwares.

At that point though, having a proper toolkit linked dynamically within an environment is not so bad (Gtk and Qt for example). It's your job to not fall into the trap of writing entangled code with those toolkits. No dependencies is a meme, using good existing libraries is the smart way, and even smarter is understanding what to leave out from your code (especially in Qt's case).

>wasting processing cycles on fucking UI rendering

what a moran

cd to folder, type make

stop looking at the shitty example in the readme and actually look in the examples or demo folder

you don't need threading, you just need an event loop that uses epoll or similar, if you want to reduce cpu usage then keep another buffer for the GUI that only updates when you get an event, and then just blit it directly when you need to redraw the whole screen

does it still do that for real?

It's pretty clear: nuklear handles the UI, that's it. You need to use win32api, opengl, vulkan, x11 etc. to create a canvas for rendering, and then nuklear will draw the UI onto it. The code in the demos directory uses many different graphics APIs.

And obviously you also need to use some kind of API to grab the user input and pass it to nuklear.

The examples don't work and are way too complex, I just want a window and a couple buttons

>rather use gtk

Attached: 1526226775744.jpg (380x349, 27K)

anywhere i can follow you user? this is interesting

I occasionally shitpost on Jow Forums.org/g/. You can find me under the username "Anonymous".

fag

kys

Learn to take a fucking joke, m8.

Attached: hitler.jpg (1200x817, 703K)

No u

open steam in command line and look at the output lmao, it outputs FPS

>cding to a folder and typing make is too complex
you aren't going to make it, maybe try web development it might be more your speed