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

Last change on this file since 2844 was 2825, checked in by ldelgass, 12 years ago

A few further cleanups on vr3d

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
3#include <vr3d/vrTexture3D.h>
4
5vrTexture3D::vrTexture3D() :
6    _width(0),
7    _height(0),
8    _depth(0)
9{
10    _target = TT_TEXTURE_3D;
11    _wrapT = TW_CLAMP_TO_EDGE;
12    _wrapS = TW_CLAMP_TO_EDGE;
13}
14
15vrTexture3D::~vrTexture3D()
16{
17}
18
19void vrTexture3D::setPixels(COLORFORMAT colorFormat, DATATYPE type,
20                            int width, int height, int depth, void *data)
21{
22    setPixels(TT_TEXTURE_3D, colorFormat, colorFormat, type, width, height, depth, data);
23}
24
25void vrTexture3D::setPixels(TEXTARGET target,
26                            COLORFORMAT internalColorFormat,
27                            COLORFORMAT colorFormat,
28                            DATATYPE type,
29                            int width, int height, int depth, void *data)
30{
31    _target = target;
32    _width = width;
33    _height = height;
34    _depth = depth;
35    _type = type;
36    _internalColorFormat = internalColorFormat;
37    _colorFormat = colorFormat;
38    _compCount = GetNumComponent(_colorFormat);
39
40    if (_objectID) {
41        glDeleteTextures(1, &_objectID);
42    }
43
44    //glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
45    glGenTextures(1, &_objectID);
46    glBindTexture(_target, _objectID);
47    glTexImage3D(_target, 0, _internalColorFormat, _width, _height, _depth, 0, _colorFormat, _type, data) ;
48    glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
49    glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
50       
51    //TBD..
52    glTexParameterf(_target, GL_TEXTURE_WRAP_S, _wrapS);
53    glTexParameterf(_target, GL_TEXTURE_WRAP_T, _wrapT);
54}
55
56void vrTexture3D::updatePixels(void* data)
57{
58    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
59    glBindTexture(_target, _objectID);
60    glTexParameteri(_target, GL_TEXTURE_WRAP_S, _wrapS);
61    glTexParameteri(_target, GL_TEXTURE_WRAP_T, _wrapT);
62    glTexParameteri(_target, GL_TEXTURE_MAG_FILTER, _magFilter);
63    glTexParameteri(_target, GL_TEXTURE_MIN_FILTER, _minFilter);
64    glTexImage3D(_target, 0, _internalColorFormat, _width, _height, _depth, 0, _colorFormat, _type, data);
65}
Note: See TracBrowser for help on using the repository browser.