Exemplo n.º 1
0
    // Program class
    Program::Program(const sf::String& vertex, const sf::String& fragment)
        :   myIsLinked(false)
    {
        myProgram = glCreateProgram();

        if (!vertex.IsEmpty())
        {
            Shader vShader(Shader::VERTEX_SHADER, vertex);
            Attach(vShader);
        }
        if (!fragment.IsEmpty())
        {
            Shader fShader(Shader::FRAGMENT_SHADER, fragment);
            Attach(fShader);
        }

        if (!fragment.IsEmpty() || !vertex.IsEmpty())
            Link();
    }
Exemplo n.º 2
0
    Shader::Shader(ShaderType type, const sf::String& filename)
        :   myType(type)
    {
        if (type == VERTEX_SHADER)
            myShader = glCreateShader(GL_VERTEX_SHADER);
        else
            myShader = glCreateShader(GL_FRAGMENT_SHADER);

        if (!filename.IsEmpty())
            LoadFromFile(filename);
    }