Skip to content

03_Switching_graphics

Oli Larkin edited this page Jul 23, 2022 · 4 revisions

The default graphics back-end in iPlug2 is NanoVG, but SKIA is another option. Here are some comparisons of the different options.

SKIA is a big library that is hard to build, but we build static libs in the cloud which can be downloaded using a script. Please follow the instructions in the Dependencies folder.

Once you have the static libs in place, you can switch the backend used in your project by changing e.g. IGRAPHICS_NANOVG to IGRAPHICS_SKIA in the IDE project's config files. This is a pre-processor macro that chooses which IGraphics code to use. For a backend such as SKIA which can work on the CPU or GPU another macro which should be one of IGRAPHICS_METAL, IGRAPHICS_GL2, IGRAPHICS_GL3 or IGRAPHICS_CPU chooses which type of rendering tech to use. Currently it is not possible to switch rendering tech at run time.

macOS/iOS

On macOS/iOS in the .xcconfig files you can edit EXTRA_ALL_DEFS for your project. You also need to modify EXTRA_LNK_FLAGS to make sure that the skia static libraries get linked.

https://github.com/iPlug2/iPlug2/blob/master/Examples/IPlugEffect/config/IPlugEffect-mac.xcconfig#L27

index 6cd08e4a6..afdbcf25f 100644
--- a/Examples/IPlugEffect/config/IPlugEffect-mac.xcconfig
+++ b/Examples/IPlugEffect/config/IPlugEffect-mac.xcconfig
@@ -17,14 +17,14 @@ BINARY_NAME = IPlugEffect
 // HEADER AND LIBRARY SEARCH PATHS
 EXTRA_INC_PATHS = $(IGRAPHICS_INC_PATHS)
 EXTRA_LIB_PATHS = $(IGRAPHICS_LIB_PATHS)
-EXTRA_LNK_FLAGS = //$(IGRAPHICS_LNK_FLAGS)
+EXTRA_LNK_FLAGS = $(IGRAPHICS_LNK_FLAGS)
 
 // EXTRA_APP_DEFS =
 // EXTRA_PLUGIN_DEFS =
 
 //------------------------------
 // PREPROCESSOR MACROS
-EXTRA_ALL_DEFS = OBJC_PREFIX=vIPlugEffect SWELL_APP_PREFIX=Swell_vIPlugEffect IGRAPHICS_NANOVG IGRAPHICS_METAL
+EXTRA_ALL_DEFS = OBJC_PREFIX=vIPlugEffect SWELL_APP_PREFIX=Swell_vIPlugEffect IGRAPHICS_SKIA IGRAPHICS_CPU

Windows

On windows you just have to modify EXTRA_ALL_DEFS in the .props file for your project

https://github.com/iPlug2/iPlug2/blob/master/Examples/IPlugEffect/config/IPlugEffect-win.props#L6

diff --git a/Examples/IPlugEffect/config/IPlugEffect-win.props b/Examples/IPlugEffect/config/IPlugEffect-win.props
index 923dfe067..81ea0a18e 100644
--- a/Examples/IPlugEffect/config/IPlugEffect-win.props
+++ b/Examples/IPlugEffect/config/IPlugEffect-win.props
@@ -3,7 +3,7 @@
   <PropertyGroup Label="UserMacros">
     <IPLUG2_ROOT>$(ProjectDir)..\..\..</IPLUG2_ROOT>
     <BINARY_NAME>IPlugEffect</BINARY_NAME>
-    <EXTRA_ALL_DEFS>IGRAPHICS_NANOVG;IGRAPHICS_GL2</EXTRA_ALL_DEFS>
+    <EXTRA_ALL_DEFS>IGRAPHICS_SKIA;IGRAPHICS_CPU</EXTRA_ALL_DEFS>
     <EXTRA_DEBUG_DEFS />
     <EXTRA_RELEASE_DEFS />
     <EXTRA_TRACER_DEFS />

Using GL3 on windows

If you want to use GL3 on windows you need to change the include path in your project's .props file for the GLAD loader to point to the GLAD_GL3_PATHS, e.g. change this line: https://github.com/iPlug2/iPlug2/blob/master/Examples/IPlugEffect/config/IPlugEffect-win.props#L22