MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / WindowSetPluginUI

Function WindowSetPluginUI

src/override/Window.cpp:362–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362void WindowSetPluginUI(Window* const window, CardinalBaseUI* const ui)
363{
364 // if nanovg context failed, init only bare minimum
365 if (window->vg == nullptr)
366 {
367 if (ui != nullptr)
368 {
369 window->internal->ui = ui;
370 window->internal->size = rack::math::Vec(ui->getWidth(), ui->getHeight());
371 }
372 else
373 {
374 window->internal->ui = nullptr;
375 window->internal->callback = nullptr;
376 }
377 return;
378 }
379
380 if (ui != nullptr)
381 {
382 const GLubyte* vendor = glGetString(GL_VENDOR);
383 const GLubyte* renderer = glGetString(GL_RENDERER);
384 const GLubyte* version = glGetString(GL_VERSION);
385 INFO("Renderer: %s %s", vendor, renderer);
386 INFO("OpenGL: %s", version);
387
388 window->internal->tlw = ui;
389 window->internal->ui = ui;
390 window->internal->size = rack::math::Vec(ui->getWidth(), ui->getHeight());
391
392#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
393 // Set up NanoVG
394 window->internal->r_vg = ui->getContext();
395#ifdef NANOVG_GLES2
396 window->internal->r_fbVg = nvgCreateSharedGLES2(window->internal->r_vg, NVG_ANTIALIAS);
397#else
398 window->internal->r_fbVg = nvgCreateSharedGL2(window->internal->r_vg, NVG_ANTIALIAS);
399#endif
400
401 // swap contexts
402 window->internal->o_vg = window->vg;
403 window->internal->o_fbVg = window->fbVg;
404 window->vg = window->internal->r_vg;
405 window->fbVg = window->internal->r_fbVg;
406
407 // also for fonts and images
408 window->uiFont->vg = window->vg;
409 window->uiFont->handle = loadFallbackFont(window->vg);
410 for (auto& font : window->internal->fontCache)
411 {
412 font.second->vg = window->vg;
413 font.second->ohandle = font.second->handle;
414 font.second->handle = nvgCreateFont(window->vg,
415 font.second->ofilename.c_str(), font.second->ofilename.c_str());
416 }
417 for (auto& image : window->internal->imageCache)
418 {
419 image.second->vg = window->vg;

Callers 2

fInitializerFunction · 0.50
~CardinalUIFunction · 0.50

Calls 8

VecClass · 0.85
getWidthMethod · 0.80
getHeightMethod · 0.80
c_strMethod · 0.80
loadFallbackFontFunction · 0.70
WindowParametersRestoreFunction · 0.70
onContextCreateMethod · 0.45
onContextDestroyMethod · 0.45

Tested by

no test coverage detected