5 ms·
Cool. Recent anecdote, I've been looking into ways to setup a semi-complex GUI around an OpenGL canvas. Buttons, menus, styling, scrolling, all that jazz. I lo
by leggomylibro 9y ago
Cool. Recent anecdote, I've been looking into ways to setup a semi-complex GUI around an OpenGL canvas. Buttons, menus, styling, scrolling, all that jazz.
I looked into existing options like QT, but found them to be extremely large and full of things I didn't need. I don't blame them for that; they're designed to support a huge range of inputs and have a lot of associated assets. I've also heard that it's possible to build custom 'lite' distributions. But it looked imposing enough to get into as a user that I was about ready to just write buttons and dropdowns and scroll bars in raw OpenGL. It was gonna be messy.
But then, I decided to just use a web browser.
And it was so easy. You can have an OpenGL ES 3 canvas surrounded by UI elements which don't look horrendous, with just an hour or two of setup. The whole thing can respond very gracefully to things like window resizing without much added effort. It is very easy to pass values between the GL context and the UI elements. It is trivial to save/load configurations with any sort of web framework.
Something that could offer similar usability in C definitely sounds exciting. I mean, I complained about QT being bloated, but so is a modern web browser. Most people just happen to already have one pre-configured, and most developers just happen to already be familiar with how one works.
- mixmastamyk 9y agoCame across this yesterday: Nuklear This is a minimal state immediate mode graphical user interface toolkit written in ANSI C and licensed under public domain. https://github.com/vurtun/nuklear https://github.com/vurtun/nuklear https://github.com/billsix/pyNuklear https://github.com/billsix/pyNuklear
- leggomylibro 9y agoNeat, thanks for sharing! (edit) Wow, that looks way more powerful and embeddable than I was expecting. I'll have to give it a try.
- billsix 9y agoLol I was just about to repost my pyNuklear link. Regular nuklear is fantastic if you like C, which I do too :-).
- mixmastamyk 9y agoWe bumped into each other yesterday on the PyQt thread, and the grandparent seemed to be asking for the same thing. ;-)
- lj3 9y agohttps://github.com/zacharycarter/nuklear-nim/ https://github.com/zacharycarter/nuklear-nim/ Nim's syntax is very python like, but it's statically typed and compiles to C. Best of both worlds.
- modeless 9y agoThis is a good one too: https://github.com/ocornut/imgui https://github.com/ocornut/imgui
- wazanator 9y agoSeconding Dear Imgui, it's a great small library that has a ton of bindings available. Highly recommend Flix01's addons branch https://github.com/Flix01/imgui/wiki/ImGui-Addons-Branch-Home https://github.com/Flix01/imgui/wiki/ImGui-Addons-Branch-Hom...
- royjacobs 9y agoDo you have an idea why this is not just merged back into 'regular' Imgui? I like the look of some of the addons, but by having this fork no Imgui bindings will support them.
- eggy 9y agoimgui is a C++ libarary, which is why I chose nuklear being a C library written in C89. Just a small distinction, but some people are working in just C.
- polskibus 9y agoWhat did you use in the browser for UI and GL?
- leggomylibro 9y agoPretty much just CSS and Bootstrap for things like nested menus. The normal input/a tags are pretty versatile, but Bootstrap does also help a lot.
- haxiomic 9y agoI like this approach, I'm keen to try it too – is the project open source? Which browser engine did you use? One advantage of this approach compared to the minimal UI libraries is that you can expect it to work well with a massive array of hardware – elements like scroll boxes should work seamlessly with touchscreens, apple trackpads and regular wheel mice, text input elements should respect the user's navigation key bindings. Accessibility features like voiceover should be supported. The downside is of course the weight of the browser engine compared to a tiny C library, however it'd be an interesting experiment to see how much bloat could be stripped out of a browser if you only care about a subset of features, i.e, WebGL can go, legacy layout modes can go etc
- jcelerier 9y agoI wonder what's the point of people touting about reusable code is when as soon as a set of 71 distinct libraries, most of them optional, (disclaimer: ls /usr/lib/libQt5*.so | wc -l) full of reusable code with a common API and coding conventions is not considered since it's apparently "too much". Do you really prefer to learn a different API and library for every different part of your app ?
- deleted 9y ago[deleted]
- jstimpfle 9y agoYou should look into the sibling comments (nuklear, DearImgui, Casey Muratori), and try doing a simple toolkit for your own use. Then you will understand the difference. Qt is huge, and opinionated, and very difficult to control. Qt is not focused on being a useful tool that you simply put next to your other modules, and plays nice when it's called. Qt wants to be a framework that drives your application. Qt expects you to speak in its own datatypes, not type-agnostic flat memory. I mean, I've only used Qt very briefly, but how would I, for example, use Qt widget functionality to add a nice menu to my existing 3d game? It's uncommon enough that I can't easily find how to do it, and I wouldn't be surprised if it's next to impossible.
- billsix 9y agoFully agreed. With Qt, Qt itself is the app, your code is just a plug-in. :-)
- jcelerier 9y ago> I mean, I've only used Qt very briefly, but how would I, for example, use Qt widget functionality to add a nice menu to my existing 3d game? I don't think that would be very desirable: Qt widgets are made to mimick the desktop OS themes... I doubt you want these in games. However, you could use QtQuick, here is for instance an example of integration with a 3d game engine: https://github.com/MaxSavenkov/nya_qt https://github.com/MaxSavenkov/nya_qt And another which integrates with the creative coding framework openFrameworks: https://github.com/aklevy/ofUnderQml https://github.com/aklevy/ofUnderQml ; doing for instance a HUD à la Scaleform with these is fairly realistic given the nice scene graph of QtQuick
- emilfihlman 9y agoYeah I don't even bother with thinking about building desktop applications. User interfaces are over 9001 times easier and faster to build as web pages / pwas.
- chatmasta 9y agoIs the browser really lighter weight than Qt?
- adultSwim 9y agoI view this all as a huge step backwards. This is exactly why my glorified IRC client takes over a gigabyte to run. The killer app is if this was all done at compile time. Use common web technologies to design the UI, translate that into lightweight GUI code.
- viperscape 9y agoA bit of a stretch, but you can use Electron (https://electronjs.org/ https://electronjs.org/) which ties to nodejs, and use nodejs to call out to C.
- rdavalos 9y agoOr a webview using Webkit or IE11. There is a cross-platform wrapper in C99 [1] [1]: https://github.com/zserge/webview https://github.com/zserge/webview
- viperscape 9y agoThis is awesome, thanks for sharing !
- davedx 9y agoWe're currently looking at pxCore / pxScene. It's a fairly small couple of libraries with a portable frame buffer layer (core) and hardware accelerated 2D scene graph (scene) with an optional JavaScript API (you can also just use C++ too).
- Const-me 9y ago> Something that could offer similar usability in C definitely sounds exciting For painting, I have positive experience with this cross-platform C library: https://github.com/memononen/nanovg https://github.com/memononen/nanovg It’s tiny, has very few dependencies, and the performance is good even on relatively slow hardware like Broadcom or Mali embedded GPUs. However, it lacks higher level stuff. There’s no layout, input handling, styles, controls, advanced typesetting, or animations.
- ris 9y agoAmusing. > options like QT, but found them to be extremely large and full of things I didn't need > But then, I decided to just use a web browser.
- tripzilch 9y agoI'm a bit unclear, do you mean you fully switched to using a WebGL canvas with HTML-based controls? Or more like a browser-widget embedded in your application with HTML UI widgets, that somehow controls a separate OpenGL canvas?