I’m able to view all GL examples on $ROOTSYS/tutorials/gl, when I run them interactively on root, i.e. with
.x macroname.C
Problems arise when I attempt viewing a written canvas to a root file. For instance, when I modify the macro glbox.C the following way:
a) on the very first line (within curly brackets):
TFile *file = new TFile(“file.root”,“RECREATE”);
b) on the very last line:
c->Write();
Then, I open the file and the canvas: Only the title “glbox …” is displayed. No histograms. Moving the cursor across the canvas, and the following error message is printed to the screen:
[quote=“gkert”]Then, I open the file and the canvas: Only the title “glbox …” is displayed. No histograms. Moving the cursor across the canvas, and the following error message is printed to the screen:
To enable opengl in a pad you have to call gStyle->SetCanvasPreferGL(kTRUE) before a canvas created.
Obviously, this line of code from any tutorial macro is not saved in your file. Can you try to execute gStyle->SetCanvasPreferGL(kTRUE) before you draw any object from the file? (btw I did not expect “glxxx” option to be saved either).
Well, in the example script, gStyle->SetCanvasPreferGL(kTRUE) is called prior to creating the canvas. I have attached a copy of the example file (glbox.C) with my two added lines.