diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-18 09:58:57 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-02-18 09:58:57 +0100 |
commit | ba9ca0e3d64c46fc63cdbc62f3e4a96e36a842f8 (patch) | |
tree | f9631624c841281302a2a546fbcc06a2375f410e /src/quick/scenegraph/qsgcontext.cpp | |
parent | a65b8785621ebf58f34eb0c1759376fc0a1117c7 (diff) | |
parent | 464bd2bf975797241213191a374e70431c5c3763 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/qml/jsruntime/qv4functionobject.cpp
src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
Change-Id: Id164f6c3b45501aa466908659ec4e3b957323753
Diffstat (limited to 'src/quick/scenegraph/qsgcontext.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index dd00f75fae..9f58876def 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -631,4 +631,38 @@ void QSGRenderContext::textureFactoryDestroyed(QObject *o) m_mutex.unlock(); } +/*! + Compile \a shader, optionally using \a vertexCode and \a fragmentCode as + replacement for the source code supplied by \a shader. + + If \a vertexCode or \a fragmentCode is supplied, the caller is responsible + for setting up attribute bindings. + + \a material is supplied in case the implementation needs to take the + material flags into account. + */ + +void QSGRenderContext::compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode, const char *fragmentCode) +{ + Q_UNUSED(material); + if (vertexCode || fragmentCode) { + Q_ASSERT_X((material->flags() & QSGMaterial::CustomCompileStep) == 0, + "QSGRenderContext::compile()", + "materials with custom compile step cannot have custom vertex/fragment code"); + QOpenGLShaderProgram *p = shader->program(); + p->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexCode ? vertexCode : shader->vertexShader()); + p->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentCode ? fragmentCode : shader->fragmentShader()); + p->link(); + if (!p->isLinked()) + qWarning() << "shader compilation failed:" << endl << p->log(); + } else { + shader->compile(); + } +} + +void QSGRenderContext::initialize(QSGMaterialShader *shader) +{ + shader->initialize(); +} + QT_END_NAMESPACE |