RE: [Fwd: Colors in OpenGL]

From: Valery Fine (Faine) (fine@bnl.gov)
Date: Thu Jun 03 1999 - 22:32:42 MEST


> 
> Hi Valery ,
> 
> thanks for the answer. I used root under linux. The screenshots were taken on a MAC running a X Window
> Server.
> But I checked the colors also directly on the console of the linux machine. They are exactly the same.
> Right now I am not able to comiple our custom class libraries under windows because I do not
> know an easy way how to transfer the unix makefile to Visual C++. So I can not check the colors
> under Windows.

    But you can just try that "tutorials/shapes.C" and customize it with the colors you want to check.

> When I run the shapes.C macro and change the LineColor in the TPad the color in the GLViewer Window
> follows not in all cases.The root line color number 28 (kind of brown) gives a blue color in the GL
> Window.

  I  took "shapes.C" example and changed the line:

    tube->SetLineColor(28);
 
  in there and got what I expected,  
  Namely  I found no problem with "native" light scheme. (just by pressing letter "t")

  "For  the "artificial" scheme I did get some "blue" color. The color index is calculated 
  slightly more complicated:

     fColorIndx = ((c % 8) - 1) * 4;

    c = 28 (for your case)

    fColorIndx =   ((28 % 8) - 1) * 4 = ( 4 -1 ) * 4 = 3 * 4 = 12

   void LightIndex(Int_t i)
     { SetCurrentColor(fColorIndx + 201 + ((i == 0) ? 0 : TMath::Abs(i%7-3))); }
 
      12 + 201 +- 3 = 213 +- 3

    The last +- 3 creates you some "shadow effect".

  Now:

root [1] TColor *c213 = gROOT->GetColor(213)
root [2] Float_t red, gree, blue;
root [3] c213->GetRGB(red,gree,blue)
root [6] cout <<"red=" << red << " green=" <<gree << " blue=" << blue << endl;

            red=0.06 green=0.06 blue=0.54 
                                           --------------

This means the color 213 is mostly "BLUE" as you did observe.

However the "original" index 28 gives:

root [7] TColor *c213 = gROOT->GetColor(28)
root [8] c213->GetRGB(red,gree,blue)
root [9] cout <<"red=" << red << " green=" <<gree << " blue=" << blue << endl;

                      red=0.53 green=0.4 blue=0.34
                      ------------

  So it has a lot of "red" as you expected.

 
  Actually the scheme was introduced by Nenad Buncic for x3d package and was reproduced 
  for GL view just to provide the same colors as X3D does. Sorry I forgot some detail of that job.

  The ROOT color palette is defined by 

  void TApplication::InitializeColors() method and for the colors in question it looks as follows:

     // Initialize special colors for x3d
      for (i = 1; i < 8; i++) {
         s0 = gROOT->GetColor(i);
         s0->GetRGB(r,g,b);
         if (i == 1) { r = 0.6; g = 0.6; b = 0.6; }
         if (r == 1) r = 0.9; if (r == 0) r = 0.1;
         if (g == 1) g = 0.9; if (g == 0) g = 0.1;
         if (b == 1) b = 0.9; if (b == 0) b = 0.1;
         s0->RGBtoHLS(r,g,b,h,l,s);
         s0->HLStoRGB(h,0.6*l,s,r,g,b);
         new TColor(200+4*i-3,r,g,b);
         s0->HLStoRGB(h,0.8*l,s,r,g,b);
         new TColor(200+4*i-2,r,g,b);
         s0->HLStoRGB(h,1.2*l,s,r,g,b);
         new TColor(200+4*i-1,r,g,b);
         s0->HLStoRGB(h,1.4*l,s,r,g,b);
         new TColor(200+4*i  ,r,g,b);
      }
   }

 Actually this means if  one wants ot get another palette for either x3d or for "artificial" GL light
model one has to redefine those TColor ROOT entry points with his/her code.

  Hope this helps,
   With my best regards,
                                                  Valery  



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:34 MET