# how to speed up vtkRenderWindow-\>Render()

**URL:** https://discourse.vtk.org/t/how-to-speed-up-vtkrenderwindow-render/14434
**Category:** Support
**Created:** [August 20, 2024, 12:15pm UTC](https://discourse.vtk.org/t/how-to-speed-up-vtkrenderwindow-render/14434 "2024-08-20T12:15:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Vicore.Nv](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/v/94ad74/32.png) [@Vicore.Nv](https://discourse.vtk.org/u/Vicore.Nv)
#### Post date: [August 20, 2024, 12:15pm UTC](https://discourse.vtk.org/t/how-to-speed-up-vtkrenderwindow-render/14434/1 "2024-08-20T12:15:51Z")

</div>

I have an Qt(5.15.2) application which display pointcloud using vtk9.1 and pcl1.12, and I need to update pointCloud at about 30fps, each PointCloud has about 100K points ,But I found that calling vtkRenderWindow-\>Render() will cause Ui slow down,  
and I test the cost, every call of Render() will cost about 10~15ms, that means about 0.3~0.45s per second, I dont know why.  
my code snap is just as below

//  
void ShowPCLWgt::SetPointCloudData(pcl::PointCloudpcl::PointXYZRGB::Ptr pcl)  
{  
//LOG\_INFO() \<\< “SetPointCloudData start.”;  
m\_pViewer-\>setPointCloudData(pcl);  
//m\_bufferedPclCount++;  
m\_pQVTKWgt-\>renderWindow()-\>Render();// this will cost about 10~15ms  
//LOG\_INFO() \<\< “SetPointCloudData end.”;  
}

void ViCloudView::setBackground(vtkRenderer\* render)  
{

vtkNew colors;  
render-\>GradientBackgroundOn();  
render-\>SetBackground(colors-\>GetColor3d(“Gray”).GetData());  
render-\>SetBackground2(colors-\>GetColor3d(“LightSlateGray”).GetData());  
}

void ShowPCLWgt::InitWgt()  
{

```
QHBoxLayout* pLayout = new QHBoxLayout(this);
pLayout->setMargin(0);
pLayout->addWidget(m_toolbar);
m_pQVTKWgt = new QVTKOpenGLNativeWidget(this);
pLayout->addWidget(m_pQVTKWgt, 1);

//m_pViewer = new ViCloudView("viewer", false);

vtkNew<vtkRenderer> renderer;
//renderer->SetBackground(colors->GetColor3d("SteelBlue").GetData());
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName("RenderWindowNoUIFile");
renderWindow->GlobalWarningDisplayOff();
//renderWindow->GlobalWarningDisplayOn();
m_pViewer = new ViCloudView(renderer, renderWindow, "viewer", false);//PCLVisualizer wrapper
//m_pViewer->getRenderWindow()->GlobalWarningDisplayOff();
m_pQVTKWgt->setRenderWindow(renderWindow);
m_pViewer->setupInteractor(m_pQVTKWgt->interactor(), m_pQVTKWgt->renderWindow());
vtkRenderer* render = m_pViewer->getRenderWindow()->GetRenderers()->GetFirstRenderer();
vtkRenderWindowInteractor* interactor = m_pViewer->getRenderWindow()->GetInteractor();
m_pViewer->setBackground(render);
m_pViewer->addOrientationMarkerWidgetAxes(interactor, 0.0, 0.0, 0.2, 0.2);
m_pViewer->addOrientationPlanes(render, 1.5);

render->GetActiveCamera()->SetFocalPoint(0, 0, 0);
m_pViewer->initCameraParameters();
//m_pViewer->setCameraPosition(0, 0, -1, 0, 0, 1, 0, 1, 0);
m_pViewer->setCameraPosition(0, 0, -1, 0, 0, 0, 0, -1, 0);
//render->GetActiveCamera()->SetFocalPoint(0, 0, 0);
//m_pViewer->setCameraPosition(0, 0, -0.2, 0, 0, 1, 0, 1, 0);
m_pViewer->resetCamera();

/*connect(&m_renderTimer, &QTimer::timeout, this, [this]()
    {
        if(m_bufferedPclCount > 0)
		{
			m_bufferedPclCount = 0;
			m_pQVTKWgt->renderWindow()->Render();
		}
    });
m_renderTimer.start(100);*/

```

}

Can any one help?

---

<div class="post-metadata">

### Author: ![lgivord](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lgivord/32/3543_2.png) [@lgivord](https://discourse.vtk.org/u/lgivord)
#### Post date: [August 21, 2024, 8:05am UTC](https://discourse.vtk.org/t/how-to-speed-up-vtkrenderwindow-render/14434/2 "2024-08-21T08:05:17Z")

</div>

Hello @Vicore.Nv,

It’s indeed strange AFAIK you should be able to have a better performance with 100k points.

Could you please share how you configure your mapper?

Also note that if you don’t use a dynamic pipeline logic, you can set the Static member of your mapper to true which will have a great impact for your performance issue.

Best

---

<div class="post-metadata">

### Author: ![Vicore.Nv](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/v/94ad74/32.png) [@Vicore.Nv](https://discourse.vtk.org/u/Vicore.Nv)
#### Post date: [August 22, 2024, 3:21am UTC](https://discourse.vtk.org/t/how-to-speed-up-vtkrenderwindow-render/14434/3 "2024-08-22T03:21:01Z")

</div>

I use pcl::visualization::PCLVisualizer , not directly use vtkxxxmap as rendering pipeline

m\_pViewer is just a wrapper of pclVisualizer
