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

osg::DisplayCalibration Class Reference

DisplayCalibration class. See PageSystemDisplayCalibration for a description. More...

#include <OSGDisplayCalibration.h>

Inheritance diagram for osg::DisplayCalibration:

osg::DisplayCalibrationBase osg::AttachmentContainer osg::FieldContainer List of all members.

Public Types

typedef DisplayCalibrationPtr Ptr
enum  {
  EnabledFieldId = Inherited::NextFieldId, ServerFieldId = EnabledFieldId + 1, ColorMatrixFieldId = ServerFieldId + 1, GammaFieldId = ColorMatrixFieldId + 1,
  GammaRampFieldId = GammaFieldId + 1, GridWidthFieldId = GammaRampFieldId + 1, GridHeightFieldId = GridWidthFieldId + 1, GridFieldId = GridHeightFieldId + 1,
  ScaleDownFieldId = GridFieldId + 1, NextFieldId = ScaleDownFieldId + 1
}

Public Member Functions

calibration
*virtual void calibrate (WindowPtr window, RenderActionBase *ract)
Sync
*virtual void changed (BitVector whichField, UInt32 origin)
Output
*virtual void dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const
FieldContainer Get
*virtual FieldContainerTypegetType (void)
virtual const FieldContainerTypegetType (void) const
virtual UInt32 getContainerSize (void) const
Field Get
*SFBoolgetSFEnabled (void)
 Get the DisplayCalibration::_sfEnabled field.
SFStringgetSFServer (void)
 Get the DisplayCalibration::_sfServer field.
SFMatrixgetSFColorMatrix (void)
 Get the DisplayCalibration::_sfColorMatrix field.
SFReal32getSFGamma (void)
 Get the DisplayCalibration::_sfGamma field.
MFColor3fgetMFGammaRamp (void)
 Get the DisplayCalibration::_mfGammaRamp field.
SFUInt32getSFGridWidth (void)
 Get the DisplayCalibration::_sfGridWidth field.
SFUInt32getSFGridHeight (void)
 Get the DisplayCalibration::_sfGridHeight field.
MFVec2fgetMFGrid (void)
 Get the DisplayCalibration::_mfGrid field.
SFReal32getSFScaleDown (void)
 Get the DisplayCalibration::_sfScaleDown field.
bool & getEnabled (void)
 Get the value of the DisplayCalibration::_sfEnabled field.
const bool & getEnabled (void) const
 Get the value of the DisplayCalibration::_sfEnabled field.
std::string & getServer (void)
 Get the value of the DisplayCalibration::_sfServer field.
const std::string & getServer (void) const
 Get the value of the DisplayCalibration::_sfServer field.
MatrixgetColorMatrix (void)
 Get the value of the DisplayCalibration::_sfColorMatrix field.
const MatrixgetColorMatrix (void) const
 Get the value of the DisplayCalibration::_sfColorMatrix field.
Real32getGamma (void)
 Get the value of the DisplayCalibration::_sfGamma field.
const Real32getGamma (void) const
 Get the value of the DisplayCalibration::_sfGamma field.
UInt32getGridWidth (void)
 Get the value of the DisplayCalibration::_sfGridWidth field.
const UInt32getGridWidth (void) const
 Get the value of the DisplayCalibration::_sfGridWidth field.
UInt32getGridHeight (void)
 Get the value of the DisplayCalibration::_sfGridHeight field.
const UInt32getGridHeight (void) const
 Get the value of the DisplayCalibration::_sfGridHeight field.
Real32getScaleDown (void)
 Get the value of the DisplayCalibration::_sfScaleDown field.
const Real32getScaleDown (void) const
 Get the value of the DisplayCalibration::_sfScaleDown field.
Color3fgetGammaRamp (const UInt32 index)
 Get the value of the index element the DisplayCalibration::_mfGammaRamp field.
MFColor3fgetGammaRamp (void)
 Get the DisplayCalibration::_mfGammaRamp field.
const MFColor3fgetGammaRamp (void) const
 Get the DisplayCalibration::_mfGammaRamp field.
Vec2fgetGrid (const UInt32 index)
 Get the value of the index element the DisplayCalibration::_mfGrid field.
MFVec2fgetGrid (void)
 Get the DisplayCalibration::_mfGrid field.
const MFVec2fgetGrid (void) const
 Get the DisplayCalibration::_mfGrid field.
Field Set
*void setEnabled (const bool &value)
 Set the value of the DisplayCalibration::_sfEnabled field.
void setServer (const std::string &value)
 Set the value of the DisplayCalibration::_sfServer field.
void setColorMatrix (const Matrix &value)
 Set the value of the DisplayCalibration::_sfColorMatrix field.
void setGamma (const Real32 &value)
 Set the value of the DisplayCalibration::_sfGamma field.
void setGridWidth (const UInt32 &value)
 Set the value of the DisplayCalibration::_sfGridWidth field.
void setGridHeight (const UInt32 &value)
 Set the value of the DisplayCalibration::_sfGridHeight field.
void setScaleDown (const Real32 &value)
 Set the value of the DisplayCalibration::_sfScaleDown field.
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

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 DisplayCalibrationPtr create (void)
 create a new instance of the class
static DisplayCalibrationPtr createEmpty (void)
 create an empty new instance of the class, do not copy the prototype

Static Public Attributes

static const osg::BitVector EnabledFieldMask
static const osg::BitVector ServerFieldMask
static const osg::BitVector ColorMatrixFieldMask
static const osg::BitVector GammaFieldMask
static const osg::BitVector GammaRampFieldMask
static const osg::BitVector GridWidthFieldMask
static const osg::BitVector GridHeightFieldMask
static const osg::BitVector GridFieldMask
static const osg::BitVector ScaleDownFieldMask
static const osg::BitVector MTInfluenceMask
static const BitVector AttachmentsFieldMask
static const BitVector NextFieldMask
CoredNodePtr helper
static const bool isNodeCore = false

Protected Member Functions

Constructors
DisplayCalibration (void)
 DisplayCalibration (const DisplayCalibration &source)
Destructors
*virtual ~DisplayCalibration (void)
helper
*void createCMViewports (WindowPtr window)
void updateMatrix ()
void updateGamma ()
void updateGrid (WindowPtr window)
void createPincushionGrid ()
Sync
*void executeSyncImpl (DisplayCalibrationBase *pOther, const BitVector &whichField)
virtual void executeSync (FieldContainer &other, const BitVector &whichField)
MT Destruction
*virtual void onDestroy (void)

Protected Attributes

bool _useFragmentProgram
bool _changed
GeometryPtr _scalegeo
GeoPositions3fPtr _positions
GeoTexCoords2fPtr _texcoords
GeoPositions3fPtr _positionsScale
GeoTexCoords2fPtr _texcoordsScale
ImagePtr _rgammaimg
TextureChunkPtr _rgammachunk
ImagePtr _ggammaimg
TextureChunkPtr _ggammachunk
ImagePtr _bgammaimg
TextureChunkPtr _bgammachunk
ImagePtr _argammaimg
TextureChunkPtr _argammachunk
ImagePtr _gbgammaimg
TextureChunkPtr _gbgammachunk
FragmentProgramChunkPtr _fragProgram
RegisterCombinersChunkPtr _regCombiner
ViewportPtr _cmPort
ViewportPtr _dsPort
ViewportPtr _dsPort2
NodePtr _cmRoot
NodePtr _dsRoot
NodePtr _ds2Root
MatrixCameraPtr _cam
TextureGrabBackgroundPtr _cmBack
TextureGrabBackgroundPtr _dsBack
SolidBackgroundPtr _ds2Back
UInt32 _winWidth
UInt32 _winHeight
Fields
*SFBool _sfEnabled
SFString _sfServer
SFMatrix _sfColorMatrix
SFReal32 _sfGamma
MFColor3f _mfGammaRamp
SFUInt32 _sfGridWidth
SFUInt32 _sfGridHeight
MFVec2f _mfGrid
SFReal32 _sfScaleDown

Private Types

typedef DisplayCalibrationBase Inherited

Private Member Functions

void operator= (const DisplayCalibration &source)

Static Private Member Functions

static void initMethod (void)

Friends

class FieldContainer
class DisplayCalibrationBase

Detailed Description

The DisplayCalibration is responsible to calibrate a cluster window

Definition at line 69 of file OSGDisplayCalibration.h.


Member Typedef Documentation

typedef DisplayCalibrationBase osg::DisplayCalibration::Inherited [private]
 

Reimplemented from osg::DisplayCalibrationBase.

Definition at line 73 of file OSGDisplayCalibration.h.

typedef DisplayCalibrationPtr osg::DisplayCalibrationBase::Ptr [inherited]
 

Definition at line 98 of file OSGDisplayCalibrationBase.h.


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumerator:
EnabledFieldId 
ServerFieldId 
ColorMatrixFieldId 
GammaFieldId 
GammaRampFieldId 
GridWidthFieldId 
GridHeightFieldId 
GridFieldId 
ScaleDownFieldId 
NextFieldId 

Reimplemented from osg::AttachmentContainer.

Definition at line 100 of file OSGDisplayCalibrationBase.h.

00101     {
00102         EnabledFieldId     = Inherited::NextFieldId,
00103         ServerFieldId      = EnabledFieldId     + 1,
00104         ColorMatrixFieldId = ServerFieldId      + 1,
00105         GammaFieldId       = ColorMatrixFieldId + 1,
00106         GammaRampFieldId   = GammaFieldId       + 1,
00107         GridWidthFieldId   = GammaRampFieldId   + 1,
00108         GridHeightFieldId  = GridWidthFieldId   + 1,
00109         GridFieldId        = GridHeightFieldId  + 1,
00110         ScaleDownFieldId   = GridFieldId        + 1,
00111         NextFieldId        = ScaleDownFieldId   + 1
00112     };


Constructor & Destructor Documentation

DisplayCalibration::DisplayCalibration void   )  [protected]
 

Definition at line 85 of file OSGDisplayCalibration.cpp.

00085                                            :
00086     Inherited(),
00087     _changed(true),
00088     _cmPort(NullFC),
00089     _dsPort(NullFC),
00090     _dsPort2(NullFC)
00091 {
00092 }

DisplayCalibration::DisplayCalibration const DisplayCalibration source  )  [protected]
 

Definition at line 94 of file OSGDisplayCalibration.cpp.

00094                                                                        :
00095     Inherited(source),
00096     _changed(true),
00097     _cmPort(NullFC),
00098     _dsPort(NullFC),
00099     _dsPort2(NullFC)
00100 {
00101 }

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

Definition at line 103 of file OSGDisplayCalibration.cpp.

References _cam, _cmPort, _cmRoot, _ds2Back, _ds2Root, _dsBack, _dsPort, _dsPort2, _dsRoot, osg::NullFC, and osg::subRefCP().

00104 {
00105     if(_cmPort != osg::NullFC) 
00106     {
00107         subRefCP(_cmPort);
00108         subRefCP(_dsPort);
00109         subRefCP(_dsPort2);
00110         subRefCP(_cmRoot);
00111         subRefCP(_dsRoot);
00112         subRefCP(_ds2Root);
00113         subRefCP(_cam);
00114         subRefCP(_dsBack);
00115         subRefCP(_ds2Back);
00116     }
00117 }


Member Function Documentation

void DisplayCalibration::calibrate WindowPtr  window,
RenderActionBase ract
[virtual]
 

Calibrate display

Definition at line 123 of file OSGDisplayCalibration.cpp.

References _cmPort, _dsPort, _dsPort2, createCMViewports(), osg::DisplayCalibrationBase::getEnabled(), and osg::DisplayCalibrationBase::getScaleDown().

00124 {
00125     if(!getEnabled())
00126         return;
00127 
00128     createCMViewports(window);
00129 
00130     window->addPort(_cmPort);
00131     _cmPort->render(ract);
00132     window->subPort(_cmPort);
00133 
00134     if(getScaleDown() < 1.0f)
00135     {
00136         window->addPort(_dsPort);
00137         _dsPort->render(ract);
00138         window->subPort(_dsPort);
00139         window->addPort(_dsPort2);
00140         _dsPort2->render(ract);
00141         window->subPort(_dsPort2);
00142     }
00143 
00144 }

void DisplayCalibration::changed BitVector  whichField,
UInt32  origin
[virtual]
 

Reimplemented from osg::AttachmentContainer.

Definition at line 146 of file OSGDisplayCalibration.cpp.

References _changed, and osg::AttachmentContainer::changed().

00147 {
00148     _changed = true;
00149     Inherited::changed(whichField, origin);
00150 }

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

Reimplemented from osg::AttachmentContainer.

Definition at line 152 of file OSGDisplayCalibration.cpp.

References SLOG.

00154 {
00155     SLOG << "Dump DisplayCalibration NI" << std::endl;
00156 }

void DisplayCalibration::createCMViewports WindowPtr  window  )  [protected]
 

Definition at line 158 of file OSGDisplayCalibration.cpp.

References _argammachunk, _argammaimg, _bgammachunk, _bgammaimg, _cam, _changed, _cmBack, _cmPort, _cmRoot, _ds2Back, _ds2Root, _dsBack, _dsPort, _dsPort2, _dsRoot, _fragProgram, _gbgammachunk, _gbgammaimg, _ggammachunk, _ggammaimg, _positions, _positionsScale, _regCombiner, _rgammachunk, _rgammaimg, _texcoords, _texcoordsScale, _useFragmentProgram, _winHeight, _winWidth, osg::addRefCP(), osg::beginEditCP(), osg::MaterialChunkBase::create(), osg::SolidBackgroundBase::create(), osg::ViewportBase::create(), osg::TextureGrabBackgroundBase::create(), osg::MatrixCameraBase::create(), osg::GroupBase::create(), osg::ComponentTransformBase::create(), osg::Node::create(), osg::GeometryBase::create(), osg::GeoProperty< GeoPropertyDesc >::create(), osg::ChunkMaterialBase::create(), osg::RegisterCombinersChunkBase::create(), osg::FragmentProgramChunkBase::create(), osg::TextureChunkBase::create(), osg::ImageBase::create(), osg::endEditCP(), osg::DisplayCalibrationBase::getGammaRamp(), osg::DisplayCalibrationBase::getGrid(), osg::DisplayCalibrationBase::getGridHeight(), osg::DisplayCalibrationBase::getGridWidth(), osg::DisplayCalibrationBase::getScaleDown(), GL_CLAMP_TO_EDGE, GL_DEPENDENT_AR_TEXTURE_2D_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV, GL_TEXTURE0_ARB, osg::TransformationMatrix< Real32 >::identity(), osg::makePlane(), osg::NullFC, osg::Image::OSG_L_PF, osg::osgnextpower2(), p, osg::Window::registerExtension(), osg::DisplayCalibrationBase::setScaleDown(), osg::TransformationMatrix< ValueTypeT >::setValue(), SINFO, osg::MField< FieldTypeT, fieldNameSpace >::size(), osg::subRefCP(), updateGamma(), and updateMatrix().

Referenced by calibrate().

00159 {
00160     // create color management structures
00161     if(_cmPort != osg::NullFC &&
00162        !_changed &&
00163        _winWidth == window->getWidth() &&
00164        _winHeight == window->getHeight())
00165         return;
00166 
00167     if(getScaleDown()>1.0)
00168         setScaleDown(1.0);
00169 
00170     _changed = false;
00171     _winWidth = window->getWidth();
00172     _winHeight = window->getHeight();
00173 
00174     // reset
00175     if(_cmPort != osg::NullFC) {
00176         subRefCP(_cmPort);
00177         subRefCP(_dsPort);
00178         subRefCP(_dsPort2);
00179         subRefCP(_cmRoot);
00180         subRefCP(_dsRoot);
00181         subRefCP(_ds2Root);
00182         subRefCP(_cam);
00183         subRefCP(_dsBack);
00184         subRefCP(_ds2Back);
00185     }
00186 
00187     Matrix m;
00188     ImagePtr img = Image::create();
00189     beginEditCP(img);
00190     img->set(GL_RGB,1,1);
00191     endEditCP(img);
00192 
00193     int extension = osg::Window::registerExtension("GL_ARB_fragment_program");
00194     if(window->hasExtension(extension))
00195     {
00196         SINFO << "Use fragment program for color crrection" << std::endl;
00197         _useFragmentProgram = true;
00198     }
00199     else
00200     {
00201         SINFO << "Use reg combiner for color crrection" << std::endl;
00202         _useFragmentProgram = false;
00203     }
00204     
00205     TextureChunkPtr tex = TextureChunk::create();    
00206 
00207     if(_useFragmentProgram)
00208     {
00209         // Step 1: The texture from the GrabBackground
00210 
00211         beginEditCP(tex);
00212         tex->setImage(img);
00213         tex->setMinFilter(GL_NEAREST);
00214         tex->setScale(false);
00215         tex->setEnvMode(GL_REPLACE);
00216         endEditCP  (tex);
00217 
00218         // Step 2: The textures for the initial gamma mapping
00219         
00220         // Texture Chunks for gamma mapping
00221         
00222         UChar8 rgammadata[] =
00223             {  0, 80, 160, 255 };
00224         
00225         _rgammaimg = Image::create();
00226         beginEditCP(_rgammaimg);
00227         _rgammaimg->set(Image::OSG_L_PF,4,1,1,1,1,0,rgammadata);
00228         endEditCP(_rgammaimg);
00229         
00230         _rgammachunk = TextureChunk::create();    
00231         beginEditCP(_rgammachunk);
00232         _rgammachunk->setImage(_rgammaimg);
00233         _rgammachunk->setMinFilter(GL_LINEAR);
00234         _rgammachunk->setMagFilter(GL_LINEAR);
00235         _rgammachunk->setWrapS(GL_CLAMP_TO_EDGE);
00236         _rgammachunk->setWrapT(GL_CLAMP_TO_EDGE);
00237         endEditCP  (_rgammachunk);
00238         
00239         UChar8 ggammadata[] =
00240             {  0, 80, 160, 255 };
00241         
00242         _ggammaimg = Image::create();
00243         beginEditCP(_ggammaimg);
00244         _ggammaimg->set(Image::OSG_L_PF,4,1,1,1,1,0,ggammadata);
00245         endEditCP(_ggammaimg);
00246         
00247         _ggammachunk = TextureChunk::create();    
00248         beginEditCP(_ggammachunk);
00249         _ggammachunk->setImage(_ggammaimg);
00250         _ggammachunk->setMinFilter(GL_LINEAR);
00251         _ggammachunk->setMagFilter(GL_LINEAR);
00252         _ggammachunk->setWrapS(GL_CLAMP_TO_EDGE);
00253         _ggammachunk->setWrapT(GL_CLAMP_TO_EDGE);
00254         endEditCP  (_ggammachunk);
00255 
00256         UChar8 bgammadata[] =
00257             {  0, 80, 160, 255 };
00258         
00259         _bgammaimg = Image::create();
00260         beginEditCP(_bgammaimg);
00261         _bgammaimg->set(Image::OSG_L_PF,4,1,1,1,1,0,bgammadata);
00262         endEditCP(_bgammaimg);
00263     
00264         _bgammachunk = TextureChunk::create();    
00265         beginEditCP(_bgammachunk);
00266         _bgammachunk->setImage(_bgammaimg);
00267         _bgammachunk->setMinFilter(GL_LINEAR);
00268         _bgammachunk->setMagFilter(GL_LINEAR);
00269         _bgammachunk->setWrapS(GL_CLAMP_TO_EDGE);
00270         _bgammachunk->setWrapT(GL_CLAMP_TO_EDGE);
00271         endEditCP  (_bgammachunk);
00272 
00273         // set gamma table
00274         for(int j=0; j < 3; ++j)
00275         {
00276             ImagePtr img;
00277             switch(j)
00278             {
00279                 case 0: img = _rgammaimg; break;
00280                 case 1: img = _ggammaimg; break;
00281                 case 2: img = _bgammaimg; break;
00282             }
00283             beginEditCP(img);
00284             if(getGammaRamp().size() == 0)
00285             {
00286                 img->set(Image::OSG_L_PF, 256, 1);
00287                 UInt8 *data = img->getData();
00288                 for(int i=0; i < 256; i++)
00289                 {
00290                     data[i] = (UInt8)(pow(i/255.0,1.0)*255);
00291                 }
00292             }
00293             else
00294             {
00295                 img->set(Image::OSG_L_PF, getGammaRamp().size(), 1);
00296                 UInt8 *data = img->getData();
00297                 for(int i=0; i < getGammaRamp().size(); i++)
00298                 {
00299                     data[i] = (UInt8)(getGammaRamp()[i][j] * 255);
00300                 }
00301             }
00302             endEditCP(img);
00303         }
00304 
00305         // Step 3: FragmentProgram Chunk for color matrix multiply
00306         m.setValue(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);     
00307         
00308         _fragProgram = FragmentProgramChunk::create();
00309         std::string prog(
00310             "!!ARBfp1.0\n"
00311             "PARAM mat0 = program.local[1];\n"
00312             "PARAM mat1 = program.local[2];\n"
00313             "PARAM mat2 = program.local[3];\n"
00314             "PARAM mat3 = program.local[4];\n"
00315             "PARAM gamma = program.local[5];\n"
00316             "TEMP source;\n"
00317             "TEMP target;\n"
00318             "\n"
00319             "# get the grabbed texture's color\n"
00320             "TEX source, fragment.texcoord[0], texture[0], 2D;\n"
00321             "\n"
00322             "# gamma map it\n"
00323             "POW source.r, source.r, gamma.r;\n"
00324             "POW source.g, source.g, gamma.r;\n"
00325             "POW source.b, source.b, gamma.r;\n"
00326             "\n"
00327             "# do the matrix transform\n"
00328             "DP4 target.x, mat0, source;\n"
00329             "DP4 target.y, mat1, source;\n"
00330             "DP4 target.z, mat2, source;\n"
00331             "\n"
00332             "# map it through the target gamma\n"
00333             "TEX target.r, target.r, texture[1], 1D;\n"
00334             "TEX target.g, target.g, texture[2], 1D;\n"
00335             "TEX target.b, target.b, texture[3], 1D;\n"
00336             "\n"
00337             "# mov it to the output\n"
00338             "MOV result.color, target;\n"
00339             "END\n");
00340         
00341         beginEditCP(_fragProgram);
00342         _fragProgram->setProgram(prog);
00343         endEditCP(_fragProgram);
00344     }   
00345     else
00346     {
00347         // Step 1: The texture from the GrabBackground
00348 
00349         beginEditCP(tex);
00350         tex->setImage(img);
00351         tex->setMinFilter(GL_NEAREST);
00352         tex->setScale(false);
00353         tex->setEnvMode(GL_REPLACE);
00354         tex->setShaderOperation(GL_TEXTURE_2D);
00355         tex->setInternalFormat(GL_RGB8);
00356         endEditCP  (tex);
00357 
00358         // Step 2: The textures for the initial gamma mapping
00359   
00360         // Texture Chunks for gamma mapping
00361 
00362         UChar8 _argammadata[] =
00363             {  0,  0,  0,    0,  0,  0,    0,  0,  0,    0,  0,  0,    
00364                80,  0,  0,   80,  0,  0,   80,  0,  0,   80,  0,  0,    
00365                160,  0,  0,  160,  0,  0,  160,  0,  0,  160,  0,  0,    
00366                255,  0,  0,  255,  0,  0,  255,  0,  0,  255,  0,  0  
00367             };
00368     
00369         _argammaimg = Image::create();
00370         beginEditCP(_argammaimg);
00371         _argammaimg->set(GL_RGB,4,4,1,1,1,0,_argammadata);
00372         endEditCP(_argammaimg);
00373     
00374         _argammachunk = TextureChunk::create();    
00375         beginEditCP(_argammachunk);
00376         _argammachunk->setImage(_argammaimg);
00377         _argammachunk->setMinFilter(GL_NEAREST);
00378         _argammachunk->setMagFilter(GL_NEAREST);
00379         _argammachunk->setWrapS(GL_CLAMP_TO_EDGE);
00380         _argammachunk->setWrapT(GL_CLAMP_TO_EDGE);
00381         _argammachunk->setShaderOperation(GL_DEPENDENT_AR_TEXTURE_2D_NV);
00382         _argammachunk->setShaderInput    (GL_TEXTURE0_ARB);
00383         _argammachunk->setInternalFormat(GL_RGB8);
00384         endEditCP  (_argammachunk);
00385 
00386         UChar8 _gbgammadata[] =
00387             {  0,  0,  0,     0, 80,  0,     0,160,  0,    0,255,  0,
00388                0,  0, 80,     0, 80, 80,     0,160, 80,    0,255, 80,
00389                0,  0,160,     0, 80,160,     0,160,160,    0,255,160,
00390                0,  0,255,     0, 80,255,     0,160,255,    0,255,255
00391             };
00392     
00393         _gbgammaimg = Image::create();
00394         beginEditCP(_gbgammaimg);
00395         _gbgammaimg->set(GL_RGB,4,4,1,1,1,0,_gbgammadata);
00396         endEditCP(_gbgammaimg);
00397     
00398         _gbgammachunk = TextureChunk::create();    
00399         beginEditCP(_gbgammachunk);
00400         _gbgammachunk->setImage(_gbgammaimg);
00401         _gbgammachunk->setMinFilter(GL_NEAREST);
00402         _gbgammachunk->setMagFilter(GL_NEAREST);
00403         _gbgammachunk->setWrapS(GL_CLAMP_TO_EDGE);
00404         _gbgammachunk->setWrapT(GL_CLAMP_TO_EDGE);
00405         _gbgammachunk->setShaderOperation(GL_DEPENDENT_GB_TEXTURE_2D_NV);
00406         _gbgammachunk->setShaderInput    (GL_TEXTURE0_ARB);
00407         _gbgammachunk->setInternalFormat(GL_RGB8);
00408         endEditCP  (_gbgammachunk);
00409 
00410         // Step 3: RegisterCombiners Chunk for color matrix multiply
00411 
00412         m.setValue(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);     
00413         m.setValue(1,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1);
00414         
00415         _regCombiner = RegisterCombinersChunk::create();
00416     }
00417 
00418     // putting it all together
00419         
00420     ChunkMaterialPtr mat = ChunkMaterial::create();
00421     beginEditCP(mat);
00422     mat->addChunk(tex);
00423     if(_useFragmentProgram)
00424     {
00425         mat->addChunk(_rgammachunk);
00426         mat->addChunk(_ggammachunk);
00427         mat->addChunk(_bgammachunk);
00428         mat->addChunk(_fragProgram);
00429     }
00430     else
00431     {
00432         mat->addChunk(_argammachunk);
00433         mat->addChunk(_gbgammachunk);
00434         mat->addChunk(_regCombiner);
00435     }
00436     endEditCP(mat);
00437 
00438     // add the second viewport
00439      
00440     GeoPTypesUI8Ptr  types = GeoPTypesUI8::create();
00441     GeoPLengthsPtr lens = GeoPLengthsUI32::create();    
00442     beginEditCP(types);
00443     types->addValue(GL_QUADS);
00444     endEditCP(types);
00445 
00446     beginEditCP(lens);
00447     lens->addValue(4);
00448     endEditCP(lens);
00449     
00450     GeoPositions3fPtr pos = GeoPositions3f::create();
00451     beginEditCP(pos);
00452     pos->addValue(Pnt3f(-1, -1, -0.5));
00453     pos->addValue(Pnt3f( 1, -1, -0.5));
00454     pos->addValue(Pnt3f( 1,  1, -0.5));
00455     pos->addValue(Pnt3f(-1,  1, -0.5));
00456     endEditCP(pos);
00457     _positions=pos;
00458     
00459     _texcoords = GeoTexCoords2f::create();
00460     beginEditCP(_texcoords);
00461     _texcoords->addValue(Vec2f(0,0));
00462     _texcoords->addValue(Vec2f(1,0));
00463     _texcoords->addValue(Vec2f(1,1));
00464     _texcoords->addValue(Vec2f(0,1));
00465     endEditCP(_texcoords);
00466    
00467     GeometryPtr geo = Geometry::create();
00468     beginEditCP(geo);
00469     geo->setMaterial(mat);
00470     geo->setPositions(pos);
00471     geo->setTypes(types);
00472     geo->setTexCoords(_texcoords);
00473     geo->setLengths(lens);
00474     endEditCP  (geo);
00475     
00476     NodePtr cube = Node::create();
00477     beginEditCP(cube);
00478     cube->setCore(geo);
00479     endEditCP(cube);