I am getting segmentation fault with EGL offscreen rendering window

Here is my code and the error message.

Thank you for the assistance.

Rafael S.

   std::cerr << "Colours" << std::endl;	              
   vtkNew<vtkNamedColors> colors;
    

   // Create a sphere
   vtkNew<vtkSphereSource> sphereSource;
    sphereSource->SetThetaResolution(75);
    sphereSource->SetPhiResolution(75);

  
  std::cerr << "Sphere Created Ok" << std::endl;	  
  // Create a mapper and actor
  vtkNew<vtkPolyDataMapper> mapper;
  mapper->SetInputConnection(sphereSource->GetOutputPort());

  // Apply the texture
  vtkNew<vtkTexture> texture;
  texture->SetInputConnection(sphereSource->GetOutputPort());


  vtkNew<vtkActor> actor;
  actor->SetMapper(mapper);
  actor->GetProperty()->SetColor(colors->GetColor3d("White").GetData());
  actor->SetTexture(texture);


  // A renderer and render window
  vtkNew<vtkRenderer> renderer;
  renderer->AddActor(actor);
  renderer->SetBackground(colors->GetColor3d("SlateGray").GetData());
  
  vtkNew<vtkEGLRenderWindow> renderWindow;
  std::cerr << "Number of Devices:  "<< renderWindow->GetNumberOfDevices() << std::endl;	  
  renderWindow->MakeCurrent();
  renderWindow->OffScreenRenderingOn();
  renderWindow->SetShowWindow(false);
  renderWindow->WindowInitialize();
  renderWindow->AddRenderer(renderer);

  std::cerr << "Render Created Ok" << std::endl;

  
  // Add the actors to the scene
  
  // Perform offscreen rendering

  std::cerr << "Actor Added Ok" << std::endl;


  std::cerr << "Render Ok" << std::endl;

  vtkNew<vtkWindowToImageFilter> windowToImageFilter;
  windowToImageFilter->SetInput(renderWindow);
  windowToImageFilter->Update();
  
  std::cerr << "Render-Window to image Ok" << std::endl;
  

  vtkNew<vtkPNGWriter> writer;
  writer->SetFileName("/home/3484681/Área de Trabalho/PRISMAMESH/createmesh/screenshot.png");
  writer->SetInputConnection(windowToImageFilter->GetOutputPort());
  writer->Write();
  
  std::cerr << "Write Ok" << std::endl;
  
Sphere Created Ok
Number of Devices:  3
2023-12-26 19:48:40.841 (   0.586s) [    7FBCADE4D5C0] vtkEGLRenderWindow.cxx:340   WARN| vtkEGLRenderWindow 	(0x56173903cd40): EGL device index: 3 could not be initialized. Trying other devices...
Render Created Ok
Actor Added Ok
Render Ok
Falha de segmentação

Please do not repost questions; it is the holidays and not everyone is around to answer questions. Reposts just create even more load for those to go through when they get back.

Repost of: Atempt to render offscreen using vtkEGLRenderWindow