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

Function WindowSetPluginRemote

src/override/Window.cpp:250–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250void WindowSetPluginRemote(Window* const window, NanoTopLevelWidget* const tlw)
251{
252 // if nanovg context failed, init only bare minimum
253 if (window->vg == nullptr)
254 {
255 if (tlw != nullptr)
256 {
257 window->internal->tlw = tlw;
258 window->internal->size = rack::math::Vec(tlw->getWidth(), tlw->getHeight());
259 }
260 else
261 {
262 window->internal->tlw = nullptr;
263 window->internal->callback = nullptr;
264 }
265 return;
266 }
267
268 if (tlw != nullptr)
269 {
270 const GLubyte* vendor = glGetString(GL_VENDOR);
271 const GLubyte* renderer = glGetString(GL_RENDERER);
272 const GLubyte* version = glGetString(GL_VERSION);
273 INFO("Renderer: %s %s", vendor, renderer);
274 INFO("OpenGL: %s", version);
275
276 window->internal->tlw = tlw;
277 window->internal->size = rack::math::Vec(tlw->getWidth(), tlw->getHeight());
278
279#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
280 // Set up NanoVG
281 window->internal->r_vg = tlw->getContext();
282#ifdef NANOVG_GLES2
283 window->internal->r_fbVg = nvgCreateSharedGLES2(window->internal->r_vg, NVG_ANTIALIAS);
284#else
285 window->internal->r_fbVg = nvgCreateSharedGL2(window->internal->r_vg, NVG_ANTIALIAS);
286#endif
287
288 // swap contexts
289 window->internal->o_vg = window->vg;
290 window->internal->o_fbVg = window->fbVg;
291 window->vg = window->internal->r_vg;
292 window->fbVg = window->internal->r_fbVg;
293
294 // also for fonts and images
295 window->uiFont->vg = window->vg;
296 window->uiFont->handle = loadFallbackFont(window->vg);
297 for (auto& font : window->internal->fontCache)
298 {
299 font.second->vg = window->vg;
300 font.second->ohandle = font.second->handle;
301 font.second->handle = nvgCreateFont(window->vg,
302 font.second->ofilename.c_str(), font.second->ofilename.c_str());
303 }
304 for (auto& image : window->internal->imageCache)
305 {
306 image.second->vg = window->vg;
307 image.second->ohandle = image.second->handle;

Callers

nothing calls this directly

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