In beta i was able to do something like this in a custom node:
void SetOutputBuffer(DX11Resource bufferOut, int index, int count, DX11RenderContext context) { SlimDX.Direct3D11.Buffer slimBuffer = SlimDX.Direct3D11.Buffer.FromPointer(MyNativeBuffer[0][context].GetNativePointer(index)); bufferOut[context] = new DX11DynamicStructuredBuffer(context, slimBuffer, count); }
and thereby set a buffer on the current context of a vvvv renderer. I believe the only thing I had to do to access context was inheriting from IDX11ResourceHost, but it’s been a long time ;) To initialize MyNativeBuffer in C++ on the vvvv device context I had to get
context.CurrentDeviceContext.ComPointer
How can i do the same thing, ideally renderer-agnostic (meaning not strictly dx11), ie accessing context, getting its pointer, creating a stride-based buffer from a native pointer, etc…in stride?
The goal is/was to manipulate buffers created on stride’s context using some native libraries in c++, then read them back to use them for rendering….
To get access to any of our services (like the Stride Game object) create a NodeContext nodeContext parameter on your constructor of your process node and access its AppHost.Services property.
For example
[ProcessNode]
public class MyStrideNode
{
private readonly Game game;
public MyStrideNode(NodeContext nodeContext)
{
var appHost = nodeContext.AppHost;
game = appHost.Services.GetRequiredService<Game>();
// Game is from Stride, has all the graphics services you might need
}
}
If you want to take part in the rendering, you’ll need to do a bit more and implement IGraphicsRenderer or better inherit from Stride’s RendererBase.
For a recent example you can have a look at our RiveRenderer node and in particular its constructor as well as the DrawCore method. And in general the VL.Stride.Runtime package might also be of interest even though it probably is not the best fit as it was developed at a time where we didn’t have the option to write process nodes in C# directly and therefor uses the node factory feature a lot.