VTK failed after update Lights 16 OpenGL errors detected 错误

纵然是瞬间 提交于 2019-11-28 08:24:25

在读取.VTK文件的时候出现如标题错误,代码如下

 1 #include<vtkSmartPointer.h>
 2 #include<vtkRenderWindow.h>
 3 #include<vtkRenderer.h>
 4 #include<vtkRenderWindowInteractor.h>
 5 #include<vtkInteractorStyleTrackballCamera.h>
 6 #include<vtkCylinderSource.h>
 7 #include<vtkPolyDataMapper.h>
 8 #include<vtkActor.h>
 9 #include<vtkLight.h>
10 #include<vtkCamera.h>
11 #include<vtkJPEGReader.h>
12 #include<vtkTexture.h>
13 #include<vtkPlaneSource.h>
14 #include<vtkStructuredPointsReader.h>
15 #include<vtkMarchingCubes.h>
16 #include "vtkOpenGLRenderWindow.h"
17 
18 void showMarchingCubes()
19 {
20     vtkSmartPointer<vtkStructuredPointsReader> reader = vtkSmartPointer<vtkStructuredPointsReader>::New();
21     reader->SetFileName("D:\\zeng\\vtkData\\CT-Head.vtk");
22 
23     vtkSmartPointer<vtkMarchingCubes> marchingCubes = vtkSmartPointer<vtkMarchingCubes>::New();
24     marchingCubes->SetInputConnection(reader->GetOutputPort());
25     marchingCubes->SetValue(0,200);
26 
27     vtkSmartPointer<vtkPolyDataMapper> manpper = vtkSmartPointer<vtkPolyDataMapper>::New();
28     manpper->SetInputConnection(marchingCubes->GetOutputPort());
29 
30     vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
31     actor->SetMapper(manpper);
32 
33     vtkSmartPointer<vtkRenderer> marchingCubesRender = vtkSmartPointer<vtkRenderer>::New();
34     vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
35     vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
36     renWin->AddRenderer(marchingCubesRender);
37     iren->SetRenderWindow(renWin);
38     marchingCubesRender->AddActor(actor);
39     marchingCubesRender->Render();
40 
41     iren->Initialize();
42     iren->Start();
43 }

出现如下错误

 

通过查资料,可通过如下方式编译通过

I finally got the answer by myself, I needed to delete the ren->Render() line.

注释掉: marchingCubesRender->Render();

https://stackoverflow.com/questions/34221190/vtkopenglrenderer-errors-after-migration-from-vtk-5-3-to-vtk-6-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!