I am modify Unreal engine 4.21 to get some texture and other render resourse from ‘FDeferredShadingSceneRenderer’.
I try to save the texture by adding a MyPass.h in ‘source/runtime/renderer/public’:
class MyPassAssets {
static FTexture2DRHIRef Texture;
static bool bTextureInited;
};
And put texture into it in FDeferredShadingSceneRenderer::Render()
However, I found because my game project and engine is different .dll, so the address of these static value is different.
I try to use ‘__declspec(dllexport)’, but always face some link error.
How to correct get these resource, Or is there a easier way to get information from renderer?
While I found the answer. It is very simple actually.
first you should declear the function where you want to use:
typedef bool (*_foo)(); // Declare the DLL function
then before you used the function
FString filePath = FPaths::Combine(*FPaths::EngineDir(), TEXT(_dll_address)); // Concatenate the plugins folder and the DLL file.
if (FPaths::FileExists(filePath))
{
void *DLLHandle;
DLLHandle = FPlatformProcess::GetDllHandle(*filePath); // Retrieve the DLL.
if (DLLHandle != NULL)
{
_foo DLLfoo = NULL; // Local DLL function pointer.
FString procName = "foo"; // The exact name of the DLL function.
DLLfoo = (_foo)FPlatformProcess::GetDllExport(DLLHandle, *procName); // Export the DLL function.
if (DLLfoo != NULL)
{
return DLLfoo (); // Call the DLL function, with arguments corresponding to the signature and return type of the function.
}
}
}
you could modify some code, according to your usage.