Ignore:
Timestamp:
Mar 15, 2012 11:46:42 PM (8 years ago)
Author:
ldelgass
Message:

Remove vr3d library - texture classes were redundant. Remove last vestiges of
opencv usage in code and remove from configure - replaced by imgLoaders library
functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Texture3D.cpp

    r2831 r2857  
    2424
    2525Texture3D::Texture3D() :
    26     gl_resource_allocated(false),
    27     id(0)
     26    _width(0),
     27    _height(0),
     28    _depth(0),
     29    _numComponents(3),
     30    _glResourceAllocated(false),
     31    _id(0),
     32    _type(GL_FLOAT),
     33    _interpType(GL_LINEAR),
     34    _wrapS(GL_CLAMP_TO_EDGE),
     35    _wrapT(GL_CLAMP_TO_EDGE),
     36    _wrapR(GL_CLAMP_TO_EDGE)
    2837{}
    2938
     
    3140                     GLuint type, GLuint interp,
    3241                     int numComponents, void *data) :
    33     gl_resource_allocated(false),
    34     id(0)
     42    _width(width),
     43    _height(height),
     44    _depth(depth),
     45    _numComponents(numComponents),
     46    _glResourceAllocated(false),
     47    _id(0),
     48    _type(type),
     49    _interpType(interp),
     50    _wrapS(GL_CLAMP_TO_EDGE),
     51    _wrapT(GL_CLAMP_TO_EDGE),
     52    _wrapR(GL_CLAMP_TO_EDGE)
    3553{
    36     this->width = width;
    37     this->height = height;
    38     this->depth = depth;
     54    //int m = (_width > _height) ? _width : _height;
     55    //m = (m > _depth) ? m : _depth;
    3956
    40     //int m = (width > height) ? width : height;
    41     //m = (m > depth) ? m : depth;
     57    //int m = max(max(_width, _height), _depth);
     58    _aspectRatioWidth = 1.;
     59    _aspectRatioHeight = (double)_height/(double)_width;
     60    _aspectRatioDepth = (double)_depth/(double)_width;
    4261
    43     //int m = max(max(width, height), depth);
    44     this->aspect_ratio_width = 1.;
    45     this->aspect_ratio_height = (double)height/(double)width;
    46     this->aspect_ratio_depth = (double)depth/(double)width;
    47 
    48     //this->aspect_ratio_width = (double)width/(double)m;
    49     //this->aspect_ratio_height = (double)height/(double)m;
    50     //this->aspect_ratio_depth = (double)depth/(double)m;
    51 
    52     this->type = type;
    53     this->interp_type = interp;
    54     this->n_components = numComponents;
     62    //_aspectRatioWidth = (double)_width/(double)m;
     63    //_aspectRatioHeight = (double)_height/(double)m;
     64    //_aspectRatioDepth = (double)_depth/(double)m;
    5565
    5666    if (data != NULL)
     
    6070Texture3D::~Texture3D()
    6171{
    62     glDeleteTextures(1, &id);
     72    glDeleteTextures(1, &_id);
    6373}
    6474
    6575GLuint Texture3D::initialize(void *data)
    6676{
    67     if (id != 0)
    68         glDeleteTextures(1, &id);
     77    if (_glResourceAllocated)
     78        glDeleteTextures(1, &_id);
    6979
    70     glGenTextures(1, &id);
     80    glGenTextures(1, &_id);
    7181
    7282    update(data);
    73  
    74     return id;
     83
     84    _glResourceAllocated = true;
     85    return _id;
    7586}
    7687
    7788void Texture3D::update(void *data)
    7889{
    79     assert(id > 0 && id != (GLuint)-1);
    80     glBindTexture(GL_TEXTURE_3D, id);
     90    glBindTexture(GL_TEXTURE_3D, _id);
    8191
    8292    //load texture with 16 bit half floating point precision if card is 6 series NV40
     
    8595    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    8696
    87     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    88     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    89     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
     97    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, _wrapS);
     98    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, _wrapT);
     99    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, _wrapR);
    90100
    91     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, interp_type);
    92     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, interp_type);
     101    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, _interpType);
     102    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, _interpType);
    93103
    94104    //to do: add handling to more formats
    95105#ifdef NV40
    96     if (type == GL_FLOAT) {
     106    if (_type == GL_FLOAT) {
    97107        GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
    98108        GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    99         glTexImage3D(GL_TEXTURE_3D, 0, targetFormat[n_components],
    100                      width, height, depth, 0,
    101                      format[n_components], type, data);
     109        glTexImage3D(GL_TEXTURE_3D, 0, targetFormat[_numComponents],
     110                     _width, _height, _depth, 0,
     111                     format[_numComponents], _type, data);
    102112    } else {
    103113#endif
    104114        GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    105         glTexImage3D(GL_TEXTURE_3D, 0, format[n_components],
    106                      width, height, depth, 0,
    107                      format[n_components], type, data);
     115        glTexImage3D(GL_TEXTURE_3D, 0, format[_numComponents],
     116                     _width, _height, _depth, 0,
     117                     format[_numComponents], _type, data);
    108118#ifdef NV40
    109119    }
     
    111121
    112122    assert(glGetError()==0);
    113 
    114     gl_resource_allocated = true;
    115123}
    116124
     
    118126{
    119127    glEnable(GL_TEXTURE_3D);
    120     glBindTexture(GL_TEXTURE_3D, id);
     128    glBindTexture(GL_TEXTURE_3D, _id);
    121129}
    122130
     
    124132{
    125133    glDisable(GL_TEXTURE_3D);           
     134}
     135
     136void Texture3D::setWrapS(GLuint wrapMode)
     137{
     138    _wrapS = wrapMode;
     139}
     140
     141void Texture3D::setWrapT(GLuint wrapMode)
     142{
     143    _wrapT = wrapMode;
     144}
     145
     146void Texture3D::setWrapR(GLuint wrapMode)
     147{
     148    _wrapR = wrapMode;
    126149}
    127150
Note: See TracChangeset for help on using the changeset viewer.