Problem offscreen rendering

Hello,

I can’t run my offscreen rendering code. It is just the offscreen rendering example…

Thank you.

        #ifdef ENABLE_OFFSCREEN_RENDERING
        // Setup offscreen rendering
    vtkNew<vtkNamedColors> colors;

    vtkNew<vtkGraphicsFactory> graphics_factory;
    graphics_factory->SetOffScreenOnlyMode(1);
    graphics_factory->SetUseMesaClasses(1);
    
      // Create a sphere
  vtkNew<vtkSphereSource> sphereSource;

  // Create a mapper and actor
  vtkNew<vtkPolyDataMapper> mapper;
  mapper->SetInputConnection(sphereSource->GetOutputPort());

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

  // A renderer and render window
  vtkNew<vtkRenderer> renderer;
  vtkNew<vtkRenderWindow> renderWindow;
  renderWindow->SetOffScreenRendering(1);
  renderWindow->AddRenderer(renderer);

  // Add the actors to the scene
  renderer->AddActor(actor);
  renderer->SetBackground(colors->GetColor3d("SlateGray").GetData());

  renderWindow->Render();

  vtkNew<vtkWindowToImageFilter> windowToImageFilter;
  windowToImageFilter->SetInput(renderWindow);
  windowToImageFilter->Update();

  vtkNew<vtkPNGWriter> writer;
  writer->SetFileName("screenshot.png");
  writer->SetInputConnection(windowToImageFilter->GetOutputPort());
  writer->Write();
      #endif

2023-12-19 16:42:29.364 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:57 WARN| Error in cache state for GL_DEPTH_WRITEMASK
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:65 WARN| Error in cache state for GL_COLOR_WRITEMASK
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:72 WARN| Error in cache state for GL_BLEND
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:79 WARN| Error in cache state for GL_DEPTH_TEST
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:102 WARN| Error in cache state for GL_SCISSOR_TEST
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:133 WARN| Error in cache state for GL_VIEWPORT
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:141 WARN| Error in cache state for GL_SCISSOR_BOX
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:148 WARN| Error in cache state for GL_CULL_FACE_MODE
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:155 WARN| Error in cache state for GL_ACTIVE_TEXTURE
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:162 WARN| Error in cache state for GL_DEPTH_FUNC
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:169 WARN| Error in cache state for GL_BLEND_SRC_RGB
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:222 WARN| Error in cache state for GL_DRAW_BUFFER got 0 expected1026
2023-12-19 16:42:29.365 ( 0.606s) [ 7F74BDACF600] vtkOpenGLState.cxx:241 WARN| Error in cache state for GL_READ_BUFFER
2023-12-19 16:42:29.367 ( 0.608s) [ 7F74BDACF600] vtkOpenGLState.cxx:263 WARN| at stack loc
0x7f74bf0d3ba1 : ??? [(???) ???:-1]
0x7f74bf0ce1db : vtksys::SystemInformation::GetProgramStack[abi:cxx11](int, int) [(libvtksys-9.3.so.1) ???:-1]
0x7f74bfad6a01 : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfade727 : vtkOpenGLState::vtkglPixelStorei(unsigned int, int) [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfa9c5ee : vtkOpenGLRenderWindow::OpenGLInitState() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfa9c537 : vtkOpenGLRenderWindow::OpenGLInit() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfbb1b45 : vtkOSOpenGLRenderWindow::CreateOffScreenWindow(int, int) [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfbb1d85 : vtkOSOpenGLRenderWindow::Initialize() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfaa1b43 : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74beaa2f28 : vtkRenderWindow::Render() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74bfaa5eb1 : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74beaae9b8 : vtkRenderWindowInteractor::Render() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74beab1a6f : vtkRenderWindowInteractor::Initialize() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74beaaeb35 : vtkRenderWindowInteractor::Start() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x5638fb4c5be3 : ??? [(???) ???:-1]
0x7f74b7a29d90 : ??? [(???) ???:-1]
0x7f74b7a29e40 : __libc_start_main [(libc.so.6) ???:-1]
0x5638fb4cadb5 : ??? [(???) ???:-1]

2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:57    WARN| Error in cache state for GL_DEPTH_WRITEMASK
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:65    WARN| Error in cache state for GL_COLOR_WRITEMASK
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:72    WARN| Error in cache state for GL_BLEND
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:79    WARN| Error in cache state for GL_DEPTH_TEST
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:86    WARN| Error in cache state for GL_CULL_FACE
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:94    WARN| Error in cache state for GL_MULTISAMPLE
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:102   WARN| Error in cache state for GL_SCISSOR_TEST
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:109   WARN| Error in cache state for GL_STENCIL_TEST
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:117   WARN| Error in cache state for GL_TEXTURE_CUBE_MAP_SEAMLESS
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:133   WARN| Error in cache state for GL_VIEWPORT
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:141   WARN| Error in cache state for GL_SCISSOR_BOX
2023-12-19 16:42:29.367 (   0.608s) [    7F74BDACF600]     vtkOpenGLState.cxx:148   WARN| Error in cache state for GL_CULL_FACE_MODE
2023-12-19 16:42:29.367 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:155   WARN| Error in cache state for GL_ACTIVE_TEXTURE
2023-12-19 16:42:29.367 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:162   WARN| Error in cache state for GL_DEPTH_FUNC
2023-12-19 16:42:29.367 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:169   WARN| Error in cache state for GL_BLEND_SRC_RGB
2023-12-19 16:42:29.367 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:176   WARN| Error in cache state for GL_BLEND_SRC_ALPHA
2023-12-19 16:42:29.367 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:183   WARN| Error in cache state for GL_BLEND_DST_RGB
2023-12-19 16:42:29.367 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:190   WARN| Error in cache state for GL_BLEND_DST_ALPHA
2023-12-19 16:42:29.367 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:197   WARN| Error in cache state for GL_DRAW_FRAMEBUFFER_BINDING
2023-12-19 16:42:29.368 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:204   WARN| Error in cache state for GL_READ_FRAMEBUFFER_BINDING
2023-12-19 16:42:29.368 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:222   WARN| Error in cache state for GL_DRAW_BUFFER got -43064224 expected1026
2023-12-19 16:42:29.368 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:241   WARN| Error in cache state for GL_READ_BUFFER
2023-12-19 16:42:29.368 (   0.609s) [    7F74BDACF600]     vtkOpenGLState.cxx:255   WARN| Error in cache state for GL_COLOR_CLEAR_VALUE
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:263   WARN| at stack loc
0x7f74bf0d3ba1 : ??? [(???) ???:-1]
0x7f74bf0ce1db : vtksys::SystemInformation::GetProgramStack[abi:cxx11](int, int) [(libvtksys-9.3.so.1) ???:-1]
0x7f74bfad6a01 : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfade727 : vtkOpenGLState::vtkglPixelStorei(unsigned int, int) [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfa9c619 : vtkOpenGLRenderWindow::OpenGLInitState() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfa9c537 : vtkOpenGLRenderWindow::OpenGLInit() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfbb1b45 : vtkOSOpenGLRenderWindow::CreateOffScreenWindow(int, int) [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfbb1d85 : vtkOSOpenGLRenderWindow::Initialize() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfaa1b43 : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74beaa2f28 : vtkRenderWindow::Render() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74bfaa5eb1 : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74beaae9b8 : vtkRenderWindowInteractor::Render() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74beab1a6f : vtkRenderWindowInteractor::Initialize() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74beaaeb35 : vtkRenderWindowInteractor::Start() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x5638fb4c5be3 : ??? [(???) ???:-1]
0x7f74b7a29d90 : ??? [(???) ???:-1]
0x7f74b7a29e40 : __libc_start_main [(libc.so.6) ???:-1]
0x5638fb4cadb5 : ??? [(???) ???:-1]

2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:133   WARN| Error in cache state for GL_VIEWPORT
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:141   WARN| Error in cache state for GL_SCISSOR_BOX
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:148   WARN| Error in cache state for GL_CULL_FACE_MODE
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:155   WARN| Error in cache state for GL_ACTIVE_TEXTURE
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:162   WARN| Error in cache state for GL_DEPTH_FUNC
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:169   WARN| Error in cache state for GL_BLEND_SRC_RGB
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:176   WARN| Error in cache state for GL_BLEND_SRC_ALPHA
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:183   WARN| Error in cache state for GL_BLEND_DST_RGB
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:190   WARN| Error in cache state for GL_BLEND_DST_ALPHA
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:222   WARN| Error in cache state for GL_DRAW_BUFFER got 0 expected1026
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:241   WARN| Error in cache state for GL_READ_BUFFER
2023-12-19 16:42:29.369 (   0.610s) [    7F74BDACF600]     vtkOpenGLState.cxx:255   WARN| Error in cache state for GL_COLOR_CLEAR_VALUE
2023-12-19 16:42:29.370 (   0.611s) [    7F74BDACF600]     vtkOpenGLState.cxx:263   WARN| at stack loc
0x7f74bf0d3ba1 : ??? [(???) ???:-1]
0x7f74bf0ce1db : vtksys::SystemInformation::GetProgramStack[abi:cxx11](int, int) [(libvtksys-9.3.so.1) ???:-1]
0x7f74bfad6a01 : vtkOpenGLState::CheckState() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfadcb01 : vtkOpenGLState::SetEnumState(unsigned int, bool) [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfadd1f1 : vtkOpenGLState::vtkglEnable(unsigned int) [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74bfaa1bbc : vtkOpenGLRenderWindow::Start() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74beaa2f28 : vtkRenderWindow::Render() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74bfaa5eb1 : vtkOpenGLRenderWindow::Render() [(libvtkRenderingOpenGL2-9.3.so.1) ???:-1]
0x7f74beaae9b8 : vtkRenderWindowInteractor::Render() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74beab1a6f : vtkRenderWindowInteractor::Initialize() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x7f74beaaeb35 : vtkRenderWindowInteractor::Start() [(libvtkRenderingCore-9.3.so.1) ???:-1]
0x5638fb4c5be3 : ??? [(???) ???:-1]
0x7f74b7a29d90 : ??? [(???) ???:-1]
0x7f74b7a29e40 : __libc_start_main [(libc.so.6) ???:-1]
0x5638fb4cadb5 : ??? [(???) ???:-1]

2023-12-19 16:42:29.373 (   0.614s) [    7F74BDACF600]     vtkOpenGLState.cxx:1786  WARN| Hardware does not support the number of textures defined.
createmesh: /home/3484681/miniconda3/envs/vtkenv/vtk-master/source/Rendering/OpenGL2/vtkTextureObject.cxx:437: void vtkTextureObject::Bind(): Assertion `this->Handle' failed.