Exemple #1
0
void safeLoadShader(std::shared_ptr<engine::Program>& shader, VSdata vsd, FSdata fsd) {
    try 
    {
        {
            auto vs = std::make_shared<engine::VertexShader>(vsd);
            auto compResult = vs->Compile();
            if (!compResult.empty())
                throw std::runtime_error(compResult);
            if (!vs)
                throw std::runtime_error(vs->Status());
            shader->AttachShader(vs);
        }
        CheckForGLError();

        {
            auto fs = std::make_shared<engine::FragmentShader>(fsd);
            auto compResult = fs->Compile();
            if (!compResult.empty())
                throw std::runtime_error(compResult);
            if (!fs)
                throw std::runtime_error(fs->Status());
            shader->AttachShader(fs);
        }
        CheckForGLError();
    
        shader->Link();
        CheckForGLError();
        if (!shader->Validate())
            throw std::runtime_error("Program not valid");
        shader->Bind();
        CheckForGLError();
        shader->SetUniform("Projection", Projection);
        CheckForGLError();
    }
    catch (std::exception const& e) {
        
        BREAKPOINT();
    }
}
Exemple #2
0
Image::Bind::Bind(std::shared_ptr<Texture> texture) :
    texture(texture)
{
    if (texture)
        texture->Bind();
}
Exemple #3
0
void Pathtracer::SetEnvironmentMap(std::shared_ptr<gl::TextureCubemap> _envMap)
{
	if(_envMap)
		_envMap->Bind(12);
}