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

Last change on this file since 2277 was 2103, checked in by ldelgass, 13 years ago

Remove unused _pixels data member, fixes warning about deleting a void pointer
being undefined.

  • 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        //glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
53        glGenTextures(1, &_objectID);
54        glBindTexture(_target, _objectID);
55        glTexImage3D(_target, 0, _internalColorFormat, _width, _height, _depth, 0, _colorFormat, _type, data) ;
56    glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
57        glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
58       
59        //TBD..
60        glTexParameterf(_target, GL_TEXTURE_WRAP_S, _wrapS);
61    glTexParameterf(_target, GL_TEXTURE_WRAP_T, _wrapT);
62
63       
64}
65
66void vrTexture3D::updatePixels(void* data)
67{
68        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
69        glBindTexture(_target, _objectID);
70        glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
71        glTexParameteri(_target, GL_TEXTURE_WRAP_T, _wrapT);
72        glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
73        glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
74        glTexImage3D(_target, 0, _internalColorFormat, _width, _height, _depth, 0, _colorFormat, _type, data);
75        /*
76        glBindTexture(_target, _objectID);
77        glTexSubImage3D(_target,
78                                                0,
79                                                0,
80                                                0,
81                                                0,
82                                                _width,
83                                                _height,
84                                                _depth,
85                                                _colorFormat,
86                                                _type,
87                                                data);
88                                                */
89}
90
91#endif
Note: See TracBrowser for help on using the repository browser.