示例#1
0
文件: Shader.cpp 项目: tsingzhen/sf3d
    // 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();
    }
示例#2
0
文件: Shader.cpp 项目: tsingzhen/sf3d
    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);
    }