本文整理汇总了C++中ShaderProgram::attachVertFrag方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::attachVertFrag方法的具体用法?C++ ShaderProgram::attachVertFrag怎么用?C++ ShaderProgram::attachVertFrag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::attachVertFrag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendProgram
void SceneLoader::appendProgram(const QDomElement & programNode) {
string name, shaderUrl;
vector<string> flags;
ShaderProgram * program = new ShaderProgram();
if (programNode.hasAttribute("name"))
name = programNode.attribute("name").toStdString();
QDomElement programInfo = programNode.firstChildElement();
while (!programInfo.isNull()) {
if (programInfo.tagName() == "Shader") {
shaderUrl = programInfo.attribute("url").toStdString();
if (programInfo.hasAttribute("type")) {
QString shaderType = programInfo.attribute("type");
if (shaderType == "VERTEX_SHADER")
program->attachShader(shaderUrl, GL_VERTEX_SHADER, false);
else if (shaderType == "GEOMETRY_SHADER")
program->attachShader(shaderUrl, GL_GEOMETRY_SHADER, false);
else if (shaderType == "FRAGMENT_SHADER")
program->attachShader(shaderUrl, GL_FRAGMENT_SHADER, false);
else if (shaderType == "CONTROL_SHADER")
program->attachShader(shaderUrl, GL_TESS_CONTROL_SHADER, false);
else if (shaderType == "EVALUATION_SHADER")
program->attachShader(shaderUrl, GL_TESS_EVALUATION_SHADER, false);
} else {
if (programInfo.hasAttribute("flags")) {
flags
= splitValues<string> (programInfo.attribute(
"flags"));
program->attachVertFrag(shaderUrl, flags);
} else {
program->attachVertFrag(shaderUrl, false);
}
}
} else if (programInfo.tagName() == "Template") {
shaderUrl = programInfo.attribute("url").toStdString();
program->attachVertFrag(shaderUrl, true);
} else if (programInfo.tagName() == "Uniform") {
program->uniforms.push_back(Uniform<float> (programInfo.attribute(
"name").toStdString(), splitValues<float> (
programInfo.attribute("value"))));
} else if (programInfo.tagName() == "Uniformi") {
program->uniformsi.push_back(Uniform<int> (programInfo.attribute(
"name").toStdString(), splitValues<int> (
programInfo.attribute("value"))));
}
programInfo = programInfo.nextSiblingElement();
}
QList<string> attributes;
attributes.push_back("uv");
attributes.push_back("normal");
attributes.push_back("tangent");
program->init(attributes);
program->name = name;
SceneData::Instance().shaderPrograms.insert(name, program);
}
示例2: appendProgram
void SceneLoader::appendProgram(const QDomElement & programNode) {
string name, shaderUrl;
vector<string> flags;
QList<string> attributes = QList<string>() << "uv" << "normal" << "tangent" << "bitangent";
if (programNode.hasAttribute("name"))
name = programNode.attribute("name").toStdString();
ShaderProgram * program = new ShaderProgram(name);
QDomElement programInfo = programNode.firstChildElement();
while (!programInfo.isNull()) {
if (programInfo.tagName() == "Shader") {
shaderUrl = programInfo.attribute("url").toStdString();
if (programInfo.hasAttribute("flags")) {
flags = splitValues<string> (programInfo.attribute("flags"));
TemplateEngine::Instance().addFlags(flags);
}
if (programInfo.hasAttribute("type")) {
QString shaderType = programInfo.attribute("type");
if (shaderType == "VERTEX_SHADER")
program->attachShader(shaderUrl, GL_VERTEX_SHADER);
else if (shaderType == "GEOMETRY_SHADER")
program->attachShader(shaderUrl, GL_GEOMETRY_SHADER);
else if (shaderType == "FRAGMENT_SHADER")
program->attachShader(shaderUrl, GL_FRAGMENT_SHADER);
else if (shaderType == "CONTROL_SHADER")
program->attachShader(shaderUrl, GL_TESS_CONTROL_SHADER);
else if (shaderType == "EVALUATION_SHADER")
program->attachShader(shaderUrl, GL_TESS_EVALUATION_SHADER);
} else {
program->attachVertFrag(shaderUrl);
}
} else if (programInfo.tagName() == "Uniform") {
program->uniforms.push_back(Uniform<float> (programInfo.attribute(
"name").toStdString(), splitValues<float> (
programInfo.attribute("value"))));
} else if (programInfo.tagName() == "Uniformi") {
program->uniformsi.push_back(Uniform<int> (programInfo.attribute(
"name").toStdString(), splitValues<int> (
programInfo.attribute("value"))));
} else if (programInfo.tagName() == "Layer") {
if (programInfo.hasAttribute("texture")) {
Texture * texture = Scene::Instance().textures.value(
programInfo.attribute("texture").toStdString());
if (Scene::Instance().textures.count(programInfo.attribute("texture").toStdString()) == 0)
LogError << "Texture "
<< programInfo.attribute("texture").toStdString()
<< " not found.";
// TODO(bmonkey): uniform name reset
LogDebug << programInfo.attribute("sampler").toStdString();
texture->name = programInfo.attribute("sampler").toStdString();
program->addTexture(texture);
}
}
programInfo = programInfo.nextSiblingElement();
}
program->init(attributes);
program->samplerUniforms();
Scene::Instance().shaders.insert(name, program);
}