macOS¶
An example CMakeLists.txt is included with the NDK examples shipped in the NDK sub-directory of the Documentation installed with NUKE. CMake is a preferred way of building plugins, the use of other build systems may not produce compatible plugins.
For macOS, plugins will need to be built with Apple Clang in order to be compatible. The use of GCC or stock LLVM is unlikely to produce compatible plugins. The use of Intel compilers for plug-in development is untested and unsupported.
The minimum deployment version is set to 11.0 which means that NUKE binaries are not compatible with macOS versions earlier than Big Sur.
On Apple macOS, NUKE is built on macOS 12 (Monterey), using the default Apple Clang compiler from the Xcode 14.2. Later Xcode versions may work too. Make sure that C++17 (use the -std=c++17
flag) is used in the build process.
The resulting shared object file (.dylib) should then be moved to your ~/.nuke directory (or otherwise into the NUKE plugin_path).
See Building & Installing Plug-ins for information on creating your first plug-in.
OpenGL and FoundryGL¶
Background¶
OpenGL is a cross-platform graphics API, which NUKE makes extensive use of for its viewers and GUI.
Apple has deprecated OpenGL in macOS and while it is still available that may not always be the case.
FoundryGL is an alternative library for macOS, developed by Foundry, that mostly matches the OpenGL API. Normally macOS’s OpenGL.framework
system library would be used. FoundryGL avoids using the system OpenGL implementation and instead uses MESA, Zink, and MoltenVK to produce a drop-in replacement OpenGL API.
From NUKE 16.0, NUKE on macOS will use FoundryGL rather than depending on the system OpenGL.
FoundryGL versions of NUKE contain the framework here:
Nuke<version>/Nuke<version.app>/Contents/Frameworks/FoundryGL.framework
More information on FoundryGL can be found in
FoundryGL.framework/Resources/English.lproj/README.md
When running a FoundryGL build of NUKE, something like the following will be printed to the terminal on application start-up (assuming NUKE has been started from the terminal):
zink: MoltenVK 1.2.8 Vulkan 1.2.280
Note
Linux and Windows versions will continue to use the system OpenGL.
FoundryGL and NUKE C++ plugins¶
Many existing plugins have no dependence on OpenGL and thus are unaffected by NUKE’s transition to FoundryGL.
Plugins that depend on OpenGL can do so in essentially three categories:
Indirectly, via NUKE’s NDK wrappers around OpenGL, such as
DD::Image::GPUContext
.Directly, via calls to the OpenGL API, such as
glBegin
andglVertex3f
, but relying on the OpenGL runtime linkage provided by NUKE’s patched GLEW libraries.Explicit linkage to OpenGL and/or platform-specific API calls, which on macOS would be CGL functions from Core OpenGL and/or NSOpenGL functions from AppKit.
Plugins in categories a and b should need no modification. Plugins in category c will need some modification, as discussed below.
Plugins in category c are incompatible with NUKE versions of the opposite type:
Using a plugin explicitly linked against OpenGL in a FoundryGL version of NUKE will likely cause a crash (though simply loading it will not, and there will be no runtime linker error so long as the macOS OpenGL framework is present on the system).
Loading a plugin explicitly linked against FoundryGL in a non-FoundryGL version of NUKE will result in a runtime linker error, due to not being able to find the FoundryGL.framework. The error message will begin with something like
RuntimeError: dlopen(<plugin path>, 0x0006): Library not loaded:
'@rpath/FoundryGL.framework/Versions/Current/Libraries/libGL.1.dylib'
Building plugins¶
There is FoundryGL specific documentation, including generic information relevant to building against FoundryGL, in FoundryGL.framework/Resources/English.lproj/README.md
.
As mentioned elsewhere in this documentation, the recommended way to build NUKE plugins is with CMake.
The NUKE install includes a Documentation/NDKExamples/examples
folder containing the source code for example plugins and a CMakeLists.txt. As before, this includes find_package(Nuke REQUIRED)
, which now automatically results in either the OpenGL or FoundryGL framework being found, according to whether the latter is present in the NUKE installation, see below.
Previously existing example plugins that use OpenGL fall into categories a and b, such as Draw2D.cpp
, and are unmodified for FoundryGL and the process of building them is as before.
A new example, OpenGL.cpp, has been added to illustrate category c. This example is essentially a copy of Draw2D.cpp but modified to link explicitly to either OpenGL or FoundryGL.
The CMakeLists.txt explicitly links this against either FoundryGL, if find_package(Nuke REQUIRED) detected that in the NUKE installation, or the system OpenGL otherwise. Either a
Found FoundryGL
orFound OpenGL
message will be output, in both cases showing the relevant path to the found framework.When linking against FoundryGL,
FOUNDRYGL_USE
is defined.Note: This is not defined for the compilation of all plugins, only those that explicitly link against FoundryGL. Do not use this define as a general way to detect whether the NUKE installation is a FoundryGL version.
The OpenGL.cpp source disables the use of GLEW, which is an existing part of the NUKE installation, and if
FOUNDRYGL_USE
is defined includesFoundryGL/FoundryGL.h
, otherwise includes the systemOpenGL/gl.h
.
The macOS otool
command can be used to determine whether a binary is explicitly linked against FoundryGL, OpenGL or neither:
otool -L <path to binary>
If the binary is linked against FoundryGL the otool output will include something like
@rpath/FoundryGL.framework/Versions/Current/Libraries/libGL.1.dylib
while a binary linked against the system OpenGL will include something like
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL