void ShaderProgramVariablesBase::onCreate(const ShaderProgramVariables *source) { Inherited::onCreate(source); if(source != NULL) { ShaderProgramVariables *pThis = static_cast<ShaderProgramVariables *>(this); MFUnrecShaderValueVariablePtr::const_iterator VariablesIt = source->_mfVariables.begin(); MFUnrecShaderValueVariablePtr::const_iterator VariablesEnd = source->_mfVariables.end (); while(VariablesIt != VariablesEnd) { pThis->addVariable(*VariablesIt); ++VariablesIt; } MFUnrecChildShaderProcVariablePtr::const_iterator ProceduralVariablesIt = source->_mfProceduralVariables.begin(); MFUnrecChildShaderProcVariablePtr::const_iterator ProceduralVariablesEnd = source->_mfProceduralVariables.end (); while(ProceduralVariablesIt != ProceduralVariablesEnd) { pThis->addProceduralVariable(*ProceduralVariablesIt); ++ProceduralVariablesIt; } } }
void ShaderProgramVariablesBase::execSyncV( FieldContainer &oFrom, ConstFieldMaskArg whichField, AspectOffsetStore &oOffsets, ConstFieldMaskArg syncMode, const UInt32 uiSyncInfo) { ShaderProgramVariables *pThis = static_cast<ShaderProgramVariables *>(this); pThis->execSync(static_cast<ShaderProgramVariables *>(&oFrom), whichField, oOffsets, syncMode, uiSyncInfo); }
void ShaderExecutableChunk::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { bool bMarkChanged = false; if(0x0000 != (whichField & VariablesFieldMask)) { ShaderProgramVariables *pVars = _sfVariables.getValue(); if(pVars != NULL) { if(details == 0x0001) { // be save reset all locations if(pVars->getMFVariables()->size() == 0) { editMFVariableLocations()->clear(); } else { editMFVariableLocations()->resize( pVars->getMFVariables()->size(), -1); std::fill(editMFVariableLocations()->begin(), editMFVariableLocations()->end (), -1); } // be save reset all locations if(pVars->getMFProceduralVariables()->size() == 0 ) { editMFProceduralVariableLocations()->clear(); } else { editMFProceduralVariableLocations()->resize( pVars->getMFProceduralVariables()->size(), -1); std::fill(editMFProceduralVariableLocations()->begin(), editMFProceduralVariableLocations()->end (), -1); } } } Window::refreshGLObject(this->getGLId()); } if(0x0000 != (whichField & (VertexShaderFieldMask | GeometryShaderFieldMask | FragmentShaderFieldMask ))) { if(details == ShaderProgram::ProgramFieldMask) { Window::reinitializeGLObject(this->getGLId()); } else if(details == ShaderProgram::VariablesFieldMask) { this->remergeVariables(); Window::refreshGLObject(this->getGLId()); } bMarkChanged = true; } if(0x0000 != (whichField & (GeometryVerticesOutFieldMask | GeometryInputTypeFieldMask | GeometryOutputTypeFieldMask ))) { // changing parameters requires re-linking the shader Window::reinitializeGLObject(this->getGLId()); } if(bMarkChanged == true) { // be save reset all locations std::fill(editMFVariableLocations()->begin(), editMFVariableLocations()->end (), -1); std::fill(editMFProceduralVariableLocations()->begin(), editMFProceduralVariableLocations()->end (), -1); if(_sfVariables.getValue() != NULL) { _sfVariables.getValue()->markAllChanged(); } } Inherited::changed(whichField, origin, details); }
void ComputeShaderChunk::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { bool bMarkChanged = false; if(0x0000 != (whichField & ComputeProgramFieldMask) && 0 != _sfComputeProgram.getValue().size() ) { if(_mfComputeShader.size() == 0) { ShaderProgramUnrecPtr pProg = ShaderProgram::createDependent( this->getFieldFlags()->_bNamespaceMask); pProg->setShaderType(GL_COMPUTE_SHADER); addComputeShader(pProg); pProg->setVariables(this->getVariables()); } else if(_mfComputeShader.size() > 1) { editMFComputeShader()->resize(1); } _mfComputeShader[0]->setProgram(_sfComputeProgram.getValue()); bMarkChanged = true; Window::reinitializeGLObject(this->getGLId()); } if(0x0000 != (whichField & VariablesFieldMask)) { ShaderProgramVariables *pVars = _sfVariables.getValue(); if(pVars != NULL) { if(details == 0x0001) { // be save reset all locations if(pVars->getMFVariables()->size() == 0) { editMFVariableLocations()->clear(); } else { editMFVariableLocations()->resize( pVars->getMFVariables()->size(), -1); std::fill(editMFVariableLocations()->begin(), editMFVariableLocations()->end (), -1); } // be save reset all locations if(pVars->getMFProceduralVariables()->size() == 0 ) { editMFProceduralVariableLocations()->clear(); } else { editMFProceduralVariableLocations()->resize( pVars->getMFProceduralVariables()->size(), -1); std::fill(editMFProceduralVariableLocations()->begin(), editMFProceduralVariableLocations()->end (), -1); } } } Window::refreshGLObject(this->getGLId()); } if(0x0000 != (whichField & ComputeShaderFieldMask)) { bMarkChanged = true; Window::reinitializeGLObject(this->getGLId()); } if(bMarkChanged == true) { // be save reset all locations std::fill(editMFVariableLocations()->begin(), editMFVariableLocations()->end (), -1); std::fill(editMFProceduralVariableLocations()->begin(), editMFProceduralVariableLocations()->end (), -1); if(_sfVariables.getValue() != NULL) { _sfVariables.getValue()->markAllChanged(); } } Inherited::changed(whichField, origin, details); }