本文整理汇总了C++中QOpenGLShaderProgram::addShader方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLShaderProgram::addShader方法的具体用法?C++ QOpenGLShaderProgram::addShader怎么用?C++ QOpenGLShaderProgram::addShader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLShaderProgram
的用法示例。
在下文中一共展示了QOpenGLShaderProgram::addShader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadShader
void LightSources::loadShader()
{
// Standardshader
QOpenGLShaderProgram* standardShaderProg = new QOpenGLShaderProgram();
QOpenGLShader vertShader(QOpenGLShader::Vertex);
vertShader.compileSourceFile(":/shader/lightsource.vert");
standardShaderProg->addShader(&vertShader);
QOpenGLShader fragShader(QOpenGLShader::Fragment);
fragShader.compileSourceFile(":/shader/lightsource.frag");
standardShaderProg->addShader(&fragShader);
standardShaderProg->link();
// Sonnenshader
this->shaderProgram = standardShaderProg;
glEnable(GL_TEXTURE_2D);
}
示例2: QOpenGLShaderProgram
QOpenGLShaderProgram *generateShaderProgram(QObject *parent, QByteArray vsrc, QByteArray fsrc)
{
QOpenGLShaderProgram *program = new QOpenGLShaderProgram(parent);
QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, program);
vshader->compileSourceCode(vsrc);
if (!vshader->compileSourceCode(vsrc))
qFatal("Error in vertex src:\n%s\n", vsrc.constData());
QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, program);
if (!fshader->compileSourceCode(fsrc))
qFatal("Error in fragment src:\n%s\n", fsrc.constData());
program->addShader(vshader);
program->addShader(fshader);
if (!program->link())
qFatal("Error linking:\n%s\n%s\n", vsrc.constData(), fsrc.constData());
return program;
}
示例3: buildPassthorughProgram
// Build a passthrough glsl program
QOpenGLShaderProgram* GLImageProcessor::buildPassthorughProgram() const
{
QOpenGLShaderProgram* prog = new QOpenGLShaderProgram();
QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, prog);
const char *vsrc =
"attribute highp vec4 in_Vertex;\n"
"attribute mediump vec4 in_TexCoord;\n"
"varying mediump vec4 texCoord;\n"
"void main(void)\n"
"{\n"
" gl_Position = in_Vertex;\n"
" texCoord = in_TexCoord;\n"
"}\n";
vshader->compileSourceCode(vsrc);
QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, prog);
const char *fsrc =
"uniform sampler2D in_Texture;\n"
"varying mediump vec4 texCoord;\n"
"void main(void)\n"
"{\n"
" gl_FragColor = texture2D(in_Texture, texCoord.st);\n"
"}\n";
fshader->compileSourceCode(fsrc);
prog->addShader(vshader);
prog->addShader(fshader);
prog->bindAttributeLocation("in_Vertex", 0);
prog->bindAttributeLocation("in_TexCoord", 1);
prog->link();
prog->bind();
prog->setUniformValue("in_Texture", 0);
prog->release();
return prog;
}