[vtkusers] Problem with vtkPanel
Jeff Lee
jeff at cdnorthamerica.com
Wed Apr 27 11:37:58 EDT 2005
Hi Antoine,
When you change the texture on one thread and render on the event
thread, you have the potential for a render to occur while you are
changing the texture. For example, say you start your UpdateImage
thread, and it runs and schedules the Render on the event thread. The
render hasn't yet occured, and then you start the UpdateImage thread
again. Now you have the potential for a render to occur while you are
changing the pipeline on another thread - bad things can happen. I
would guess that if you did something like
SwingUtilities.invokeLater(new Runnable() {
public void run() {
for (int isurf = 0; isurf<vue.getSurfaces().size(); isurf++)
{
((Surface)view.getSurfaces().get(isurf)).updateTabImage();
}
view.Render();
}
});
then things would behave better, but your performance might degrade. A
more advanced solution would be to mutex the Render method with the
method which updates the textures. i.e. you cannot render while the
textures are being updated. You only have to mutex the part of
updateTabImages which touch the vtk pipeline. HTH,
-Jeff
Antoine Boivin wrote:
> Hi vtk users!
>
> I use vtk with Java and I use a vtkPanel.
> In the renderer of this vtkPanel I insert a surface with a texture.
> In an other thread, I update this texture every time.
> This program run correctly with a good frame rate
> but some minutes ago, the surface disappear of the view.
> I notice an increase of the memory use by the program
> when the function "Render" of the vtkPanel are call.
> That is the problem?
>
> I don't understand what occurs and why the texture disappear?
>
> This is the source of my Thread :
>
> public class UpdateImage extends Thread
> {
>
> private view3D view; //view3D extends vtkPanel
> public boolean running=true;
> public boolean visu=true;
>
> public UpdateImage(View3D _view)
> {
> view = _view;
> }
>
> public void run()
> {
> try
> {
> while(running)
> {
> for (int isurf = 0; isurf<vue.getSurfaces().size(); isurf++)
> {
> ((Surface)view.getSurfaces().get(isurf)).updateTabImage();
> }
> SwingUtilities.invokeAndWait(new Runnable()
> {
> public void run()
> {
> view.Render();
> }
> });
> }
> }
> catch (Exception e){
> System.out.println("Exception="+e);
> }
> }
> }
>
>
> Thanks for your help!
>
> Antoine
>
>------------------------------------------------------------------------
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
More information about the vtkusers
mailing list