Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::DVRMtexLUTShader Class Reference

*put brief class description here* More...

#include <OSGDVRMtexLUTShader.h>

Inheritance diagram for osg::DVRMtexLUTShader:

osg::DVRMtexLUTShaderBase osg::DVRSimpleLUTShader osg::DVRSimpleLUTShaderBase osg::DVRSimpleShader osg::DVRSimpleShaderBase osg::DVRShader osg::DVRShaderBase osg::FieldContainer List of all members.

Public Types

typedef DVRMtexLUTShaderPtr Ptr
enum  { LutModeFieldId = Inherited::NextFieldId, ActiveLutModeFieldId = LutModeFieldId + 1, NextFieldId = ActiveLutModeFieldId + 1 }

Public Member Functions

Sync
*virtual void changed (BitVector whichField, UInt32 from)
 react to field changes
Output
*virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
 output the instance for debug purposes
Volume Rendering
*virtual bool initialize (DVRVolume *volume, DrawActionBase *action)
 callback to set up shader - register textures here
virtual void activate (DVRVolume *volume, DrawActionBase *action)
 callback before any slice is rendered - setup per volume
virtual void deactivate (DVRVolume *volume, DrawActionBase *action)
 callback after all rendering of the volume is done
virtual void renderSlice (DVRVolume *volume, DrawActionBase *action, Real32 *data, UInt32 vertices, UInt32 values)
 callback for rendering slices
virtual void renderSlice (DVRVolume *volume, DrawActionBase *action, DVRRenderSlice *clippedSlice)
virtual void cleanup (DVRVolume *volume, DrawActionBase *action)
 callback to clean up shader resources
virtual bool hasRenderCallback (void)
 callback to set up shader - register textures here
virtual bool useMTSlabs (void)
FieldContainer Get
*virtual FieldContainerTypegetType (void)
virtual const FieldContainerTypegetType (void) const
virtual UInt32 getContainerSize (void) const
Binary Access
*virtual UInt32 getBinSize (const BitVector &whichField)
virtual void copyToBin (BinaryDataHandler &pMem, const BitVector &whichField)
virtual void copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField)
Copy
*virtual FieldContainerPtr shallowCopy (void) const
Volume Rendering
virtual void brickActivate (DVRVolume *volume, DrawActionBase *action, Brick *brick)
 Callback before any brick - state setup per brick.

Static Public Member Functions

Class Get
*static FieldContainerTypegetClassType (void)
 access the type of the class
static UInt32 getClassTypeId (void)
 access the numerical type of the class
Construction
*static DVRMtexLUTShaderPtr create (void)
 create a new instance of the class
static DVRMtexLUTShaderPtr createEmpty (void)
 create an empty new instance of the class, do not copy the prototype

Static Public Attributes

static const osg::BitVector MTInfluenceMask
static const osg::BitVector LutModeFieldMask
static const osg::BitVector ActiveLutModeFieldMask
static const BitVector NextFieldMask

Protected Types

enum  LutMode {
  LM_AUTO = 0, LM_TABLE_SGI, LM_PALETTE_EXT, LM_DEPENDENT,
  LM_FRAGPROG, LM_RELOAD, LM_NO
}

Protected Member Functions

Constructors
DVRMtexLUTShader (void)
 Constructor.
 DVRMtexLUTShader (const DVRMtexLUTShader &source)
 Copy Constructor.
Destructors
*virtual ~DVRMtexLUTShader (void)
 Destructor.
Sync
*void executeSyncImpl (DVRMtexLUTShaderBase *pOther, const BitVector &whichField)
virtual void executeSync (FieldContainer &other, const BitVector &whichField)
Sync
*void executeSyncImpl (DVRSimpleLUTShaderBase *pOther, const BitVector &whichField)
Sync
*void executeSyncImpl (DVRSimpleShaderBase *pOther, const BitVector &whichField)
Sync
*void executeSyncImpl (DVRShaderBase *pOther, const BitVector &whichField)
Volume Rendering
*void getPaletteFormat (DrawActionBase *action, UInt8 lutMode, GLenum &internalFormat, GLenum &externalFormat)
 returns texture formate for selected lookup table mode
bool isModeSupported (DrawActionBase *action, UInt8 mode, Int8 textureMode)
 Checks whether the selected mode is supported.
UInt8 selectMode (DrawActionBase *action, Int8 textureMode)
 Automatically select a lookup table mode.
void enablePalette (void)
 enables lut
void disablePalette (void)
 diasables lut
void initDependentTexture (Int32 size)
 create dependent texture
void updateDependentTexture (Int32 size, const UInt8 *data)
 update dependent texture
void destroyDependentTexture (void)
 destroy dependent texture
void setupAlphaCorrectionRegisterCombiners (DrawActionBase *action)
Field Get
*SFInt8getSFLutMode (void)
 Get the DVRSimpleLUTShader::_sfLutMode field.
SFInt8getSFActiveLutMode (void)
 Get the DVRSimpleLUTShader::_sfActiveLutMode field.
Int8getLutMode (void)
 Get the value of the DVRSimpleLUTShader::_sfLutMode field.
const Int8getLutMode (void) const
 Get the value of the DVRSimpleLUTShader::_sfLutMode field.
Int8getActiveLutMode (void)
 Get the value of the DVRSimpleLUTShader::_sfActiveLutMode field.
const Int8getActiveLutMode (void) const
 Get the value of the DVRSimpleLUTShader::_sfActiveLutMode field.
Field Set
*void setLutMode (const Int8 &value)
 Set the value of the DVRSimpleLUTShader::_sfLutMode field.
void setActiveLutMode (const Int8 &value)
 Set the value of the DVRSimpleLUTShader::_sfActiveLutMode field.
Volume Rendering
*void getPaletteFormat (DrawActionBase *action, UInt8 lutMode, GLenum &internalFormat, GLenum &externalFormat)
 returns texture formate for selected lookup table mode
bool isModeSupported (DrawActionBase *action, UInt8 mode, Int8 textureMode)
 Checks whether the selected mode is supported.
UInt8 selectMode (DrawActionBase *action, Int8 textureMode)
 Automatically select a lookup table mode.
void enablePalette (void)
 enables lut
void disablePalette (void)
 diasables lut
void initDependentTexture (Int32 size)
 create dependent texture
void updateDependentTexture (Int32 size, const UInt8 *data)
 update dependent texture
void destroyDependentTexture (void)
 destroy dependent texture
void setupAlphaCorrectionRegisterCombiners (DrawActionBase *action)
Field Get
*SFInt8getSFLutMode (void)
 Get the DVRSimpleLUTShader::_sfLutMode field.
SFInt8getSFActiveLutMode (void)
 Get the DVRSimpleLUTShader::_sfActiveLutMode field.
Int8getLutMode (void)
 Get the value of the DVRSimpleLUTShader::_sfLutMode field.
const Int8getLutMode (void) const
 Get the value of the DVRSimpleLUTShader::_sfLutMode field.
Int8getActiveLutMode (void)
 Get the value of the DVRSimpleLUTShader::_sfActiveLutMode field.
const Int8getActiveLutMode (void) const
 Get the value of the DVRSimpleLUTShader::_sfActiveLutMode field.
Field Set
*void setLutMode (const Int8 &value)
 Set the value of the DVRSimpleLUTShader::_sfLutMode field.
void setActiveLutMode (const Int8 &value)
 Set the value of the DVRSimpleLUTShader::_sfActiveLutMode field.
Sync
*void executeSyncImpl (DVRSimpleShaderBase *pOther, const BitVector &whichField)
Sync
*void executeSyncImpl (DVRShaderBase *pOther, const BitVector &whichField)

Protected Attributes

UInt8 m_nTexturePaletteMode
Int8 m_nTextureMode
FragmentProgramChunkPtr m_pFragProg
TextureChunkPtr m_pDepTexture
Int32 m_nTextureId
Fields
*SFInt8 _sfLutMode
SFInt8 _sfActiveLutMode
Fields
*SFInt8 _sfLutMode
SFInt8 _sfActiveLutMode

Private Types

typedef DVRMtexLUTShaderBase Inherited

Private Member Functions

void operator= (const DVRMtexLUTShader &source)
Volume Rendering
*void initCombiners (DrawActionBase *action)
 set up correct register combiner state

Static Private Member Functions

static void initMethod (void)
 initialize the static features of the class, e.g. action callbacks

Static Private Attributes

static UInt32 _arbMultitexture
static UInt32 _nvRegisterCombiners
static UInt32 _funcMultiTexCoord2dARB
static UInt32 _funcCombinerParameteriNV
static UInt32 _funcCombinerParameterfvNV
static UInt32 _funcCombinerInputNV
static UInt32 _funcCombinerOutputNV
static UInt32 _funcFinalCombinerInputNV

Friends

class FieldContainer
class DVRMtexLUTShaderBase

Detailed Description

Abstract shader class - not to be instantiated. Is intended to be stateless - NO FIELDS!!

Definition at line 57 of file OSGDVRMtexLUTShader.h.


Member Typedef Documentation

typedef DVRMtexLUTShaderBase osg::DVRMtexLUTShader::Inherited [private]
 

Reimplemented from osg::DVRMtexLUTShaderBase.

Definition at line 61 of file OSGDVRMtexLUTShader.h.

typedef DVRMtexLUTShaderPtr osg::DVRMtexLUTShaderBase::Ptr [inherited]
 

Reimplemented from osg::DVRSimpleLUTShaderBase.

Definition at line 89 of file OSGDVRMtexLUTShaderBase.h.


Member Enumeration Documentation

enum osg::DVRSimpleLUTShader::LutMode [protected, inherited]
 

Enumerator:
LM_AUTO 
LM_TABLE_SGI 
LM_PALETTE_EXT 
LM_DEPENDENT 
LM_FRAGPROG 
LM_RELOAD 
LM_NO 

Definition at line 120 of file OSGDVRSimpleLUTShader.h.

00121     {
00122         LM_AUTO = 0,
00123         LM_TABLE_SGI,
00124         LM_PALETTE_EXT,
00125         LM_DEPENDENT,
00126         LM_FRAGPROG,
00127         LM_RELOAD,
00128         LM_NO
00129     };

anonymous enum [inherited]
 

Enumerator:
LutModeFieldId 
ActiveLutModeFieldId 
NextFieldId 

Reimplemented from osg::FieldContainer.

Definition at line 93 of file OSGDVRSimpleLUTShaderBase.h.

00094     {
00095         LutModeFieldId       = Inherited::NextFieldId,
00096         ActiveLutModeFieldId = LutModeFieldId       + 1,
00097         NextFieldId          = ActiveLutModeFieldId + 1
00098     };


Constructor & Destructor Documentation

DVRMtexLUTShader::DVRMtexLUTShader void   )  [protected]
 

Definition at line 105 of file OSGDVRMtexLUTShader.cpp.

References _arbMultitexture, _funcCombinerInputNV, _funcCombinerOutputNV, _funcCombinerParameterfvNV, _funcCombinerParameteriNV, _funcFinalCombinerInputNV, _funcMultiTexCoord2dARB, _nvRegisterCombiners, OSG_DLSYM_UNDERSCORE, osg::Window::registerExtension(), and osg::Window::registerFunction().

00105                                        :
00106     Inherited()
00107 {
00108     _arbMultitexture           = 
00109         Window::registerExtension( "GL_ARB_multitexture"     );
00110 
00111     _nvRegisterCombiners       = 
00112         Window::registerExtension( "GL_NV_register_combiners");
00113     
00114 
00115     _funcMultiTexCoord2dARB    = 
00116       Window::registerFunction (OSG_DLSYM_UNDERSCORE"glMultiTexCoord2dARB",
00117                                 _arbMultitexture);
00118 
00119     _funcCombinerParameteriNV  = 
00120       Window::registerFunction (OSG_DLSYM_UNDERSCORE"glCombinerParameteriNV",
00121                                 _nvRegisterCombiners);
00122 
00123     _funcCombinerParameterfvNV = 
00124       Window::registerFunction (OSG_DLSYM_UNDERSCORE"glCombinerParameterfvNV",
00125                                 _nvRegisterCombiners);
00126 
00127     _funcCombinerInputNV       = 
00128       Window::registerFunction (OSG_DLSYM_UNDERSCORE"glCombinerInputNV",
00129                                 _nvRegisterCombiners);
00130 
00131     _funcCombinerOutputNV      = 
00132       Window::registerFunction (OSG_DLSYM_UNDERSCORE"glCombinerOutputNV",
00133                                 _nvRegisterCombiners);
00134 
00135     _funcFinalCombinerInputNV  = 
00136       Window::registerFunction (OSG_DLSYM_UNDERSCORE"glFinalCombinerInputNV",
00137                                 _nvRegisterCombiners);
00138 }

DVRMtexLUTShader::DVRMtexLUTShader const DVRMtexLUTShader source  )  [protected]
 

Definition at line 141 of file OSGDVRMtexLUTShader.cpp.

00141                                                                  :
00142     Inherited(source)
00143 {
00144 }

DVRMtexLUTShader::~DVRMtexLUTShader void   )  [protected, virtual]
 

Definition at line 147 of file OSGDVRMtexLUTShader.cpp.

00148 {
00149 }


Member Function Documentation

void DVRMtexLUTShader::changed BitVector  whichField,
UInt32  from
[virtual]
 

Reimplemented from osg::DVRSimpleLUTShader.

Definition at line 159 of file OSGDVRMtexLUTShader.cpp.

References osg::DVRSimpleLUTShader::changed(), and SWARNING.

00160 {
00161     SWARNING << "DVRMtexLUTShader::changed" << std::endl;
00162     
00163     Inherited::changed(whichField, origin);
00164 }

void DVRMtexLUTShader::dump UInt32  uiIndent = 0,
const BitVector  bvFlags = 0
const [virtual]
 

Reimplemented from osg::DVRSimpleLUTShader.

Definition at line 168 of file OSGDVRMtexLUTShader.cpp.

References SLOG.

00170 {
00171     SLOG << "Dump DVRMtexLUTShader NI" << std::endl;
00172 }

bool DVRMtexLUTShader::initialize DVRVolume volume,
DrawActionBase action
[virtual]
 

Reimplemented from osg::DVRSimpleLUTShader.

Definition at line 175 of file OSGDVRMtexLUTShader.cpp.

References _arbMultitexture, _nvRegisterCombiners, DVRVOLUME_PARAMETER, FWARNING, osg::DVRSimpleLUTShaderBase::getLutMode(), osg::DVRSimpleLUTShader::getPaletteFormat(), osg::DVRVolume::getTextureManager(), osg::DVRVolume::getTextureMode(), osg::DrawActionBase::getWindow(), GLenum, osg::Window::hasExtension(), osg::DVRSimpleLUTShader::isModeSupported(), osg::DVRSimpleLUTShader::LM_AUTO, osg::DVRSimpleLUTShader::LM_NO, osg::DVRSimpleShader::m_nTextureId, osg::DVRSimpleLUTShader::m_nTexturePaletteMode, osg::NullFC, osg::TextureManager::registerTexture(), osg::DVRSimpleLUTShader::selectMode(), osg::DVRSimpleLUTShaderBase::setActiveLutMode(), and SWARNING.

00176 {
00177     //FDEBUG(("DVRMtexLUTShader::initialize\n"));
00178     FWARNING(("DVRMtexLUTShader::initialize\n"));
00179 
00180     GLenum nInternalFormat;
00181     GLenum nExternalFormat;
00182 
00183     Window *win = action->getWindow();
00184 
00185     // Determine lookup table mechanism
00186     if(getLutMode() != LM_AUTO)
00187     {
00188         // A certain mode has been selected
00189         if(isModeSupported(action, 
00190                            getLutMode(), 
00191                            volume->getTextureMode(win)) == true)
00192         {
00193             SWARNING << "DVRMtexLUTShader - User specified lookup table mode "
00194                      << int(getLutMode()) 
00195                      << std::endl;
00196 
00197             m_nTexturePaletteMode = getLutMode();
00198         }
00199         else
00200         {
00201             SWARNING << "DVRMtexLUTShader - Unsupported lookup table mode " 
00202                      << int(getLutMode()) 
00203                      << " disabling LUT" 
00204                      << std::endl;
00205 
00206             m_nTexturePaletteMode = LM_NO;
00207         }
00208     }
00209     else 
00210     {
00211         // Use automatic mode selection
00212         m_nTexturePaletteMode = selectMode(action, 
00213                                            volume->getTextureMode(win));
00214     }
00215 
00216     setActiveLutMode(m_nTexturePaletteMode);
00217 
00218     
00219     getPaletteFormat(action, 
00220                      m_nTexturePaletteMode, 
00221                      nInternalFormat, 
00222                      nExternalFormat      );
00223 
00224     DVRLookupTablePtr   lut = DVRVOLUME_PARAMETER(volume, DVRLookupTable);
00225     DVRVolumeTexturePtr vol = DVRVOLUME_PARAMETER(volume, DVRVolumeTexture);
00226 
00227     if((volume == NULL) || (vol == NullFC)) 
00228     {
00229         SWARNING << "NO Volume..." << std::endl;
00230         return false;
00231     }
00232 
00233     // This shader requires ARB_multitexture and 
00234     // NV_register_combiner extensions
00235 
00236     if(!action->getWindow()->hasExtension(_arbMultitexture))
00237     {
00238         SWARNING << "NO multi textures ..." << std::endl;
00239 
00240         return false;
00241     }
00242 
00243     SWARNING << "Multitextures found" << std::endl;
00244 
00245     if(!action->getWindow()->hasExtension(_nvRegisterCombiners))
00246     {
00247         SWARNING << "NO register combiners" << std::endl;
00248         return false;
00249     }
00250 
00251     SWARNING << "Register Combiners found" << std::endl;
00252     
00253     m_nTextureId = volume->getTextureManager().registerTexture(
00254         vol->getImage(), // image
00255         nInternalFormat, // internalFormat
00256         nExternalFormat, // externalFormat
00257         1,               // doBricking
00258         0,               // textureStage0
00259         1);              // textureStage1
00260     
00261     if(m_nTextureId == -1) 
00262     {
00263         SWARNING << "Error registering textures ..." << std::endl;
00264         return false;
00265     }
00266     else
00267     {
00268         SWARNING << "New texture Id: " << m_nTextureId << std::endl;
00269     }
00270     
00271     if(lut != NullFC)
00272         lut->setTouched(true); // force initialization in first render pass
00273 
00274     return true;
00275 }

void DVRMtexLUTShader::activate DVRVolume volume,
DrawActionBase action
[virtual]
 

Reimplemented from osg::DVRSimpleLUTShader.

Definition at line 279 of file OSGDVRMtexLUTShader.cpp.

References osg::DVRSimpleLUTShader::activate(), osg::DVRVolumeBase::getDoTextures(), GL_REGISTER_COMBINERS_NV, initCombiners(), and SWARNING.

00280 {
00281     //FDEBUG(("DVRMtexLUTShader::activate\n"));
00282 
00283 #if !defined(GL_ARB_multitexture) || !defined(GL_NV_register_combiners)
00284     SWARNING << "DVRtexLUTShader requires ARB_multitexture and "
00285              << "NV_register_combiners extensions" 
00286              << std::endl;
00287 
00288     volume = volume; action = action; // calm down compiler
00289 #else
00290     DVRSimpleLUTShader::activate(volume, action);
00291 
00292     if(volume->getDoTextures())
00293     {
00294         glEnable(GL_REGISTER_COMBINERS_NV);
00295 
00296         initCombiners(action);
00297     }
00298 #endif // required extensions available
00299 }

void DVRMtexLUTShader::deactivate DVRVolume volume,
DrawActionBase action
[virtual]
 

Reimplemented from osg::DVRSimpleLUTShader.

Definition at line 303 of file OSGDVRMtexLUTShader.cpp.

References osg::DVRSimpleLUTShader::deactivate(), osg::DVRVolumeBase::getDoTextures(), GL_REGISTER_COMBINERS_NV, and SWARNING.

00304 {
00305     //FDEBUG(("DVRMtexLUTShader::deactivate\n"));
00306 
00307 #if !defined(GL_ARB_multitexture) || !defined(GL_NV_register_combiners)
00308     SWARNING << "DVRtexLUTShader requires ARB_multitexture and " 
00309              << "NV_register_combiners extensions"
00310              << std::endl;
00311 
00312     volume = volume; action = action; // calm down compiler
00313 #else
00314     if (volume->getDoTextures())
00315     {
00316         glDisable(GL_REGISTER_COMBINERS_NV);
00317     }
00318     
00319     DVRSimpleLUTShader::deactivate(volume, action);
00320 #endif // required extensions available
00321 }

void DVRMtexLUTShader::renderSlice DVRVolume volume,
DrawActionBase action,
Real32 data,
UInt32  vertices,
UInt32  values
[virtual]
 

! TODO - alpha correction

Reimplemented from osg::DVRShader.

Definition at line 342 of file OSGDVRMtexLUTShader.cpp.

References _arbMultitexture, _funcCombinerParameterfvNV, _funcMultiTexCoord2dARB, _nvRegisterCombiners, osg::DVRVolumeBase::getDoTextures(), osg::Window::getFunction(), osg::DrawActionBase::getWindow(), GL_CONSTANT_COLOR0_NV, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, osg::Window::hasExtension(), and SWARNING.

00347 {
00348 #if !defined(GL_ARB_multitexture) || !defined(GL_NV_register_combiners)
00349     SWARNING << "DVRtexLUTShader requires ARB_multitexture and "
00350              << "NV_register_combiners extensions" 
00351              << std::endl;
00352 
00353     volume   = volume;   action = action; data = data; // calm down compiler
00354     vertices = vertices; values = values; 
00355 #else
00356     Window *win = action->getWindow();
00357 
00358     if(!win->hasExtension(_nvRegisterCombiners) ||
00359        !win->hasExtension(_arbMultitexture))
00360     {
00361         return;
00362     }
00363 
00364     CombinerParameterfvNVFunc CombinerParameterfvNV = 
00365         (CombinerParameterfvNVFunc) win->getFunction(
00366             _funcCombinerParameterfvNV);
00367 
00368     MultiTexCoord2dARBFunc MultiTexCoord2dARB = 
00369         (MultiTexCoord2dARBFunc) win->getFunction(_funcMultiTexCoord2dARB); 
00370     
00371     //FINFO(("DVRMtexLUTShader::renderSlice - vert(%d) - values(%d)\n", 
00372     //       vertices, values));
00373     
00374     if(values < 6)
00375     {
00376         SWARNING << "DVRMtexLUTShader::renderSlice - insufficient values" 
00377                  << std::endl;
00378         return;
00379     }
00380     
00381     
00382     float col[4] = 
00383     { 
00384         0.f, 0.f, 0.f, data[5]
00385     };
00386 
00387     CombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, col);
00388 
00389     glFogfv(GL_FOG_COLOR, col);
00390 
00391     if(volume->getDoTextures())
00392     {
00393         glBegin(GL_TRIANGLE_FAN);
00394     }
00395     else
00396     {
00398         glColor4f(1.0, 1.0, 1.0, 1.0);
00399 
00400         glBegin(GL_LINE_LOOP);
00401     }
00402 
00403     
00404     for(UInt32 i = 0; i < vertices; i++)
00405     {
00406         Real32 *vert = data + i *values;
00407         
00408     // constant color is used as blending factor between tex0 and tex1
00409     // a == 0 means tex0
00410     // a == 1 means tex1 
00411     // float col[4] = {0, 0, 0, vert[5]};
00412     // CombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, col);
00413       
00414         MultiTexCoord2dARB(GL_TEXTURE0_ARB, vert[3], vert[4]);
00415         MultiTexCoord2dARB(GL_TEXTURE1_ARB, vert[3], vert[4]);
00416         
00417         glVertex3f(vert[0], vert[1], vert[2]);  
00418         
00419     }
00420     glEnd();
00421     
00422 #endif // required extensions
00423 }

void DVRMtexLUTShader::renderSlice DVRVolume volume,
DrawActionBase action,
DVRRenderSlice clippedSlice
[virtual]
 

! TODO - alpha correction

Reimplemented from osg::DVRShader.

Definition at line 426 of file OSGDVRMtexLUTShader.cpp.

References _arbMultitexture, _funcCombinerParameterfvNV, _funcMultiTexCoord2dARB, _nvRegisterCombiners, osg::DVRVolumeBase::getDoTextures(), osg::Window::getFunction(), osg::DrawActionBase::getWindow(), GL_CONSTANT_COLOR0_NV, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, osg::Window::hasExtension(), osg::DVRRenderSlice::orientation, SWARNING, osg::DVRRenderSlice::XY, osg::DVRRenderSlice::XZ, and osg::DVRRenderSlice::YZ.

00429 {
00430 #if !defined(GL_ARB_multitexture) || !defined(GL_NV_register_combiners)
00431     SWARNING << "DVRtexLUTShader requires ARB_multitexture and "
00432              << "NV_register_combiners extensions" 
00433              << std::endl;
00434 
00435     volume       = volume; 
00436     action       = action; 
00437     clippedSlice = clippedSlice; // calm down compiler
00438 #else
00439 
00440     Window *win = action->getWindow();
00441 
00442     if(!win->hasExtension(_nvRegisterCombiners) ||
00443        !win->hasExtension(_arbMultitexture))
00444     {
00445         return;
00446     }
00447 
00448     CombinerParameterfvNVFunc CombinerParameterfvNV =
00449         (CombinerParameterfvNVFunc) win->getFunction(
00450             _funcCombinerParameterfvNV);
00451 
00452     MultiTexCoord2dARBFunc MultiTexCoord2dARB = 
00453         (MultiTexCoord2dARBFunc) win->getFunction(_funcMultiTexCoord2dARB); 
00454    
00455     GLfloat intFactor = 0;
00456     
00457     switch(clippedSlice->orientation)
00458     {
00459         case DVRRenderSlice::XY:
00460             intFactor = 
00461                 Real32((*(*clippedSlice->begin())->vertices.begin())[5]);
00462             break;
00463 
00464         case DVRRenderSlice::XZ:
00465             intFactor = 
00466                 Real32((*(*clippedSlice->begin())->vertices.begin())[4]);
00467             break;
00468 
00469         case DVRRenderSlice::YZ:
00470             intFactor = 
00471                 Real32((*(*clippedSlice->begin())->vertices.begin())[3]);
00472             break;
00473 
00474         default:
00475             break;
00476     }
00477 
00478     if(intFactor < 0 || intFactor > 1)
00479         std::cerr << intFactor << std::endl;
00480     
00481     float col[4] = 
00482     {
00483         0.f, 0.f, 0.f, intFactor
00484     };
00485 
00486     CombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, col);
00487 
00488     glFogfv(GL_FOG_COLOR, col);
00489 
00490     if(volume->getDoTextures())
00491     {
00492         //glBegin(GL_TRIANGLE_FAN);
00493     }
00494     else
00495     {
00497         glColor4f(1.0, 1.0, 1.0, 1.0);
00498         //glBegin(GL_LINE_LOOP);
00499     }
00500 
00501     switch(clippedSlice->orientation)
00502     {
00503         case DVRRenderSlice::XY:
00504 
00505             for(std::vector<DVRRenderSlicePrimitive *>::const_iterator prim = 
00506                     clippedSlice->begin();
00507 
00508                   prim != clippedSlice->end();
00509                 ++prim)
00510             {
00511                 glBegin((*prim)->type);
00512                 
00513                 std::vector<GLdouble *>::const_iterator vert = 
00514                     (*prim)->vertices.begin();        
00515 
00516                 for(; vert != (*prim)->vertices.end(); ++vert)
00517                 {
00518                     MultiTexCoord2dARB(GL_TEXTURE0_ARB, 
00519                                        (*vert)[3], 
00520                                        (*vert)[4]);
00521 
00522                     MultiTexCoord2dARB(GL_TEXTURE1_ARB, 
00523                                        (*vert)[3], 
00524                                        (*vert)[4]);
00525 
00526                     glVertex3dv(*vert);
00527                 }      
00528                 glEnd();
00529             }     
00530             break;
00531 
00532         case DVRRenderSlice::XZ:
00533 
00534             for(std::vector<DVRRenderSlicePrimitive *>::const_iterator prim = 
00535                     clippedSlice->begin();
00536  
00537                   prim != clippedSlice->end();
00538                 ++prim)
00539             {
00540                 glBegin((*prim)->type);
00541                 
00542                 std::vector<GLdouble *>::const_iterator vert = 
00543                     (*prim)->vertices.begin();        
00544 
00545                 for(; vert != (*prim)->vertices.end(); vert++)
00546                 {
00547                     MultiTexCoord2dARB(GL_TEXTURE0_ARB, 
00548                                        (*vert)[3], 
00549                                        (*vert)[5]);
00550                     MultiTexCoord2dARB(GL_TEXTURE1_ARB, 
00551                                        (*vert)[3], 
00552                                        (*vert)[5]);
00553 
00554                     glVertex3dv(*vert);
00555                 }      
00556                 glEnd();
00557             }     
00558             break;
00559 
00560         case DVRRenderSlice::YZ:
00561             
00562             for(std::vector<DVRRenderSlicePrimitive*>::const_iterator prim = 
00563                     clippedSlice->begin();
00564 
00565                   prim != clippedSlice->end();
00566                 ++prim)
00567             {
00568                 glBegin((*prim)->type);
00569    
00570                 std::vector<GLdouble*>::const_iterator vert = 
00571                     (*prim)->vertices.begin();        
00572 
00573                 for(; vert != (*prim)->vertices.end(); vert++)
00574                 {
00575                     MultiTexCoord2dARB(GL_TEXTURE0_ARB, 
00576                                        (*vert)[4], 
00577                                        (*vert)[5]);
00578 
00579                     MultiTexCoord2dARB(GL_TEXTURE1_ARB, 
00580                                        (*vert)[4], 
00581                                        (*vert)[5]);
00582                     glVertex3dv(*vert);
00583                 }      
00584                 glEnd();
00585             }
00586             break;
00587 
00588         default:
00589             break;
00590     }
00591 #endif // required extensions
00592 }

void DVRMtexLUTShader::cleanup DVRVolume volume,
DrawActionBase action
[virtual]
 

Reimplemented from osg::DVRSimpleLUTShader.

Definition at line 324 of file OSGDVRMtexLUTShader.cpp.

References osg::DVRVolume::getTextureManager(), osg::DVRSimpleShader::m_nTextureId, and osg::TextureManager::unregisterTexture().

00325 {
00326     if(volume != NULL)
00327     {
00328         if(m_nTextureId != -1)
00329             volume->getTextureManager().unregisterTexture(m_nTextureId);
00330     }
00331 }

bool DVRMtexLUTShader::hasRenderCallback void   )  [virtual]
 

Reimplemented from osg::DVRShader.

Definition at line 92 of file OSGDVRMtexLUTShader.cpp.

00093 {
00094     return true; 
00095 }

bool DVRMtexLUTShader::useMTSlabs void   )  [virtual]
 

Reimplemented from osg::DVRShader.

Definition at line 97 of file OSGDVRMtexLUTShader.cpp.

00098 {
00099     return true; 
00100 } 

void DVRMtexLUTShader::initCombiners DrawActionBase action  )  [private]
 

Definition at line 621 of file OSGDVRMtexLUTShader.cpp.

References _arbMultitexture, _funcCombinerInputNV, _funcCombinerOutputNV, _funcCombinerParameteriNV, _funcFinalCombinerInputNV, _nvRe