I’m trying to write an extension to take screenshots. dmGraphics
has all the functionality needed, but it’s not exposed to extensions as far as I can tell.
dmGraphics::g_adapter->m_GetContextCb()
should be able to get the context, and that context can be passed to the various functions in dmGraphics::g_functions
.
Of course the functions should be called via the dmGraphics::SomeFunc
wrappers that call them form the function table of the current selected adapter, but:
a) There isn’t a function for GetContext
b) Not all of these are exposed in graphics.h
I have tried without success to cheese-it by copying relevant structures and function declarations into duplicate headers in the extension, but even with the correct headers in place the linking fails. I have tried to simplify this approach (in order to figure out what’s going on) by calling the Vulkan*
functions directly but even then they cannot be linked. Here are the errors I get:
ld: warning: ignoring duplicate libraries: '-lMoltenVK', '-lgraphics_vulkan', '-lplatform_vulkan'
Undefined symbols for architecture arm64:
"dmGraphics::VulkanGetWidth(void*)", referenced from:
ScreenshotExtension::CallbackPostRender(ExtensionParams*) in libScreenshot_2.a[2](extension.cpp_0.o)
"dmGraphics::VulkanGetHeight(void*)", referenced from:
ScreenshotExtension::CallbackPostRender(ExtensionParams*) in libScreenshot_2.a[2](extension.cpp_0.o)
"dmGraphics::VulkanReadPixels(void*, void*, unsigned int)", referenced from:
ScreenshotExtension::CallbackPostRender(ExtensionParams*) in libScreenshot_2.a[2](extension.cpp_0.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
com.defold.extender.ExtenderException: java.io.IOException: clang++ -c -isystem /Users/bjorn/extender-production/platformsdk/MacOSX14.5.sdk/usr/include/c++/v1 -DDLIB_LOG_DOMAIN="SCREENSHOT" -DDDF_EXPOSE_DESCRIPTORS -DDM_PLATFORM_MACOS -DDM_PLATFORM_OSX -DGL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED -O2 -g -stdlib=libc++ -mmacosx-version-min=10.13 -isysroot /Users/bjorn/extender-production/platformsdk/MacOSX14.5.sdk -nostdinc++ -fno-exceptions -fvisibility=hidden -Werror=format -arch arm64 -target arm64-apple-darwin19 -m64 -Iupload/_extension-screenshot/include/ -Ibuild/_extension-screenshot/ -Iupload/ -Iupload/defos/include/ -I/Users/bjorn/extender-production/sdk/d01194cf0fb576b516a1dca6af6f643e9e590051/defoldsdk//include -I/Users/bjorn/extender-production/sdk/d01194cf0fb576b516a1dca6af6f643e9e590051/defoldsdk//sdk/include -I/Users/bjorn/extender-production/sdk/d01194cf0fb576b516a1dca6af6f643e9e590051/defoldsdk//ext/include upload/_extension-screenshot/src/extension.cpp -obuild/extension.cpp_0.o
clang++ -c -isystem /Users/bjorn/extender-production/platformsdk/MacOSX14.5.sdk/usr/include/c++/v1 -DDLIB_LOG_DOMAIN="SCREENSHOT" -DDDF_EXPOSE_DESCRIPTORS -DDM_PLATFORM_MACOS -DDM_PLATFORM_OSX -DGL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED -O2 -g -stdlib=libc++ -mmacosx-version-min=10.13 -isysroot /Users/bjorn/extender-production/platformsdk/MacOSX14.5.sdk -nostdinc++ -fno-exceptions -fvisibility=hidden -Werror=format -arch arm64 -target arm64-apple-darwin19 -m64 -Iupload/_extension-screenshot/include/ -Ibuild/_extension-screenshot/ -Iupload/ -Iupload/defos/include/ -I/Users/bjorn/extender-production/sdk/d01194cf0fb576b516a1dca6af6f643e9e590051/defoldsdk//include -I/Users/bjorn/extender-production/sdk/d01194cf0fb576b516a1dca6af6f643e9e590051/defoldsdk//sdk/include -I/Users/bjorn/extender-production/sdk/d01194cf0fb576b516a1dca6af6f643e9e590051/defoldsdk//ext/include upload/_extension-screenshot/src/fpng.cpp -obuild/fpng.cpp_1.o