[vtkusers] vtkWindowToImageFilter - black image

Fredrik frejon at gmail.com
Wed Jun 10 07:55:06 EDT 2015


Hi all. I realise now that my problem is at heart a problem with Java 8 +
VTK 6 + JOGL, where vtkJoglCanvasComponent is no longer working as it did
with JAVA 6, VTK 4 / 5, JOGL 2.0.2.

With JAVA 8, I've been able to port (at least such that everything
compiles) vtkJoglCanvasComponent, vtkAbstractJoglComponent
& vtkJoglPanelComponent to JOGL 2.3.1.

That is an improvement in comparison to these abandoned threads:

http://public.kitware.com/pipermail/vtkusers/2014-April/083707.html
http://public.kitware.com/pipermail/vtkusers/2015-March/090337.html

Everything looks good and behaves well with vtkJoglCanvasComponent (and
terrible with vtkJoglPanelComponent) but I'm unable to
use vtkWindowToImageFilter and I get fatal crashes if I ask vtkRenderWindow
to render by itself, instead of asking the JoglCanvasComponent or the
vtkRenderer to render.

I believe that is sufficient information to reproduce the problem.



If anyone in the future is interested on how to get JOGL to work with VTK,
these are the steps I've made:

•update to JOGL 2.3.1.

•change import library names from
javax.media.opengl*
to
com.jogamp.opengl*

in all three .java files found under
/java/vtk/rendering/jogl/

•also change line 49 in vtkAbstractJoglComponent.java to accommodate the
method name change from getWidth() to getSurfaceWidth() and getHeight() to
getSurfaceHeight()

Sincerely, Fredrik


On Wed, Jun 10, 2015 at 7:27 AM, Fredrik <frejon at gmail.com> wrote:
>
>> Thanks for the reply Miroslav. I get an immediate Fatal Crash when I add
>> a renderWindow.render() line.
>>
>>
>> # A fatal error has been detected by the Java Runtime Environment:
>> #
>> #  SIGSEGV (0xb) at pc=0x000000012f4b8979, pid=42597, tid=54087
>> #
>> # JRE version: Java(TM) SE Runtime Environment (8.0_45-b14) (build
>> 1.8.0_45-b14)
>> # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode
>> bsd-amd64 compressed oops)
>> # Problematic frame:
>> # C  [libvtkRenderingOpenGL.jnilib+0x179979]  vtkUpload3D<unsigned
>> char>::Upload(void*, unsigned char*, unsigned int*, int, long long*, int,
>> int*)+0x149
>>
>> full crash report here: http://pastebin.com/bvfxB3er
>>
>> Which is interesting, I can ask the JOGLVisPanel itself to render
>> flawlessly, but not the vtkRenderWindow contained therein.
>> I can't really make sense of the error report. If anyone could take pity
>> on my plight and help me I'd be most appreciative. I'm suspecting some kind
>> of JOGL/VTK/Mac problem. If it's any help, I'm debugging code that used to
>> work years ago under JDK 6 and older versions of VTK.
>>
>> // Fredrik
>>
>>
>> 2015-06-09 19:43 GMT+02:00 Miroslav Drahos <mdrahos at thinksurgical.com>:
>>
>>> Frederik,
>>> you should call vtkRenderWindow::Render() before updating the pipeline.
>>> This is what has worked for me reliably:
>>>
>>>   VTK_CREATE(vtkWindowToImageFilter, w2i);
>>>   w2i->SetInput(rw);
>>>   w2i->ReadFrontBufferOff();
>>>   rw->Render();
>>>   w2i->Modified();  // See doc
>>> http://www.vtk.org/doc/nightly/html/classvtkWindowToImageFilter.html#details
>>>
>>>   VTK_CREATE(vtkPNGWriter, writer);
>>>   writer->SetFileName(fname.c_str());
>>>   writer->SetInputConnection(w2i->GetOutputPort());
>>>   writer->Write();
>>>
>>> where VTK_CREATE is a widely used macro:
>>>
>>> #define VTK_CREATE(type, name) vtkSmartPointer<type> name =
>>> vtkSmartPointer<type>::New();
>>>
>>> HTH,
>>> Miro
>>>
>>> ________________________________________
>>> From: vtkusers [vtkusers-bounces at vtk.org] On Behalf Of Fredrik [
>>> frejon at gmail.com]
>>> Sent: Tuesday, June 09, 2015 8:55 AM
>>> To: Scott Wittenburg
>>> Cc: vtkusers at public.kitware.com
>>> Subject: Re: [vtkusers] vtkWindowToImageFilter - black image
>>>
>>> Hi Scott, thanks for the reply. Unfortunately it didn't help. I think I
>>> remember some other thread with the "ShouldRerender" flag, but I think that
>>> mentioned it should be windowToImageFilter.ShouldRerenderOff();
>>> , not on. I tried both anyway, but no change
>>>
>>> All the best,
>>> Fredrik
>>>
>>> 2015-06-09 17:33 GMT+02:00 Scott Wittenburg <
>>> scott.wittenburg at kitware.com<mailto:scott.wittenburg at kitware.com>>:
>>> Hi Frederik,
>>>
>>>    I believe I have encountered this before.  What solved it for me was
>>> turning on the "ShouldRerender" flag in addition to what you have set.
>>> Something like:
>>>
>>> windowToImageFilter.ShouldRerenderOn();
>>>
>>> could possibly help.
>>>
>>> Cheers,
>>> Scott
>>>
>>>
>>>
>>> On Tue, Jun 9, 2015 at 9:02 AM, Fredrik <frejon at gmail.com<mailto:
>>> frejon at gmail.com>> wrote:
>>> Hello. There are several threads on this topic, and the few I see, the
>>> proposed solutions are not enough or the thread is left unresolved. see
>>> this:
>>>
>>> http://public.kitware.com/pipermail/vtkusers/2014-October/085358.html
>>> http://public.kitware.com/pipermail/vtkusers/2014-October/085294.html
>>>
>>> I still am unable to generate anything else than a black image.
>>> I'm on the latest VTK, under Mac OS X 10.10.  I also tried offscreen
>>> rendering, but no luck.
>>>
>>> Hours of googling and testing solutions have proven unsuccessful, I'd
>>> really appreciate if anyone could help me.
>>>
>>> here's a snippet of my code if you think it'll help
>>>
>>>         tempFile = "xyz.bmp";
>>>         // write to temporary bmp file
>>>         vtkBMPWriter writer = new vtkBMPWriter();
>>>         vtkWindowToImageFilter windowToImageFilter = new
>>> vtkWindowToImageFilter();
>>>         windowToImageFilter.ReadFrontBufferOff();
>>>         windowToImageFilter.SetMagnification(1);
>>>         windowToImageFilter.SetInput(renderWindow);
>>>         windowToImageFilter.SetInputBufferTypeToRGBA();
>>>         windowToImageFilter.ReadFrontBufferOff();
>>>
>>>         windowToImageFilter.Update();
>>>
>>>         windowToImageFilter.ReadFrontBufferOff();
>>>         writer.SetInputConnection(windowToImageFilter.GetOutputPort());
>>>         writer.SetFileName(tempFile);
>>>         writer.Write();
>>>
>>>
>>>
>>> Kind Regards, Fredrik
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com<http://www.kitware.com>
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
>
>
> --
> kinde mekuria
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150610/aeb187dc/attachment.html>


More information about the vtkusers mailing list