Login / Register 0 items | $0.00 New @ KVR
User avatar
syntonica
KVRist
 
389 posts since 24 Sep, 2014, from Specific Northwest

Postby syntonica; Tue Dec 19, 2017 10:44 pm Re: nanovg for plugin uis

I revisited my OGL branch and got it mostly working. (No resizing yet and text input is a bit iffy from DAW to DAW.)

I solved the antialiasing issue, but OGL still has its weird little ways. Like it has its own gamma. I had to fudge my numbers to get my colors to come out right. Due to the antialiasing, though, the white bits are more off-white and the alien green waves are a bit dim and fluffy. I think if I futz with it some more, I can get it looking how I want.

The best bit, however, is NO Cocoa! No Objective-C++! And I shouldn't have to change anything to compile on Windows! Yay!

So, is OpenGL worth it? Now that I have an inkling of what I am doing, yes, absolutely! And I only went through two dozen APIs...
mystran
KVRAF
 
4888 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Wed Dec 20, 2017 12:34 am Re: nanovg for plugin uis

stratum wrote:
At this point, I've pretty much abandoned the idea and am steeling myself to learn Windows GDI... :?


The problem is not that you don't use GDI but rather if you do not know GDI you probably do not know WIN32 programming (and related GUI message handling mechanism).
GDI is outdated and is kept only for compatibility, and there is confusing information about it in the web about whether it's still properly hardware accelerated or not.


GDI lost acceleration in Vista, but in Win7 they added some of it back for the more important stuff (forgot the details, but I think at least it should do HW blits). I doubt they broke it again in later versions, but who knows.

Either way, SetDIBitsToDevice (or BitBLT) works fine (so you don't need to bother with OpenGL just to blit software rendering, like you'd do on macOS) and if you're using GDI for anything else you're probably doing something wrong (well, I suppose you could let it render text if you're lazy, for anything else it just sucks).
Image <- plugins | forum
mystran
KVRAF
 
4888 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Wed Dec 20, 2017 12:39 am Re: nanovg for plugin uis

syntonica wrote:I revisited my OGL branch and got it mostly working. (No resizing yet and text input is a bit iffy from DAW to DAW.)


For plugins on Windows it's generally necessary to manually synthesize the text input from WM_KEYDOWN messages (eg. you call MapVirtualKey followed by ToUnicode, probably followed by WideCharToMultiByte to get it into UTF-8) since some hosts don't bother with TranslateMessage that would normally turn these into WM_UNICHAR. This won't give you full IME support (and please don't ask me how to do that), but it will use the current keyboard layout and will handle simple dead keys (eg. for accents) and such.

Either way, once you do the translation manually, basic text input will work in any host that gives you focus as long as the host doesn't steal your keyboard shortcuts (eg. standard copy-paste and such might require some further magic). If you want the shortcuts too, then you need to play around with hooks... which is bit of an "advanced topic."

I solved the antialiasing issue, but OGL still has its weird little ways. Like it has its own gamma. I had to fudge my numbers to get my colors to come out right. Due to the antialiasing, though, the white bits are more off-white and the alien green waves are a bit dim and fluffy. I think if I futz with it some more, I can get it looking how I want.


OpenGL can support sRGB framebuffers (and textures), at which point the implementation is expected to convert to/from linear space so your shaders don't need to bother. Not sure why that would happen if you didn't ask for it, but if you're using some wrapper lib then sanity check that it's not trying to be "helpful."
Image <- plugins | forum
PurpleSunray
KVRian
 
780 posts since 13 Mar, 2012

Postby PurpleSunray; Wed Dec 20, 2017 1:43 am Re: nanovg for plugin uis

The best bit, however, is NO Cocoa! No Objective-C++! And I shouldn't have to change anything to compile on Windows! Yay!
So, is OpenGL worth it? Now that I have an inkling of what I am doing, yes, absolutely! And I only went through two dozen APIs...

ahaha, two dozen is not enough - feel like i have passed the 100x already :D :lol:
If it is for portability, I would probably have used a lib like Skia, Cairo or Fog library (no platform depending stuff, this includes OpenGL).
They have a hardware + pure software implemenation and they are optimized to hell (i.e. Chrome and Android use Skia). This runs everywhere, if GL has an issue, fallback to software rasterizer (such done by GPU backlist on Chrome for almost all GPUs on market :lol: )

Like it has its own gamma. I had to fudge my numbers to get my colors to come out right.

Try using GL_SRGB for the framebuffer. With GL_RGB you need to do gamma correction manually, with GL_SRGB GL should do it for you (glEnable(GL_FRAMEBUFFER_SRGB))

I solved the antialiasing issue, but OGL still has its weird little ways.

You do to with nanovg or GL?
There are two ways you can do antialiasing: MSAA via OpenGL (GPU does antialiasing when drwaing) or antialiasing via gemorty which is implemented by nanovg (nanovg builds a gemorty that is already anti-aliased).
They can look different indeed ;)
User avatar
syntonica
KVRist
 
389 posts since 24 Sep, 2014, from Specific Northwest

Postby syntonica; Wed Dec 20, 2017 10:21 am Re: nanovg for plugin uis

mystran wrote: but it will use the current keyboard layout and will handle simple dead keys (eg. for accents) and such.

Either way, once you do the translation manually, basic text input will work in any host that gives you focus as long as the host doesn't steal your keyboard shortcuts (eg. standard copy-paste and such might require some further magic). If you want the shortcuts too, then you need to play around with hooks... which is bit of an "advanced topic."

I'm just being lazy. I haven't learned yet how UTF8/Unicode is handled. My unupgraded brain still thinks in ASCII.

7 bit.

OpenGL can support sRGB framebuffers (and textures), at which point the implementation is expected to convert to/from linear space so your shaders don't need to bother. Not sure why that would happen if you didn't ask for it, but if you're using some wrapper lib then sanity check that it's not trying to be "helpful."


I tried srgb, but it made everything horribly brighter! I need to dim everything from my original numbers. I used 1.8 gamma (since Apple...) and while it's closer, it's actual a tad too dark.

I get how OpenGL works in general, but there's 5000 fussy settings to fuss with and I still need to learn them all. :?
hibrasil
KVRian
 
763 posts since 23 Jun, 2002, from Huddersfield, UK

Postby hibrasil; Wed Dec 20, 2017 10:27 am Re: nanovg for plugin uis

DNAdisaster wrote:I use nanovg + glfw in my modular synth project: https://github.com/austensatterlee/VOSIMSynth

The simple API was a big draw for me, especially since I was planning on drawing most of it on the fly. Once you get to the point where your window and opengl context is set up, nanovg is a pretty smooth ride.


I thought GLFW wouldn't work in a plug-in. PUGL is pretty cool -> https://github.com/drobilla/pugl

I'm currently reworking IPlug, to make it much easier to experiment with different UI frameworks, might be useful for your project.
My Website | WDL-OL | Web Audio Modules - WAMs | Oli Larkin Plugin's Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
User avatar
syntonica
KVRist
 
389 posts since 24 Sep, 2014, from Specific Northwest

Postby syntonica; Wed Dec 20, 2017 10:37 am Re: nanovg for plugin uis

PurpleSunray wrote:ahaha, two dozen is not enough - feel like i have passed the 100x already :D :lol:
If it is for portability, I would probably have used a lib like Skia, Cairo or Fog library (no platform depending stuff, this includes OpenGL).
They have a hardware + pure software implemenation and they are optimized to hell (i.e. Chrome and Android use Skia). This runs everywhere, if GL has an issue, fallback to software rasterizer (such done by GPU backlist on Chrome for almost all GPUs on market :lol: )

You do to with nanovg or GL?
There are two ways you can do antialiasing: MSAA via OpenGL (GPU does antialiasing when drwaing) or antialiasing via gemorty which is implemented by nanovg (nanovg builds a gemorty that is already anti-aliased).
They can look different indeed ;)

Skia, Cairo, SDL, etc. are all far too heavyweight for my purposes. My original Mac-native plugin came in at a bit over 1mb, code size. The new OpenGL version is double that at 2mb. It makes me feel all bloaty now! :hihi: Using any of those libraries would make my plugin Baron Harkonnen sized. I need to turn on dead stripping, I think, to lose a bit of weight, or maybe just delete out the unwanted GUI stuff. I just need event handling and basic raster drawing. That's it! Funny thing is, I can write my own GUI faster than I can try and learn to use someone else's. My brain vs alien tech brain. :borg:

I know there's better anti-aliasing out there. I just need to dig into nanoVG and see how they set everything up. And how they handle color space. And all the settings OpenGL offers... :roll:

If developers want to be "helpful", they can write accurate, complete documentation and not make assumptions about what everybody wants and then bury them under five layers of wrapping.
User avatar
syntonica
KVRist
 
389 posts since 24 Sep, 2014, from Specific Northwest

Postby syntonica; Wed Dec 20, 2017 10:45 am Re: nanovg for plugin uis

hibrasil wrote:
DNAdisaster wrote:I use nanovg + glfw in my modular synth project: https://github.com/austensatterlee/VOSIMSynth

The simple API was a big draw for me, especially since I was planning on drawing most of it on the fly. Once you get to the point where your window and opengl context is set up, nanovg is a pretty smooth ride.


I thought GLFW wouldn't work in a plug-in. PUGL is pretty cool -> https://github.com/drobilla/pugl

I'm currently reworking IPlug, to make it much easier to experiment with different UI frameworks, might be useful for your project.

I'm using PUGL + nanoVG. Pugl is good, but a tad buggy. I've got an email in to the developer. For some reason, he didn't include double-clicking! And there's an issue with the timestamp function on events. Windows does longs and Mac does doubles, so Macs only report time by the second as the millis get truncated. :lol: I'm also having issues with the c++ wrapper, so I side step a lot of it. Hopefully, I'll hear back about why double clicks were not implemented. (I'm not familiar with X11, so the reason may lie there.). I want Linux as an option, still, before I start hacking away.

No comments on nanoVG. Yet... :hihi:
hibrasil
KVRian
 
763 posts since 23 Jun, 2002, from Huddersfield, UK

Postby hibrasil; Wed Dec 20, 2017 10:46 am Re: nanovg for plugin uis

it would be great if the operating systems had decent embedded web views, then we could make < 1mb plug-ins that relied on the heavily optimised embedded webview. on the other hand you have native instruments releasing 35 megabyte phaser!
My Website | WDL-OL | Web Audio Modules - WAMs | Oli Larkin Plugin's Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
stratum
KVRAF
 
1792 posts since 29 May, 2012

Postby stratum; Wed Dec 20, 2017 5:01 pm Re: nanovg for plugin uis

it would be great if the operating systems had decent embedded web views, then we could make < 1mb plug-ins that relied on the heavily optimised embedded webview


Windows still has IE as a widget. use at your own risk :wink:
Honestly I have never understood the attractiveness of HTML as a GUI description language. Sucks beyond reason.
~stratum~
User avatar
syntonica
KVRist
 
389 posts since 24 Sep, 2014, from Specific Northwest

Postby syntonica; Wed Dec 20, 2017 5:27 pm Re: nanovg for plugin uis

SVG graphics. Lots of brackets, but you only have to write once.
stratum
KVRAF
 
1792 posts since 29 May, 2012

Postby stratum; Wed Dec 20, 2017 5:38 pm Re: nanovg for plugin uis

Write once debug everywhere? I had heard that as a description of Java applets (about 10-15 years ago) and the speaker (somebody from IBM? introducing newer "web technologies" in a conference I don't quite recall well) had promised a bright new future for newer the web tech which would be quite different. Blah blah.
~stratum~
DNAdisaster
KVRist
 
36 posts since 31 Jan, 2011

Postby DNAdisaster; Wed Dec 20, 2017 7:14 pm Re: nanovg for plugin uis

hibrasil wrote:
DNAdisaster wrote:I use nanovg + glfw in my modular synth project: https://github.com/austensatterlee/VOSIMSynth

The simple API was a big draw for me, especially since I was planning on drawing most of it on the fly. Once you get to the point where your window and opengl context is set up, nanovg is a pretty smooth ride.


I thought GLFW wouldn't work in a plug-in. PUGL is pretty cool -> https://github.com/drobilla/pugl

I'm currently reworking IPlug, to make it much easier to experiment with different UI frameworks, might be useful for your project.

It took some hacking, but it's possible with some OS-specific code to attach the GLFW window to the one provided by the host. I heard of PUGL a while back, but unfortunately after I spent ages getting GLFW to work. It seems like a good alternative to GLFW for plugin work. I'd love to see your work on IPlug once it's ready. The way I'm integrating my graphics solution with IPlug right now is horrendously hacky.

@syntonica: Oddly enough, double clicking is not a feature of GLFW either. I ended up rolling my own double click event, which isn't terribly challenging.
User avatar
syntonica
KVRist
 
389 posts since 24 Sep, 2014, from Specific Northwest

Postby syntonica; Thu Dec 21, 2017 12:04 am Re: nanovg for plugin uis

DNAdisaster wrote:@syntonica: Oddly enough, double clicking is not a feature of GLFW either. I ended up rolling my own double click event, which isn't terribly challenging.


It's not difficult at all, but the system should be setting the double-click speed, not the program. Both Mac and Windows both return double and single clicks.
User avatar
syntonica
KVRist
 
389 posts since 24 Sep, 2014, from Specific Northwest

Postby syntonica; Thu Dec 21, 2017 12:15 am Re: nanovg for plugin uis

Other than some GUI tweaking, my conversion to OpenGL is complete!. I only had to give up one feature--the user must close and reopen the GUI window if they resize. Too much hoohaw going on in setting up the OpenGL window and attaching it.

My code size doubled and the GUI is a couple of percent of my CPU slower. Before, my graphics were all native, which were amazingly fast for what was I'm doing.

NanoVG definitely has not been optimized for the kind of abuse I'm sending its way. More time is spent in seeing up each frame than is spent drawing my entire GUI, so I'm curious as to what's really going on under the hood. I've been more concerned with getting my VST completed. Soon, I'll be into that code, hacking around.

One more thing about Pugl that attracted me was the ability to use it to create a child window and attach it to the parent that's extant. No futzing about with extra windows. All in all, it's pluses have far outweighed its minuses.
PreviousNext

Moderator: Moderators (Main)

Return to DSP and Plug-in Development