Chandrajit Bajaj



VRLIB(Volume Rendering Library) is a C++ library which provides efficient volume rendering functionality using OpenGL and modern graphics hardware.

  • Multiplatform C++ using OpenGL. Volume Library has been tested on Windows, Linux, MacOS X and Irix.
  • Supports several types of graphics hardware. 3D texture support is not a requirement (though it is strongly recommended).


C. Bajaj, Z. Yu and M. Auer
Volumetric Feature Extraction and Visualization of Tomographic Molecular Imaging
Journal of Structural Biology, 2003, 144(1-2), pp. 132-143. (pdf)

  • Source package of VRLIB is delivered on demand upon explicit request.
    Please contact to Dr. Chandrajit Bajaj (

  • VRLIB functionalities are also provided through our molecular visualization and processing tool VolRover.

Software Usage
  • Installation
    • Requirements: C++ compiler, OpenGL, Qmake + GNU make on Linux
    • Building:
      • Unix: run qmake and make in Volume Library's directory.
      • Windows: include Volume Library's VC++ project file as a dependency of a project that wishes to use the library.

  • Simple Use:
    • #include
    • Create a VolumeRenderer instance.
    • call initRenderer() for that instance.
    • Upload texture data with uploadColorMappedData(...) or uploadRGBAData(...). Note that texture dimensions _must_ be a power of 2.
    • Upload a colormap with uploadColorMap(...) if you used uploadColorMappedData(...).
    • Render the volume with renderVolume().

  • Advanced Use:
    • Add support for other graphics chipsets by subclassing UnshadedBase or RGBABase.
    • Look at the XXXImpl.cpp source files for example implementations.

Further Details
  • Function Descriptions

    Constructors, assignment:

      VolumeRenderer(const VolumeRenderer& copy);
      VolumeRenderer& operator=(const VolumeRenderer& copy);
      : These are pretty straightforward.


      bool initRenderer();
      : This function attempts to construct a colormapped and an RGBA rendering object. If either attempt fails, the function returns false. You should not proceed if this function returns false.

    Aspect Ratio:

      bool setAspectRatio(double ratioX, double ratioY, double ratioZ);
      : This function sets the aspect ratio for the volume's cells. The aspect ratio is the same as the span in a rawiv file. All arguments are in the range [0,1].

    Texture Sub-cube:

      bool setTextureSubCube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ);
      : This function controls how much of the texture is rendered. Its main use is rendering volumes whose dimensions are not a power of two. Simply copy the volume to a texture which is large enough to hold it but has power of two dimensions. Pad with zeros (otherwise the edges might look odd). Then call setTextureSubCube() with the extents of the cube that the volume data occupies. All arguments are in the range [0,1];

    Render Quality:

      bool setQuality(double quality);
      double getQuality() const;
      : These functions set and return the current render quality. setQuality() is most useful in controlling rendering speed. What is actually adjusted is the sampling rate of the volume rendering integral (ie- the number of cutting planes that are drawn). The range of values for the quality is [0,1]. 0 is the lowest quality, 1 is the highest.

    Clipping Plane:

      bool setNearPlane(double nearPlane);
      double getNearPlane();
      : These functions set and return the current relative position of the clipping plane. The range of values for the position is [0,1]. 0 means no clipping. 1 means the entire volume is clipped.

    Shaded Rendering:

      bool isShadedRenderingAvailable() const;
      bool enableShadedRendering();
      bool disableShadedRendering();
      : Currently these functions have no effect. In the future, Volume Library will support shaded rendering.

    Volume Data Uploading:

      bool uploadColorMappedData(const GLubyte* data, int width, int height, int depth);
      bool uploadColorMappedDataWithBorder(const GLubyte* data, int width, int height, int depth);
      bool uploadRGBAData(const GLubyte* data, int width, int height, int depth);
      : These functions supply the renderer with data to render. The uploadColorMappedDataWithBorder() function is not supported currently (it always returns false). The memory pointed to by data can be freed after these functions return. width, height, and depth are the dimensions of the buffer being uploaded. They _must_ be power of two. This is a restriction of most hardware. As of the GeForce 6800 (and possibly the ATI X800) this restriction is going away. Non power of two textures are part of the OpenGL 2.0 spec.

    Test Data Uploading:

      bool testColorMappedData(int width, int height, int depth);
      bool testColorMappedDataWithBorder(int width, int height, int depth);
      : These functions test whether or not a call to uploadXXXData() will succeed based on the size of the volume.

    Shading Information:

      bool uploadGradients(const GLubyte* data, int width, int height, int depth);
      bool calculateGradientsFromDensities(const GLubyte* data, int width, int height, int depth);
      : These functions will affect the normals used for shaded rendering when it is supported. Currently they do nothing.

    Colormap Management:

      bool uploadColorMap(const GLubyte* colorMap);
      : This function sets the colormap for the renderer. A colormap is a 1024 entry array of unsigned bytes. Every 4 bytes is an RGBA tuple.


      bool renderVolume();
      : This function renders the volume. If there is an error, it returns false.


      int getNumberOfPlanesRendered() const;
      :This function returns the number of planes that were draw by the last call to renderVolume().