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


C++ ShaderProgram::getReference方法代码示例

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


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

示例1: combinedHash

ShaderProgram& ShaderAssembler::getShader(const uint64 materialAttribs, const uint64 drawableAttribs)
{
    JOP_ASSERT(m_instance != nullptr, "Couldn't load shader, no ShaderAssembler instance!");

    auto& cont = m_instance->m_shaders;

    const std::size_t combinedAttribs = combinedHash(materialAttribs, drawableAttribs);

    {
        std::unique_lock<std::recursive_mutex> lock(m_instance->m_mutex);

        auto itr = cont.find(combinedAttribs);
        if (itr != cont.end() && !itr->second.expired())
            return *itr->second;
    }

    const auto& uber = m_instance->m_uber;
    const std::string shaderName = "jop_shader_" + std::to_string(combinedAttribs);

    std::string pp = Material::getShaderPreprocessorDef(materialAttribs) +
                     Drawable::getShaderPreprocessorDef(drawableAttribs);

    ShaderProgram* s = &ResourceManager::getNamed<ShaderProgram>(shaderName, pp, Shader::Type::Vertex, uber[0], Shader::Type::Geometry, uber[1], Shader::Type::Fragment, uber[2]);

    if (!ResourceManager::isError(*s))
    {
        s->setShouldSerialize(false);
        s->setPersistence(5);

        {
            std::unique_lock<std::recursive_mutex> lock(m_instance->m_mutex);

            cont[combinedAttribs] = static_ref_cast<ShaderProgram>(s->getReference());
        }

        // Needed so that different samplers don't all point to zero
        if ((materialAttribs & Material::FragLightingAttribs) != 0)
        {
            static const int maxUnits = Texture::getMaxTextureUnits();

            for (std::size_t i = 0; i < LightSource::getMaximumLights(LightSource::Type::Point); ++i)
                s->setUniform("u_PointLightShadowMaps[" + std::to_string(i) + "]", maxUnits - 1);
        }
    }

    return *s;
}
开发者ID:Jopnal,项目名称:Jopnal,代码行数:47,代码来源:ShaderAssembler.cpp

示例2: setOverrideShader

 void Drawable::setOverrideShader(ShaderProgram& shader)
 {
     m_shader = static_ref_cast<ShaderProgram>(shader.getReference());
 }
开发者ID:Jopnal,项目名称:Jopnal,代码行数:4,代码来源:Drawable.cpp


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