From $ROOTSYS/tutorials/gl/glvox1.C

// This macro demonstrates how to use "glcol" option for TH3.
// Author: Timur Pocheptsov

void glvox1()
{
   //Create and fill TH3.
   const UInt_t nX = 30;
   const Double_t xMin = -1., xMax = 1., xStep = (xMax - xMin) / (nX - 1);

   const UInt_t nY = 30;
   const Double_t yMin = -1., yMax = 1., yStep = (yMax - yMin) / (nY - 1);

   const UInt_t nZ = 30;
   const Double_t zMin = -1., zMax = 1., zStep = (zMax - zMin) / (nZ - 1);

   TH3F *hist = new TH3F("glvoxel", "glvoxel", 30, -1., 1., 30, -1., 1., 30, -1., 1.);

   //Fill the histogram to create a "sphere".
   for (UInt_t i = 0; i < nZ; ++i) {
      const Double_t z = zMin + i * zStep;

      for (UInt_t j = 0; j < nY; ++j) {
         const Double_t y = yMin + j * yStep;

         for (UInt_t k = 0; k < nX; ++k) {
            const Double_t x = xMin + k * xStep;

            const Double_t val = 1. - (x * x + y * y + z * z);
            hist->SetBinContent(k + 1, j + 1, i + 1, val);
         }
      }
   }

   gStyle->SetCanvasPreferGL(1);
   gStyle->SetPalette(1);

   hist->Draw("glcol");
}
 glvox1.C:1
 glvox1.C:2
 glvox1.C:3
 glvox1.C:4
 glvox1.C:5
 glvox1.C:6
 glvox1.C:7
 glvox1.C:8
 glvox1.C:9
 glvox1.C:10
 glvox1.C:11
 glvox1.C:12
 glvox1.C:13
 glvox1.C:14
 glvox1.C:15
 glvox1.C:16
 glvox1.C:17
 glvox1.C:18
 glvox1.C:19
 glvox1.C:20
 glvox1.C:21
 glvox1.C:22
 glvox1.C:23
 glvox1.C:24
 glvox1.C:25
 glvox1.C:26
 glvox1.C:27
 glvox1.C:28
 glvox1.C:29
 glvox1.C:30
 glvox1.C:31
 glvox1.C:32
 glvox1.C:33
 glvox1.C:34
 glvox1.C:35
 glvox1.C:36
 glvox1.C:37
 glvox1.C:38
 glvox1.C:39