is the right way to change uniform data in vtkshader,
But how can I access it by myself?
Because I can not find the object “cbo” belongs to which part of an actor.
I checked the source code in github for a really long time, but I could not get the result, please help me.
Thank you, and sorry, it names vtkOpenGLPolyDataMapper actually.
it has the function in 9.0 version, and the function is removed in the lastest version, but the question is the same; despite the way of setting shaders is different, I can not find a easy way to get vtkProgram objects.
Well, I’d add bookkeeping code to the program. Whenever you create a vtkActor/vtkMapper alongside a vtkShader in your scene-building code, you could add the two objects to some indexed STL container (using the vtkShader pointers as key). So, when you get a vtkShader via GetVertexShader(), GetFragmentShader() or GetGeometryShader() via vtkShaderProgram in your callback, simply query the index to find the corresponding vtkActor/vtkMapper. I know it’s dirty, but I couldn’t think of a better way to do what you want.
Alternatively, you could subclass the vtkShader you are using and add setter/getter to add a pointer to whatever object you need to recover in the callback. This is a bit cleaner than bookkeeping.
You may also want to look at vtkShaderProperty which is on Actor. It supports all sorts of shader manipulation and is already tied to the actor and honored by the mapper. Note that OpenGLPolyDataMapper uses multiple shader programs when rendering (one for lines, another for surfaces, another for edges, and they can be changed by picking/opacity/etc so they tend to be changing based on user input (if the user has that level of control).