From $ROOTSYS/tutorials/gl/transp.C

//This demo shows how to use transparency.

//Includes for ACLiC (cling does not need them).
#include "TCanvas.h"
#include "TColor.h"
#include "TError.h"
#include "TStyle.h"
#include "TH1F.h"

//Aux. functions for tutorials/gl.
#include "customcolorgl.h"

void transp()
{
   //1. Try to find free indices for our custom colors.
   //We can use hard-coded indices like 1001, 1002, 1003, ... but
   //I prefer to find free indices in a ROOT's color table
   //to avoid possible conflicts with other tutorials.
   Int_t indices[2] = {};
   if (ROOT::GLTutorials::FindFreeCustomColorIndices(indices) != 2) {
      ::Error("transp", "failed to create new custom colors");
      return;
   }

   //2. Now that we have indices, create our custom colors.
   const Int_t redIndex = indices[0], greeIndex = indices[1];

   new TColor(redIndex, 1., 0., 0., "red", 0.85);
   new TColor(greeIndex, 0., 1., 0., "green", 0.5);

   gStyle->SetCanvasPreferGL(kTRUE);
   TCanvas * const cnv = new TCanvas("trasnparency", "transparency demo", 600, 400);

   TH1F * const hist = new TH1F("a5", "b5", 10, -2., 3.);
   TH1F * const hist2 = new TH1F("c6", "d6", 10, -3., 3.);
   hist->FillRandom("landau", 100000);
   hist2->FillRandom("gaus", 100000);

   hist->SetFillColor(redIndex);
   hist2->SetFillColor(greeIndex);

   cnv->cd();
   hist2->Draw();
   hist->Draw("SAME");
}
 transp.C:1
 transp.C:2
 transp.C:3
 transp.C:4
 transp.C:5
 transp.C:6
 transp.C:7
 transp.C:8
 transp.C:9
 transp.C:10
 transp.C:11
 transp.C:12
 transp.C:13
 transp.C:14
 transp.C:15
 transp.C:16
 transp.C:17
 transp.C:18
 transp.C:19
 transp.C:20
 transp.C:21
 transp.C:22
 transp.C:23
 transp.C:24
 transp.C:25
 transp.C:26
 transp.C:27
 transp.C:28
 transp.C:29
 transp.C:30
 transp.C:31
 transp.C:32
 transp.C:33
 transp.C:34
 transp.C:35
 transp.C:36
 transp.C:37
 transp.C:38
 transp.C:39
 transp.C:40
 transp.C:41
 transp.C:42
 transp.C:43
 transp.C:44
 transp.C:45
 transp.C:46