Cross Platform GUI - VST3 and AU.

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

I find myself at an infuriating standstill. There are multiple cross-platform graphics libraries - but I need a graphics library that can reliably create a view from an existing HWND and draw on it without "altering" it.

From the Steinberg VST SDK iplugview.h:

/** The parent window of the view has been created, the (platform) representation of the view
should now be created as well.
Note that the parent is owned by the caller and you are not allowed to alter it in any way
other than adding your own views.
Note that in this call the plug-in could call a IPlugFrame::resizeView ()!
\param parent : platform handle of the parent window or view
\param type : \ref platformUIType which should be created */

My most recent attempt involved SDL. The following runs in a std::thread spawned via lambda when the host calls "attached" on my plugin's implementation of IPlugView. It renders a beautiful fuscia rectangle. Then, when "removed" is called, it breaks out of the run loop when atomic bool "isrunning" is set to false... and hangs forever on "SDL_DestroyWindow(window);"

void AudioObjectsGUI::guiLoop()
{
//init
isRunning = true;
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindowFrom(parent)
SDL_Surface* s = SDL_GetWindowSurface(window);
SDL_FillRect(s, &s->clip_rect, 0xffff00ff);
SDL_UpdateWindowSurface(window);

//main loop
while (isRunning)
{
}

//cleanup
SDL_DestroyWindow(window); //hangs here
SDL_Quit();
}

- Nothing besides the above function in its own thread touches "window"
- I tried adding SDL_SetHintWithPriority(SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT, "1", SDL_HINT_OVERRIDE); at the beginning of this function and it crashed on "SDL_CreateWindowFrom(parent)"

My conclusion is that both of these crashes are caused by SDL somehow "altering" the underlying native window that we're not allowed to alter (or breathe on, or look at, or think about). The first version of the crash might be happening on window destruction because SDL is actually attempting to destroy the native window. The second version of the crash might be happening because SDL is attempting to create an openGL context in the native window, somehow altering it in the process.

Thoughts? I'm getting pretty demoralized by this process and I find myself alternating between "maybe VSTGUI4 is the devil I know..." and "man, I wish I didn't have to completely tie my gui in with Steinberg so I can more easily port it for other plugin formats" and "I swear they made it this difficult on purpose!"

Post

SDL is really a platform abstraction library for games rather than a GUI toolkit and games often do things a bit differently from native applications, so expect some friction. In fact, expect friction with pretty much anything not explicitly designed to support plugins... but expect more friction with libraries designed for games.

Windows generally does not like multi-threading very much and if you have the parent and child windows in different threads and one needs to send a message to the other when the other isn't pumping events, you'll have a deadlock because of how the messages get dispatched through the thread's message queues, which is what might be going on here.

With OpenGL contexts there's another gotcha: in a plugin situation where different plugins might have their own contexts you really need to manage those correctly with wglMakeCurrent. I can't remember how much SDL will help you with this, but it might not do it automatically, 'cos you kinda don't necessarily need that in games when you just have one context anyway. If you look at a crash stack-trace and see your OpenGL drivers there, some issue with the contexts is probably the most likely cause.

ps. As far as VSTGUI though, I highly recommend that if you absolutely have to touch it, use a very long stick.

Post

I have succeeded at multiple rendering contexts using pugl with GLEW to create two triangles in two separate windows. I am beyond thrilled.

Now I just have to figure out how to render and manipulate SVGs, handle mouse events, and potentially render fun stuff like oscilloscopes and parametric controls and other fun nonsense.
thankgiving miracle.jpg
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “DSP and Plugin Development”