iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IGraphics_include_in_plug_src.h
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#ifndef __IGRAPHICS_SRC_INC__
12#define __IGRAPHICS_SRC_INC__
13
20#include "IPlugPlatform.h"
21
22#ifndef NO_IGRAPHICS
23
24 #if defined OS_WEB
25
26 #include <emscripten.h>
27 #include <vector>
28 #include <algorithm>
29
30 // Instance registry for multi-instance support (Shadow DOM / web components)
31 std::vector<iplug::igraphics::IGraphicsWeb*> gGraphicsInstances;
32
33 void RegisterGraphicsInstance(iplug::igraphics::IGraphicsWeb* pGraphics)
34 {
35 gGraphicsInstances.push_back(pGraphics);
36 }
37
38 void UnregisterGraphicsInstance(iplug::igraphics::IGraphicsWeb* pGraphics)
39 {
40 gGraphicsInstances.erase(
41 std::remove(gGraphicsInstances.begin(), gGraphicsInstances.end(), pGraphics),
42 gGraphicsInstances.end()
43 );
44 }
45
46 void StartMainLoopTimer()
47 {
48 emscripten_set_main_loop(iplug::igraphics::IGraphicsWeb::OnMainLoopTimer, 0, 1);
49 }
50
51 #elif defined OS_WIN
52 extern HINSTANCE gHINSTANCE;
53 #endif
54
55 BEGIN_IPLUG_NAMESPACE
56 BEGIN_IGRAPHICS_NAMESPACE
57
58 #if defined OS_WIN
59 IGraphics* MakeGraphics(IGEditorDelegate& dlg, int w, int h, int fps = 0, float scale = 1.)
60 {
61 IGraphicsWin* pGraphics = new IGraphicsWin(dlg, w, h, fps, scale);
62 pGraphics->SetWinModuleHandle(gHINSTANCE);
63 return pGraphics;
64 }
65 #elif defined OS_MAC
66 IGraphics* MakeGraphics(IGEditorDelegate& dlg, int w, int h, int fps = 0, float scale = 1.)
67 {
68 IGraphicsMac* pGraphics = new IGraphicsMac(dlg, w, h, fps, scale);
69 pGraphics->SetBundleID(BUNDLE_ID);
70 pGraphics->SetAppGroupID(APP_GROUP_ID);
71 pGraphics->SetSharedResourcesSubPath(SHARED_RESOURCES_SUBPATH);
72
73 return pGraphics;
74 }
75 #elif defined OS_IOS
76 IGraphics* MakeGraphics(IGEditorDelegate& dlg, int w, int h, int fps = 0, float scale = 1.)
77 {
78 IGraphicsIOS* pGraphics = new IGraphicsIOS(dlg, w, h, fps, scale);
79 pGraphics->SetBundleID(BUNDLE_ID);
80 pGraphics->SetAppGroupID(APP_GROUP_ID);
81
82 return pGraphics;
83 }
84 #elif defined OS_WEB
85 IGraphics* MakeGraphics(IGEditorDelegate& dlg, int w, int h, int fps = 0, float scale = 1., emscripten::val canvas = emscripten::val::undefined())
86 {
87 IGraphicsWeb* pGraphics = new IGraphicsWeb(dlg, w, h, fps, scale, canvas);
88 RegisterGraphicsInstance(pGraphics);
89 return pGraphics;
90 }
91 #else
92 #error "No OS defined!"
93 #endif
94
95 END_IGRAPHICS_NAMESPACE
96 END_IPLUG_NAMESPACE
97
98#endif //NO_IGRAPHICS
99
100#endif //__IGRAPHICS_SRC_INC__
Include to get consistently named preprocessor macros for different platforms and logging functionali...
An editor delegate base class that uses IGraphics for the UI.
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
IGraphics platform class for IOS.
Definition: IGraphicsIOS.h:25
IGraphics platform class for macOS.
Definition: IGraphicsMac.h:24
IGraphics platform class for the web.
Definition: IGraphicsWeb.h:40
IGraphics platform class for Windows.
Definition: IGraphicsWin.h:26