I ran the following commands within a root session to export pictures with different formats.
TGLViewer * v = (TGLViewer *)gPad->GetViewer3D();
v->SavePicture("viewer.png");
v->SavePicture("viewer.pdf");
v->SavePicture("viewer.eps");
Exporting as png (or gif, gif+) all worked perfect, but pdf is somewhat broken as shown below. Exporting as eps is even worse as it crashed and output only an empty file. I know that I can avoid pdf by scaling up png images but I wish to understand why are pdf and eps broken in my case. Could anyone shed some light on this problem? I really appreciate it!
This is actually the first time I use TGLViewer…so I basically looked up everything first in the Class Reference and and found SavePicture function supports pdf format. This link ROOT: TGLViewer Class Reference should be able to bring you to the description of SavePicture. However, it warns me that ‘eps’ and ‘pdf’ do not fully support transparency and texturing. Perhaps this is the cause?
The pdf exporting is actually working as expected. The problem is caused by the semitransparent box (alpha value set to really low so you can barely see it) around the 3D object. At current stage, SavePicture with pdf format can not handle semitransparent object properly. That’s why it was rendered that way. I have to change the visualization attribute to transparent. And I can also export as eps file which turns out to be much better than pdf after experimenting.