Ignore:
Timestamp:
Mar 23, 2012, 1:31:05 AM (13 years ago)
Author:
ldelgass
Message:

Some minor refactoring, also add some more fine grained config.h defines
(e.g. replace NV40 define with feature defines). Add tests for some required
OpenGL extensions (should always check for extensions or base version before
calling entry points from the extension). Also, clamp diffuse and specular
values on input and warn when they are out of range.

File:
1 edited

Legend:

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

    r2857 r2877  
    8888void Texture3D::update(void *data)
    8989{
     90    static GLuint floatFormats[] = { -1, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGB32F_ARB, GL_RGBA32F_ARB };
     91    static GLuint halfFloatFormats[] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
     92    static GLuint basicFormats[] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
     93
    9094    glBindTexture(GL_TEXTURE_3D, _id);
    9195
    92     //load texture with 16 bit half floating point precision if card is 6 series NV40
    93     //half float with linear interpolation is only supported by 6 series and up cards
    94     //If NV40 not defined, data is quantized to 8-bit from 32-bit.
    9596    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    9697
     
    103104
    104105    //to do: add handling to more formats
    105 #ifdef NV40
     106    GLuint *targetFormats;
     107#ifdef HAVE_FLOAT_TEXTURES
    106108    if (_type == GL_FLOAT) {
    107         GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB };
    108         GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    109         glTexImage3D(GL_TEXTURE_3D, 0, targetFormat[_numComponents],
    110                      _width, _height, _depth, 0,
    111                      format[_numComponents], _type, data);
     109# ifdef USE_HALF_FLOAT
     110        targetFormats = halfFloatFormats;
     111# else
     112        targetFormats = floatFormats;
     113# endif
    112114    } else {
    113115#endif
    114         GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
    115         glTexImage3D(GL_TEXTURE_3D, 0, format[_numComponents],
    116                      _width, _height, _depth, 0,
    117                      format[_numComponents], _type, data);
    118 #ifdef NV40
     116        targetFormats = basicFormats;
     117#ifdef HAVE_FLOAT_TEXTURES
    119118    }
    120119#endif
     120
     121    glTexImage3D(GL_TEXTURE_3D, 0, targetFormats[_numComponents],
     122                 _width, _height, _depth, 0,
     123                 basicFormats[_numComponents], _type, data);
    121124
    122125    assert(glGetError()==0);
Note: See TracChangeset for help on using the changeset viewer.