示例#1
0
int CstBufferRepository::gatherFromAnnotation(ICstBuffer** &pp, const char *annotationName, const char* str, int *ival, float *fval)
{
    memset(cbArray, 0, 100*sizeof(ICstBuffer*));
    pp = (ICstBuffer**)cbArray;
    int n = 0;
    if(!annotationName)
        return 0;
    ItemMap::iterator i2 = m_Items.begin();
    while(i2 != m_Items.end())
    {
        if(i2->second.p)
        {
            IAnnotation* pAnnot = i2->second.p->annotations();
            if((str && findMatchingAnnotation(pAnnot, annotationName, str))
             ||(ival && (pAnnot->getAnnotationInt(annotationName)==ival[0]))
             ||(fval && (pAnnot->getAnnotationFloat(annotationName)==fval[0])))
            {
                if(n >= 100)
                {
                    nvFX::printf(">>Error : gathering of uniforms exceeded 100 !");
                    return n;
                }
                cbArray[n++] = i2->second.p;
            }
        }
        ++i2;
    }
    return n;
}
示例#2
0
int ShaderModuleRepository::gatherFromAnnotation(IShader** &ppShaders, const char *annotationName, const char* str, int *ival, float *fval)
{
    memset(shdArray, 0, 100*sizeof(IShader*));
    ppShaders = (IShader**)shdArray;
    int nshaders = 0;
    if(!annotationName)
        return 0;
    ShdMap::iterator i2 = m_shaders.begin();
    while(i2 != m_shaders.end())
    {
        Shader* pShd = static_cast<Shader*>(i2->second.p);
        if(pShd)
        {
            IAnnotation* pAnnot = pShd->annotations();
            if((str && findMatchingAnnotation(pAnnot, annotationName, str))
             ||(ival && (pAnnot->getAnnotationInt(annotationName)==ival[0]))
             ||(fval && (pAnnot->getAnnotationFloat(annotationName)==fval[0])))
            {
                if(nshaders >= 100)
                {
                    nvFX::printf(">>Error : gathering of shader exceeded 100 !");
                    return nshaders;
                }
                shdArray[nshaders++] = pShd;
            }
        }
        ++i2;
    }
    // warning : means that we cannot put in the same list some global shaders from here with
    // local shader previously found in this method...
    if(nshaders == 0)
    {
        // Try in the global repository
        return static_cast<ShaderModuleRepository*>(getShaderModuleRepositorySingleton())->gatherFromAnnotation(ppShaders, annotationName, str, ival, fval);
    }
    return nshaders;
}
示例#3
0
文件: resources.cpp 项目: 2php/nvFX
int ResourceRepository::gatherFromAnnotation(IResource** &pp, const char *annotationName, const char* str, int *ival, float *fval)
{
    memset(resArray, 0, 100*sizeof(IShader*));
    pp = (IResource**)resArray;
    int n = 0;
    if(!annotationName)
        return 0;
    ResourceMap::iterator i2 = m_resources.begin();
    while(i2 != m_resources.end())
    {
        if(i2->second.p)
        {
            IAnnotation* pAnnot = i2->second.p->annotations();
            if((str && findMatchingAnnotation(pAnnot, annotationName, str))
             ||(ival && (pAnnot->getAnnotationInt(annotationName)==ival[0]))
             ||(fval && (pAnnot->getAnnotationFloat(annotationName)==fval[0])))
            {
                if(n >= 100)
                {
                    nvFX::printf(">>Error : gathering of resources exceeded 100 !");
                    return n;
                }
                resArray[n++] = i2->second.p;
            }
        }
        ++i2;
    }
    // warning : means that we cannot put in the same list some global shaders from here with
    // local shader previously found in this method...
    if(n == 0)
    {
        // Try in the global repository
        return static_cast<ResourceRepository*>(getResourceRepositorySingleton())->gatherFromAnnotation(pp, annotationName, str, ival, fval);
    }
    return n;
}