source: trunk/packages/vizservers/nanovis/vr3d/vrTexture3D.cpp @ 2096

Last change on this file since 2096 was 2096, checked in by ldelgass, 14 years ago

Normalize line endings, set eol-style to native on *.cpp, *.h files

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1#include <vr3d/vrTexture3D.h>
2
3#include <string.h>
4#include <math.h>
5#include <valarray>
6
7#ifndef OPENGLES
8#ifdef _WIN32
9inline unsigned int log2(unsigned int x)
10{
11    unsigned int i = 0;
12    while ( ( x = ( x >> 1 ) ) != 0 ) i++;
13        return i;     
14}
15#endif
16
17
18vrTexture3D::vrTexture3D()
19: _width(0), _height(0), _depth(0)
20{
21        _target = TT_TEXTURE_3D;
22        _wrapT = TW_CLAMP_TO_EDGE;
23        _wrapS =TW_CLAMP_TO_EDGE;
24}
25
26vrTexture3D::~vrTexture3D()
27{
28       
29}
30
31void vrTexture3D::setPixels(COLORFORMAT colorFormat, DATATYPE type, int width, int height, int depth, void* data)
32{
33    setPixels(TT_TEXTURE_3D, colorFormat,  colorFormat, type, width, height, depth, data);
34}
35
36void vrTexture3D::setPixels(TEXTARGET target,  COLORFORMAT internalColorFormat, COLORFORMAT colorFormat, DATATYPE type, int width, int height, int depth, void* data)
37{
38    _target = target;
39        _width = width;
40        _height = height;
41        _depth = depth;
42        _type = type;
43    _internalColorFormat = internalColorFormat;
44        _colorFormat = colorFormat;
45        _compCount = GetNumComponent(_colorFormat);
46
47        if (_objectID)
48        {
49                glDeleteTextures(1, &_objectID);
50        }
51
52        if (_pixels)
53        {
54                delete [] _pixels;
55        }
56
57        //glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
58        glGenTextures(1, &_objectID);
59        glBindTexture(_target, _objectID);
60        glTexImage3D(_target, 0, _internalColorFormat, _width, _height, _depth, 0, _colorFormat, _type, data) ;
61    glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
62        glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
63       
64        //TBD..
65        glTexParameterf(_target, GL_TEXTURE_WRAP_S, _wrapS);
66    glTexParameterf(_target, GL_TEXTURE_WRAP_T, _wrapT);
67
68       
69}
70
71void vrTexture3D::updatePixels(void* data)
72{
73        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
74        glBindTexture(_target, _objectID);
75        glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
76        glTexParameteri(_target, GL_TEXTURE_WRAP_T, _wrapT);
77        glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
78        glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
79        glTexImage3D(_target, 0, _internalColorFormat, _width, _height, _depth, 0, _colorFormat, _type, data);
80        /*
81        glBindTexture(_target, _objectID);
82        glTexSubImage3D(_target,
83                                                0,
84                                                0,
85                                                0,
86                                                0,
87                                                _width,
88                                                _height,
89                                                _depth,
90                                                _colorFormat,
91                                                _type,
92                                                data);
93                                                */
94}
95
96#endif
Note: See TracBrowser for help on using the repository browser.