source: trunk/packages/vizservers/nanovis/TransferFunction.cpp @ 1489

Last change on this file since 1489 was 1475, checked in by vrinside, 15 years ago

mofified a way of dealing with volumes by adding reference counts to data objects.

  • To-do : check any memory leaks for graphics objects
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
31    _tex->initialize_float_rgba(_data);
32    id = _tex->id;
33}
34
35
36TransferFunction::~TransferFunction()
37{
38    delete [] _data;
39    delete _tex;
40}
41
42void
43TransferFunction::update(float* data)
44{
45    memcpy(_data, data, sizeof(float) * _size);
46    _tex->update_float_rgba(_data);
47}
48
49
50void
51TransferFunction::update(int size, float *data)
52{
53    // TBD..
54    //assert((size*4) == _size);
55    update(data);
56}
57
Note: See TracBrowser for help on using the repository browser.