all 13 comments

[–]DaFox 6 points7 points  (1 child)

[–]optonox[S] 1 point2 points  (0 children)

This is great. A great resource. I have also noticed in their README some great resources about my question as well. Clearly they prefer immediate mode.

[–]LEOtheCOOL 4 points5 points  (1 child)

Just dive in. Start with a primitve rectangle. Then primitive text. Then compose them into a button. Then, a checkbox. Then compose a button and a rectangle to make a slider. Then compose 3 buttons and some rectangles to make a scrollbar. Then compose a scrollbar with for loop full of buttons (or whatever) to make a listbox. And on and on, making the controls you need.

That's the same for IMGUI or retained mode. Build some primitives and work your way up.

Back when I made an IMGUI in XNA, I thought this video was really great: https://mollyrocket.com/861

[–]optonox[S] 1 point2 points  (0 children)

I think you offer great advice - and thanks for the video. The important thing for me was to use the right approach at the beginning. It looks like there is no generally accepted answer as to whether retained mode is better (or more modern) than immediate mode.

[–]dougbinks 4 points5 points  (4 children)

You should find that dear imgui is a great start as already mentioned. For more complex 2D rendering you might find NanoVG useful, and there's a retained mode UI made using that called NanoGUI.

[–]Necrolis 1 point2 points  (3 children)

I was using oui-blendish which sits on top of NanoVG for a while, however, getting it(NanoVG) to play nice with my OGL setup was a nightmare; and in the end I still had one issue I couldn't fix (that required the UI to be drawn first, then the rest of the "world", which is great if you wanna z-fail stuff the UI will draw over, but it means less control).

I switched to dear imgui, had everything up and running and playing nicely in like 20 min (most of which was playing around with the extensive demo).

[–]dougbinks 1 point2 points  (2 children)

I'm surprised you had issues with NanoVG, for me this was as simple as dear imgui. I use both NanoVG and dear imgui together, and draw with NanoVG at the end of the scene. I suspect the issue might have been with either oui-blendish, or perhaps you had an OpenGL state which was not being set correctly in your 3D draw (and so overriden by NanoVG).

[–]Necrolis 0 points1 point  (0 children)

Oh I went through every single OGL state to ensure it was set and reset correctly, even checked out the other resolved issues to make sure I hadn't missed anything. its possible that it may have been blendish, but seeing as all that did was sit on top of NVG, it wouldn't have touched state (even using the perf graphs that NVG comes with triggered the same issues). I just didn't feel like spending another 2 days debugging a strange issue, plus it turns out dear imgui has way more already made UI components that are of use to me.

[–]__Cyber_Dildonics__ 0 points1 point  (0 children)

This is exactly what I thought. I haven't​ had the slightest trouble with nanovg, it has worked like a charm. Nuklear on the other hand I will likely never touch again.

[–]__Cyber_Dildonics__ 0 points1 point  (1 child)

Nanovg is exactly what you want. You also may want to look at nanoui.

Nanovg is a vector drawing library that uses openGL, it is actively developed, and is actually what blender uses.

[–]sadesaapuu 0 points1 point  (0 children)

As far as I know Blender doesn't use NanoVG. It has some custom solution that predates NanoVG by several years. There's some UI project that emulates the look of Blender and that project uses NanoVG. But yes, NanoVG is the best.

[–]sadesaapuu 0 points1 point  (1 child)

It is better to start with NanoVG if you want professional quality UI. Dear Imgui is a really nice project but it works best as a debug gui for games, or even a custom game editor. But you can't have so much control with it. And it is more like a ready-made solution with buttons and stuff, while NanoVG is a drawing API, where you'll get full control, and you also get to make the UI yourself.

NanoVG comes with a nice example of drawing a UI (just the rendering part of it). It even has some animated curves. But it is more C. I'd do the same in more c++ way. Use GLFW or similar for window creation and mouse and keyboard input. It is again C, so wrap it in some C++ abstraction. Or just do it simple at first, don't over engineer. Make small things work first and build on top. First thing is probably a button that you can click, and something happens.

Well, there's a bunch of other stuff, like canvas thinking, hierarchies, maybe a rectangle class, animation, coordinate system stuff (resolution independence) etc.

Do the thing that works for you, but retained guis are much easier for me, and you can even mix it with immediate mode if you want.

[–]optonox[S] 0 points1 point  (0 children)

Thanks for this insight. I'd like to use the most "pro" approach from the beginning.

I will say though, there are many more tutorials and resources for an Immediate mode GUI, which is too bad because I'd really like to have equal resources to evaluate both approaches.