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


C++ QOpenGLShaderProgram::addShader方法代码示例

本文整理汇总了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);
}
开发者ID:ragemcmad,项目名称:CGBillard,代码行数:17,代码来源:lightsources.cpp

示例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;
}
开发者ID:paulolav,项目名称:mazecompositor,代码行数:20,代码来源:common.cpp

示例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;
}
开发者ID:diegomazala,项目名称:alpha-matting,代码行数:39,代码来源:GLImageProcessor.cpp


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