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 | |
---|
22 | TransferFunction::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 | |
---|
36 | TransferFunction::~TransferFunction() |
---|
37 | { |
---|
38 | delete [] _data; |
---|
39 | delete _tex; |
---|
40 | } |
---|
41 | |
---|
42 | void |
---|
43 | TransferFunction::update(float* data) |
---|
44 | { |
---|
45 | memcpy(_data, data, sizeof(float) * _size); |
---|
46 | _tex->update_float_rgba(_data); |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | void |
---|
51 | TransferFunction::update(int size, float *data) |
---|
52 | { |
---|
53 | assert((size*4) == _size); |
---|
54 | update(data); |
---|
55 | } |
---|
56 | |
---|