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


C++ Program::create方法代码示例

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


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

示例1: loadProgram

	void loadProgram(Program &p, const std::string& name) {

		//Initializes a Program object
		p.create();

		//Gets the path to the vertex shader (ending in ".vsh")
		string sv = rh.pathToResource(name, "vsh");
		// cout << "path of vertex shader is: " << sv << endl;

		//Compiles the vertex shader and attaches it to our Program object
		p.attach(rh.contentsOfFile(sv), GL_VERTEX_SHADER);

		//Binds attribute variables to a particular ID
		glBindAttribLocation(p.id(), posLoc, "vertexPosition");
		glBindAttribLocation(p.id(), colLoc, "vertexColor");


		//Gets the path to the fragment shader (ending in ".fsh")
		string sp = rh.pathToResource(name, "fsh");
		// cout << "path of vertex shader is: " << sp << endl;

		//Compiles the fragment shader and attaches it to our Program object
		p.attach(rh.contentsOfFile(sp), GL_FRAGMENT_SHADER);

		//Links the Program object to the GPU so that it can be activated when needed
		p.link();
	}
开发者ID:CreativeCodingLab,项目名称:aluminum,代码行数:27,代码来源:Transformation.cpp

示例2: loadProgram

  void loadProgram(Program &p, const std::string& name) {

    //can't link shaders unless a vao is bound...
    //bindDefaultVAO();

    p.create();

    string sv = rh.pathToResource(name, "vsh");

    p.attach(rh.contentsOfFile(sv), GL_VERTEX_SHADER);

    glBindAttribLocation(p.id(), posLoc, "vertexPosition");
    glBindAttribLocation(p.id(), texCoordLoc, "vertexTexCoord");


    string sg = rh.pathToResource(name, "gsh");
    cout << "path of vertex shader is: " << sg << endl;

    p.attach(rh.contentsOfFile(sg), GL_GEOMETRY_SHADER);

    string sp = rh.pathToResource(name, "fsh");

    p.attach(rh.contentsOfFile(sp), GL_FRAGMENT_SHADER);

    p.link();
  }
开发者ID:,项目名称:,代码行数:26,代码来源:

示例3: createProgram

Program ResourceCreator::createProgram(const char* pVertexShaderName, const char* pFragmentShaderName)
{
    Program program;

    std::string vertexShaderFilename = std::string("./data/shaders/") + pVertexShaderName + ".vert";
    std::string fragmentShaderFilename = std::string("./data/shaders/") + pFragmentShaderName + ".frag";


    std::string vertShaderSource = ReadFile(vertexShaderFilename.c_str());
    if (vertShaderSource.length() == 0)
    {
        std::cerr << "Couldn't read file: " << vertexShaderFilename << std::endl;
        return program;
    }


    std::string fragShaderSource = ReadFile(fragmentShaderFilename.c_str());
    if (fragShaderSource.length() == 0) {
        std::cerr << "Couldn't read file: " << fragmentShaderFilename << std::endl;
        return program;
    }

    if (!program.create(vertShaderSource.c_str(), fragShaderSource.c_str()))
    {
        std::cerr << "Failed to make program with vertex shader " << vertexShaderFilename << " and fragment shader " << fragmentShaderFilename << "." << std::endl;
        return program;
    }

    return program;
}
开发者ID:johnsietsma,项目名称:RefEngine,代码行数:30,代码来源:ResourceCreator.cpp

示例4: create

 Program create(std::string const& vertShaderPath, std::string const& fragShaderPath, IncludeCommonCode icc)
 {
     Program prog;
     prog.create(vertShaderPath, fragShaderPath);
     ShaderFiles sf = ShaderFiles(vertShaderPath, lastModifyTime(vertShaderPath), std::string(), static_cast<std::uint64_t>(0), fragShaderPath, lastModifyTime(fragShaderPath));
     mProgs.emplace_back(prog, sf);
     return prog;
 }
开发者ID:happanda,项目名称:renderize,代码行数:8,代码来源:program_manager.cpp

示例5: loadProgram

  void loadProgram(Program &p, const std::string& name) {

    p.create();

    p.attach(p.loadText(name + ".vsh"), GL_VERTEX_SHADER);
    glBindAttribLocation(p.id(), posLoc, "vertexPosition");
    glBindAttribLocation(p.id(), normalLoc, "vertexNormal");

    p.attach(p.loadText(name + ".fsh"), GL_FRAGMENT_SHADER);

    p.link();
  }
开发者ID:CreativeCodingLab,项目名称:aluminum,代码行数:12,代码来源:NoiseSphere.cpp


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