Changeset 2824 for trunk/packages/vizservers/nanovis/vr3d/vrTexture3D.cpp
- Timestamp:
- Mar 7, 2012, 1:21:00 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/vr3d/vrTexture3D.cpp
r2798 r2824 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <vr3d/vrTexture3D.h>3 2 4 3 #include <string.h> 5 4 #include <math.h> 6 #include <valarray> 5 #include <valarray> 7 6 8 #ifndef OPENGLES 7 #include <vr3d/vrTexture3D.h> 8 9 9 #ifdef _WIN32 10 10 inline unsigned int log2(unsigned int x) … … 16 16 #endif 17 17 18 19 vrTexture3D::vrTexture3D() 20 : _width(0), _height(0), _depth(0) 18 vrTexture3D::vrTexture3D() : 19 _width(0), 20 _height(0), 21 _depth(0) 21 22 { 22 23 24 _wrapS =TW_CLAMP_TO_EDGE;23 _target = TT_TEXTURE_3D; 24 _wrapT = TW_CLAMP_TO_EDGE; 25 _wrapS = TW_CLAMP_TO_EDGE; 25 26 } 26 27 27 28 vrTexture3D::~vrTexture3D() 28 29 { 29 30 30 } 31 31 32 void vrTexture3D::setPixels(COLORFORMAT colorFormat, DATATYPE type, int width, int height, int depth, void* data) 32 void vrTexture3D::setPixels(COLORFORMAT colorFormat, DATATYPE type, 33 int width, int height, int depth, void *data) 33 34 { 34 setPixels(TT_TEXTURE_3D, colorFormat, 35 setPixels(TT_TEXTURE_3D, colorFormat, colorFormat, type, width, height, depth, data); 35 36 } 36 37 37 void vrTexture3D::setPixels(TEXTARGET target, COLORFORMAT internalColorFormat, COLORFORMAT colorFormat, DATATYPE type, int width, int height, int depth, void* data) 38 void vrTexture3D::setPixels(TEXTARGET target, 39 COLORFORMAT internalColorFormat, 40 COLORFORMAT colorFormat, 41 DATATYPE type, 42 int width, int height, int depth, void *data) 38 43 { 39 44 _target = target; 40 41 42 43 45 _width = width; 46 _height = height; 47 _depth = depth; 48 _type = type; 44 49 _internalColorFormat = internalColorFormat; 45 46 50 _colorFormat = colorFormat; 51 _compCount = GetNumComponent(_colorFormat); 47 52 48 if (_objectID) 49 { 50 glDeleteTextures(1, &_objectID); 51 } 53 if (_objectID) { 54 glDeleteTextures(1, &_objectID); 55 } 52 56 53 54 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) ; 57 61 glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter); 58 62 glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter); 59 63 60 61 64 //TBD.. 65 glTexParameterf(_target, GL_TEXTURE_WRAP_S, _wrapS); 62 66 glTexParameterf(_target, GL_TEXTURE_WRAP_T, _wrapT); 63 64 65 67 } 66 68 67 69 void vrTexture3D::updatePixels(void* data) 68 70 { 69 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 70 glBindTexture(_target, _objectID); 71 glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS); 72 glTexParameteri(_target, GL_TEXTURE_WRAP_T, _wrapT); 73 glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter); 74 glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter); 75 glTexImage3D(_target, 0, _internalColorFormat, _width, _height, _depth, 0, _colorFormat, _type, data); 76 /* 77 glBindTexture(_target, _objectID); 78 glTexSubImage3D(_target, 79 0, 80 0, 81 0, 82 0, 83 _width, 84 _height, 85 _depth, 86 _colorFormat, 87 _type, 88 data); 89 */ 71 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 72 glBindTexture(_target, _objectID); 73 glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS); 74 glTexParameteri(_target, GL_TEXTURE_WRAP_T, _wrapT); 75 glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter); 76 glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter); 77 glTexImage3D(_target, 0, _internalColorFormat, _width, _height, _depth, 0, _colorFormat, _type, data); 90 78 } 91 92 #endif
Note: See TracChangeset
for help on using the changeset viewer.