Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQGLColormap Class Reference
[OpenGL module]

The TQGLColormap class is used for installing custom colormaps into TQGLWidgets. More...

#include <ntqglcolormap.h>

List of all member functions.

Public Members


Detailed Description

The TQGLColormap class is used for installing custom colormaps into TQGLWidgets.

TQGLColormap provides a platform independent way of specifying and installing indexed colormaps into TQGLWidgets. TQGLColormap is especially useful when using the OpenGL color-index mode.

Under X11 you must use an X server that supports either a PseudoColor or DirectColor visual class. If your X server currently only provides a GrayScale, TrueColor, StaticColor or StaticGray visual, you will not be able to allocate colorcells for writing. If this is the case, try setting your X server to 8 bit mode. It should then provide you with at least a PseudoColor visual. Note that you may experience colormap flashing if your X server is running in 8 bit mode.

Under Windows the size of the colormap is always set to 256 colors. Note that under Windows you can also install colormaps in child widgets.

This class uses explicit sharing (see Shared Classes).

Example of use:

    #include <ntqapplication.h>
    #include <ntqglcolormap.h>

    int main()
    {
        TQApplication a( argc, argv );

        MySuperGLWidget widget( 0 ); // A TQGLWidget in color-index mode
        TQGLColormap colormap;

        // This will fill the colormap with colors ranging from
        // black to white.
        for ( int i = 0; i < colormap.size(); i++ )
            colormap.setEntry( i, qRgb( i, i, i ) );

        widget.setColormap( colormap );
        widget.show();
        return a.exec();
    }
    

See also TQGLWidget::setColormap(), TQGLWidget::colormap(), Graphics Classes, and Image Processing Classes.


Member Function Documentation

TQGLColormap::TQGLColormap ()

Construct a TQGLColormap.

TQGLColormap::TQGLColormap ( const TQGLColormap & map )

Construct a shallow copy of map.

TQGLColormap::~TQGLColormap ()

Dereferences the TQGLColormap and deletes it if this was the last reference to it.

void TQGLColormap::detach ()

Detaches this TQGLColormap from the shared block.

TQColor TQGLColormap::entryColor ( int idx ) const

Returns the TQRgb value in the colorcell with index idx.

TQRgb TQGLColormap::entryRgb ( int idx ) const

Returns the TQRgb value in the colorcell with index idx.

int TQGLColormap::find ( TQRgb color ) const

Returns the index of the color color. If color is not in the map, -1 is returned.

int TQGLColormap::findNearest ( TQRgb color ) const

Returns the index of the color that is the closest match to color color.

bool TQGLColormap::isEmpty () const

Returns TRUE if the colormap is empty; otherwise returns FALSE. A colormap with no color values set is considered to be empty.

TQGLColormap & TQGLColormap::operator= ( const TQGLColormap & map )

Assign a shallow copy of map to this TQGLColormap.

void TQGLColormap::setEntries ( int count, const TQRgb * colors, int base = 0 )

Set an array of cells in this colormap. count is the number of colors that should be set, colors is the array of colors, and base is the starting index.

void TQGLColormap::setEntry ( int idx, TQRgb color )

Set cell at index idx in the colormap to color color.

void TQGLColormap::setEntry ( int idx, const TQColor & color )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Set the cell with index idx in the colormap to color color.

int TQGLColormap::size () const

Returns the number of colorcells in the colormap.

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8