I think this will serve you as starting point
https://gitlab.kitware.com/vtk/vtk/-/blob/master/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx
I think this will serve you as starting point
https://gitlab.kitware.com/vtk/vtk/-/blob/master/Rendering/ContextOpenGL2/vtkOpenGLContextBufferId.cxx