I found an interesting issue about vtkSDL2OpenGLRenderWindow::SetSize when changed canvas for VTK WASM 3D window.
The related post on the website is Change Canvas For VTK WASM Project.

void Worker::ChangeRenderWindow()
{
    m_Renderer = vtkSPtr<vtkRenderer>::New(); // need it!
    m_Renderer->AddActor(m_Actor);
    m_Renderer->SetBackground( 0, 0, 0 );

    vtkSPtr<vtkSDL2OpenGLRenderWindow> newWin = vtkSPtr<vtkSDL2OpenGLRenderWindow>::New(); // need
    newWin->AddRenderer( m_Renderer );
    newWin->SetSize(1000, 600); //works
    //newWin->SetSize(10, 10); //works
    m_RenderWindowInteractor->SetRenderWindow( newWin );

    vtkSDL2OpenGLRenderWindow* oldSDLWin = vtkSDL2OpenGLRenderWindow::SafeDownCast( m_RenderWindow );
    oldSDLWin->ReleaseGraphicsResources( oldSDLWin ); 

    m_RenderWindow = newWin;
    
    m_Renderer->ResetCamera();
    m_RenderWindow->Render();
    m_RenderWindowInteractor->Start();
}

The interface SetSize can work if it was used before m_RenderWindowInteractor->SetRenderWindow( newWin );.
It means the 3D window will become smaller or bigger than the outer shell.

The red object represents the outer shell, and the black object is the render window.

If we remove the statement newWin->SetSize(1000, 600); or put it after m_RenderWindowInteractor->SetRenderWindow, the 3D window will adjust its size to match the outer shell (canvas).

I was trying to find the reason, but I am too tired today. I will update the relevant content when I have time.

Categories: VTKWeb

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x