source: branches/blt4/packages/vizservers/nanovis/vr3d/vrTexture1D.cpp @ 2120

Last change on this file since 2120 was 2120, checked in by gah, 13 years ago
File size: 1.7 KB
Line 
1#include <vr3d/vrTexture1D.h>
2
3#include <string.h>
4#include <math.h>
5#include <valarray>
6
7#ifdef _WIN32
8inline unsigned int log2(unsigned int x)
9{
10    unsigned int i = 0;
11    while ( ( x = ( x >> 1 ) ) != 0 ) i++;
12        return i;     
13}
14#endif
15
16
17vrTexture1D::vrTexture1D(bool depth)
18: _width(0)
19{
20        _target = TT_TEXTURE_1D;
21        _wrapS =TW_CLAMP_TO_EDGE;
22}
23
24vrTexture1D::~vrTexture1D()
25{
26}
27
28void vrTexture1D::setPixels(COLORFORMAT colorFormat, DATATYPE type, int width, void* data)
29
30{
31    setPixels(TT_TEXTURE_1D, colorFormat,  colorFormat, type, width, data);
32}
33
34void vrTexture1D::setPixels(TEXTARGET target,  COLORFORMAT internalColorFormat, COLORFORMAT colorFormat, DATATYPE type, int width, void* data)
35{
36        _target = target;
37        _width = width;
38        _type = type;
39        _internalColorFormat = internalColorFormat;
40        _colorFormat = colorFormat;
41        _compCount = GetNumComponent(_colorFormat);
42
43        if (_objectID)
44        {
45                glDeleteTextures(1, &_objectID);
46        }
47
48        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
49        glGenTextures(1, &_objectID);
50        glBindTexture(_target, _objectID);
51
52        glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
53        glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
54        glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
55
56        glTexImage1D(_target, 0, _internalColorFormat, _width, 0, _colorFormat, _type, data);
57
58       
59}
60
61void vrTexture1D::updatePixels(void* data)
62{
63        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
64        glBindTexture(_target, _objectID);
65        glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
66        glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
67        glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
68        glTexImage1D(_target, 0, _internalColorFormat, _width, 0, _colorFormat, _type, data);
69}
70
Note: See TracBrowser for help on using the repository browser.