当前位置: 首页>>代码示例>>C++>>正文


C++ GpuProgramParametersSharedPtr::_readRawConstants方法代码示例

本文整理汇总了C++中ogre::GpuProgramParametersSharedPtr::_readRawConstants方法的典型用法代码示例。如果您正苦于以下问题:C++ GpuProgramParametersSharedPtr::_readRawConstants方法的具体用法?C++ GpuProgramParametersSharedPtr::_readRawConstants怎么用?C++ GpuProgramParametersSharedPtr::_readRawConstants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::GpuProgramParametersSharedPtr的用法示例。


在下文中一共展示了GpuProgramParametersSharedPtr::_readRawConstants方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

KBOOL Kylin::EffectFade::Initialize()
{

    Ogre::CompositorPtr spCompositor = Ogre::CompositorManager::getSingleton().create(
                                           m_sName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
                                       );

    Ogre::CompositionTechnique *t;
    Ogre::CompositionTechnique::TextureDefinition *td;
    Ogre::CompositionTargetPass *tp;
    Ogre::CompositionPass *pass;

    t = spCompositor->createTechnique();
    td = t->createTextureDefinition("scene");
    td->width = 1;
    td->height = 1;
    td->formatList.push_back(Ogre::PF_X8R8G8B8);

    tp = t->createTargetPass();
    tp->setInputMode(Ogre::CompositionTargetPass::IM_PREVIOUS);
    tp->setOutputName("scene");

    tp = t->getOutputTargetPass();
    tp->setInputMode(Ogre::CompositionTargetPass::IM_NONE);
    pass = tp->createPass();
    pass->setType(Ogre::CompositionPass::PT_RENDERQUAD);
    pass->setMaterialName("PostFilters/Fade");
    pass->setInput(0, "scene");
    pass->setIdentifier(0xDEADBADE);

    // receive default parameters from material script
    m_fColourAmount = 0;
    m_fGrayAmount	= 1;
    if (!pass->getMaterial().isNull())
    {
        Ogre::GpuProgramParametersSharedPtr parameters = pass->getMaterial()->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
        /*#if OGRE_VERSION >= 0x010300*/
        const Ogre::GpuConstantDefinition* def;

        def = parameters->_findNamedConstantDefinition("colour_amount");
        if (def)
            parameters->_readRawConstants(def->physicalIndex, 1, &m_fColourAmount);
        def = parameters->_findNamedConstantDefinition("gray_amount");
        if (def)
            parameters->_readRawConstants(def->physicalIndex, 1, &m_fGrayAmount);
// #else
// 		GpuProgramParameters::RealConstantEntry* entry;
//
// 		entry = parameters->getNamedRealConstantEntry("colour_amount");
// 		if (entry && entry->isSet)
// 			m_fColourAmount = entry->val[0];
//
// 		entry = parameters->getNamedRealConstantEntry("gray_amount");
// 		if (entry && entry->isSet)
// 			m_fGrayAmount = entry->val[0];
// #endif
    }

    KBOOL bRet = EffectCompositor::Initialize();

    if (bRet)
        m_pCompositor->addListener(this);

    return bRet;
}
开发者ID:dzw,项目名称:kylin001v,代码行数:65,代码来源:EffectFade.cpp

示例2: CreateProperties

bool OgreMaterialProperties::CreateProperties()
{
    Ogre::MaterialPtr matPtr = material_->GetMaterial();
    if (matPtr.isNull())
        return false;

    // Material
    Ogre::Material::TechniqueIterator tIter = matPtr->getTechniqueIterator();
    while(tIter.hasMoreElements())
    {
        // Technique
        Ogre::Technique *tech = tIter.getNext();
        Ogre::Technique::PassIterator pIter = tech->getPassIterator();
        while(pIter.hasMoreElements())
        {
            // Pass
            Ogre::Pass *pass = pIter.getNext();
            if (!pass)
                continue;

            if(pass->hasVertexProgram())
            {
                // Vertex program
                const Ogre::GpuProgramPtr &verProg = pass->getVertexProgram();
                if (!verProg.isNull())
                {
                    Ogre::GpuProgramParametersSharedPtr verPtr = pass->getVertexProgramParameters();
                    if (verPtr->hasNamedParameters())
                    {
                        // Named parameters (constants)
                        Ogre::GpuConstantDefinitionIterator mapIter = verPtr->getConstantDefinitionIterator();
                        while(mapIter.hasMoreElements())
                        {
                            QString paramName = mapIter.peekNextKey().c_str();
                            const Ogre::GpuConstantDefinition &paramDef  = mapIter.getNext();

                            // Filter names that end with '[0]'
                            int found = paramName.indexOf("[0]");
                            if (found != -1)
                                continue;

                            // Ignore auto parameters
                            bool is_auto_param = false;
                            Ogre::GpuProgramParameters::AutoConstantIterator autoConstIter = verPtr->getAutoConstantIterator();
                            while(autoConstIter.hasMoreElements())
                            {
                                Ogre::GpuProgramParameters::AutoConstantEntry autoConstEnt = autoConstIter.getNext();
                                if (autoConstEnt.physicalIndex == paramDef.physicalIndex)
                                {
                                    is_auto_param = true;
                                    break;
                                }
                            }

                            if (is_auto_param)
                                continue;

                            if (!paramDef.isFloat())
                                continue;

                            size_t count = paramDef.elementSize * paramDef.arraySize;
                            QVector<float> paramValue;
                            QVector<float>::iterator iter;
                            paramValue.resize(count);
                            verPtr->_readRawConstants(paramDef.physicalIndex, count, &*paramValue.begin());

                            QTextStream vector_string;
                            QString string;
                            vector_string.setString(&string, QIODevice::WriteOnly);

                            for(iter = paramValue.begin(); iter != paramValue.end(); ++iter)
                                vector_string << *iter << " ";

                            // Add QPROPERTY. Add to "VP" to the end of the parameter name in order to identify VP parameters.
                            QMap<QString, QVariant> typeValuePair;
                            typeValuePair[GpuConstantTypeToString(paramDef.constType)] = *vector_string.string();
                            setProperty(paramName.append(" VP").toLatin1(), QVariant(typeValuePair));
                        }
                    }
                }
            }

            if(pass->hasFragmentProgram())
            {
                // Fragment program
                const Ogre::GpuProgramPtr fragProg = pass->getFragmentProgram();
                if (!fragProg.isNull())
                {
                    Ogre::GpuProgramParametersSharedPtr fragPtr = pass->getFragmentProgramParameters();
                    if (!fragPtr.isNull())
                    {
                        if (fragPtr->hasNamedParameters())
                        {
                            // Named parameters (constants)
                            Ogre::GpuConstantDefinitionIterator mapIter = fragPtr->getConstantDefinitionIterator();
                            while(mapIter.hasMoreElements())
                            {
                                QString paramName = mapIter.peekNextKey().c_str();
                                const Ogre::GpuConstantDefinition &paramDef  = mapIter.getNext();

//.........这里部分代码省略.........
开发者ID:Chiru,项目名称:naali,代码行数:101,代码来源:OgreMaterialProperties.cpp


注:本文中的ogre::GpuProgramParametersSharedPtr::_readRawConstants方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。