本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}