the easiest way to write a plugin with a texture output was by extending the DXTextureOutPluginBase class and overriding the CreateTexture and UpdateTexture methods. this approach lead to several issues though:
well it's nearly as simple as that now. you can create a texture output by writing
[Output("Texture")] ISpread<TextureResource> FMyTextureOut;
the TextureResource class takes care of the resource management, for example if a renderer is moved to another screen, the directx9 device changes and therefor the texture on the old device needs to be disposed and recreated on the new one.
the constructor of the TextureResource class takes up to four arguments:
so in order to create a texture we need to do this:
FMyTextureOut[i] = TextureResource.Create(i, CreateTexture); ... Texture CreateTexture(int slice, Device device) { return new Texture(device, ...); }
if we want to update the texture when some input changes:
FMyTextureOut[i] = TextureResource.Create(i, CreateTexture, UpdateTexture); ... void UpdateTexture(int slice, Texture texture) { // Do something with the texture }
and if something special needs to be done when destroying the texture:
FMyTextureOut[i] = TextureResource.Create(i, CreateTexture, UpdateTexture, DestroyTexture); ... void DestroyTexture(int slice, Texture texture) { // Destroy the texture }
in many cases the UpdateTexture call can be quite expensive, in order to disable it set the NeedsUpdate property on the TextureResource to false and set it back to true under a certain condition.
for a full example have a look at the rewritten dynamic plugin template.
oh and all this stuff works for meshes too, simply replace TextureResource with MeshResource.
anonymous user login
~5d ago
~7d ago
~9d ago
~13d ago
~13d ago
~20d ago
~26d ago
~26d ago
~27d ago
~1mth ago
;) looks great