source: branches/blt4/packages/vizservers/nanovis/TransferFunction.cpp @ 2742

Last change on this file since 2742 was 1493, checked in by gah, 15 years ago

Changed vector id to name

File size: 1.3 KB
Line 
1
2/*
3 * ----------------------------------------------------------------------
4 * ColorMap.h: color map class contains an array of (RGBA) values
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2006  Purdue Research Foundation
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16
17
18#include "TransferFunction.h"
19#include <memory.h>
20#include <assert.h>
21
22TransferFunction::TransferFunction(int size, float *data)
23{
24    _tex = new Texture1D(size, GL_FLOAT);
25
26    // _size : # of slot, 4 : rgba
27    _size = size * 4;
28    _data = new float[_size];
29    memcpy(_data, data, sizeof(float) * _size);
30    _tex->initialize_float_rgba(_data);
31    _id = _tex->id;
32}
33
34
35TransferFunction::~TransferFunction()
36{
37    delete [] _data;
38    delete _tex;
39}
40
41void
42TransferFunction::update(float* data)
43{
44    memcpy(_data, data, sizeof(float) * _size);
45    _tex->update_float_rgba(_data);
46}
47
48
49void
50TransferFunction::update(int size, float *data)
51{
52    // TBD..
53    //assert((size*4) == _size);
54    update(data);
55}
56
Note: See TracBrowser for help on using the repository browser.