Hi, I am using VTK on Avalonia, but I can’t get the render method work after the RenderWindowControl is created.
I created several triangles and added texture to them.
And I have a button to change the texture.
But the display won’t change with the render method.
Only mouse interaction with a interactor can refresh the display.
The Avalonia sample is too simple.
How should I force render the VTK control to refresh the display?
byte os = 0;
for (var i = 0; i < _textureData.Length; i++)
{
if (i == 0) os = (byte)new Random().Next(0, 255);
_textureData[i] = os;
}
_texture = vtkTexture.New();
_imageImport = vtkImageImport.New();
_imageImport.SetDataExtent(0, 255, 0, 255, 0, 0);
_imageImport.SetWholeExtent(0, 255, 0, 255, 0, 0);
_imageImport.SetDataScalarTypeToUnsignedChar();
_imageImport.SetNumberOfScalarComponents(1);
var pinnedArray = GCHandle.Alloc(_textureData, GCHandleType.Pinned);
var pointer = pinnedArray.AddrOfPinnedObject();
_imageImport.SetImportVoidPointer(pointer);
_imageImport.SetDataSpacing(1, 1, 1);
_imageImport.SetDataOrigin(0, 0, 0);
_imageImport.Update();
_texture.SetInputConnection(_imageImport.GetOutputPort());
_texture.Update();
pinnedArray.Free();
_vtkActor.SetTexture(_texture);