How to use vtk to check if a discrete GPU existed?

Hello,ChatGPT gives me this:

#include <iostream>
#include <vtkRenderWindow.h>

bool isDiscreteGPUExist()
{
    vtkSmartPointer<vtkRenderWindow> window = vtkSmartPointer<vtkRenderWindow>::New();
    window->OffScreenRenderingOn();
    window->SetMultiSamples(0);
    window->SetNumberOfLayers(1);
    window->SetSize(1, 1);
    window->OffScreenRenderingOff();
    window->MakeCurrent();
    bool success = window->IsCurrent();
    window->Finalize();
    return success;
}

int main()
{
    if (isDiscreteGPUExist())  {
        std::cout << "Discrete GPU exists!\n";
    }  else  {
        std::cout << "No discrete GPU found!\n";
    }
    return 0;
}

It seems not right,I do have a discrete GPU,but got:

“No discrete GPU found!”

Is there any way to do this checking?

Please write your own code.

How to use vtk to check if a discrete GPU

I dont think VTK can do that. You can recover OpenGL information.

My usual crutch is Stack Overflow, you may have to use something like this.

The operating system and GPU APIs make a lot of effort to hide exactly this kind of low-level information from applications. It just should not matter.

What you may need to know if a certain version of some API (CUDA, OpenGL,…) is supported.

hi there, but how can I know that if VTK is using a GPU for rendering or sth? My mates told me that the GPU drive is limited by VTK version. But it seems make no sense? I have no idea. Thanks a lot.

It seems that some OpenGL version is needed for vtk. Because the higher version of vtk8.2 seems dumped the old version OpenGL1 in the earlier 8.1 version. After change the vtk version from 8.0 to 8.2, things go wrong.

Probably the minimum required OpenGL version was increased in VTK 8.2. Supporting an older OpenGL version means that you cannot take advantage of modern graphics hardware and software improvements, which makes VTK slower on modern hardware and makes VTK maintenance and development harder. Since OpenGL 1 was superseded by OpenGL 2 in 2004 it was really time fro VTK to drop OpenGL support in VTK 8.2 in 2019.

Note that OpenGL 1 is so old that if your computer seems to offer only this OpenGL version then it almost surely means that there is a configuration error. For example, you are using Windows Remote Desktop Protocol and due to a misconfigured server or incompatible client you get a legacy OpenGL 1.1 context. You should be able to fix this issue or (if you don’t have graphics hardware) then you can use a software renderer (that performs all OpenGL operations on the CPU).

Thanks for replying! So you mean that OpenGL is not necessary for VTK8.2, but the limited version of OpenGL is still working. In vtk8.1UpdateNote and vtk8.2UpdateNote from @DavidDeMarle just mention OpenGL1 dropped. So I wondered if the driver of my GPU is not work for VTK, is it because the GPU is too old. :smiling_face_with_tear: