Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 9. OpenGL > Creating a Color Scale

Creating a Color Scale

It is useful to show the representation of colors assigned to the data plot on the GUI. For this the Map Color control is created to act as a legend for the colors showing the data range. The CreateColorScale function is called from the PlotOGLData function above for this purpose. The source listing for CreateColorScale is shown in Figure 9-9.

Figure 9-9. CreateColorScale Source Listing

    //Display color map on the Color Map scale
    int CreateColorScale (void)

        double ColorMapArray[5][2];
        int NumberOfXpoints, NumberOfYpoints, NumberOfColors,
             InterpolateColors,InterpolatePixels ;

        ColorMapArray[0][0] = -10.0;
        ColorMapArray[0][1] = -10.0;
        ColorMapArray[1][0] = -5.0;
        ColorMapArray[1][1] = -5.0;
        ColorMapArray[2][0] =  0.0;
        ColorMapArray[2][1] =  0.0;
        ColorMapArray[3][0] =  5.0;
        ColorMapArray[3][1] =  5.0;
        ColorMapArray[4][0] =  10.0;
        ColorMapArray[4][1] =  10.0;

        // Plot this array on the color scale graph control
        NumberOfXpoints = 2;
        NumberOfYpoints = 5;
        NumberOfColors =   5;
        InterpolateColors =    0;
        InterpolatePixels =	0;

	if (PlotIntensity (OGLPanelHandle, OGLPANEL_COLORMAP, ColorMapArray,
		    NumberOfXpoints, NumberOfYpoints, VAL_DOUBLE, MapColor, VAL_YELLOW,
                                     NumberOfColors, InterpolateColors, InterpolatePixels) <= 0)
	    return -1;
        return 0;



You are currently reading a PREVIEW of this book.


Get instant access to over $1 million worth of books and videos.


Start a Free 10-Day Trial

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint