本文整理汇总了C++中ShaderProgram::getLog方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::getLog方法的具体用法?C++ ShaderProgram::getLog怎么用?C++ ShaderProgram::getLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::getLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createDefaultShader
ShaderProgram* SpriteCache::createDefaultShader () {
if (!Gdx::graphics->isGL20Available()) return NULL;
std::string vertexShader = "attribute vec4 " + ShaderProgram::POSITION_ATTRIBUTE + ";\n" //
"attribute vec4 " + ShaderProgram::COLOR_ATTRIBUTE + ";\n" //
"attribute vec2 " + ShaderProgram::TEXCOORD_ATTRIBUTE + "0;\n" //
"uniform mat4 u_projectionViewMatrix;\n" //
"varying vec4 v_color;\n" //
"varying vec2 v_texCoords;\n" //
"\n" //
"void main()\n" //
"{\n" //
" v_color = " + ShaderProgram::COLOR_ATTRIBUTE + ";\n" //
" v_texCoords = " + ShaderProgram::TEXCOORD_ATTRIBUTE + "0;\n" //
" gl_Position = u_projectionViewMatrix * " + ShaderProgram::POSITION_ATTRIBUTE + ";\n" //
"}\n";
std::string fragmentShader = "#ifdef GL_ES\n" //
"precision mediump float;\n" //
"#endif\n" //
"varying vec4 v_color;\n" //
"varying vec2 v_texCoords;\n" //
"uniform sampler2D u_texture;\n" //
"void main()\n"//
"{\n" //
" gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n" //
"}";
ShaderProgram* shader = new ShaderProgram(vertexShader, fragmentShader);
if (shader->isCompiled() == false)
throw std::runtime_error("Error compiling shader: " + shader->getLog());
return shader;
}
示例2: buildCurrentProject
void GLShaderDev::buildCurrentProject()
{
ShaderProgram* prog = new ShaderProgram;
bool success = true;
int i = 1;
OutputParser parser(_glInfo.getVendor());
const ShaderProject::Stages& stages = _projectManager.getCurrentProject()->getStages();
_editor->saveAll();
_output->getModel()->clear();
_buildOutputDock->setVisible(true);
for (ShaderProject::Stages::const_iterator it = stages.begin(); it != stages.end(); ++it)
{
QFile file(it->second);
QFileInfo fileInfo(file);
ShaderObject* obj = new ShaderObject;
QString str = QString(tr("[%1/%2] Compiling %3...")).arg(i).arg(stages.size()).arg(fileInfo.fileName());
_output->getModel()->addItem(OutputItem(str, OutputItem::InformationItem));
if (!file.open(QIODevice::ReadOnly))
throw (GlsdException(std::string("Could not open shader file") + it->second.toStdString())); // TODO proper exception handling
if (!obj->compile(QString(file.readAll()).toStdString(), static_cast<ShaderObject::ShaderType>(it->first)))
{
_output->getModel()->addItems(parser.parse(obj->getErrorLog(), fileInfo.absoluteFilePath().toStdString()));
success = false;
}
prog->attach(*obj);
++i;
}
_output->getModel()->addItem(OutputItem(tr("Linking shader..."), OutputItem::InformationItem));
if (!prog->link())
{
_output->getModel()->addItem(OutputItem(prog->getLog().c_str(), OutputItem::ErrorItem));
success = false;
}
if (!success)
{
_output->getModel()->addItem(OutputItem(tr("*** Compilation failed ***"), OutputItem::StandardItem));
return;
}
_output->getModel()->addItem(OutputItem(tr("*** Compilation successful ***"), OutputItem::StandardItem));
// FIXME Set shader properly, with attributes correctly bound
_glwidget->setShader(prog);
prog->printDebug();
}