diff options
Diffstat (limited to 'examples/quick/scenegraph')
5 files changed, 22 insertions, 26 deletions
diff --git a/examples/quick/scenegraph/openglunderqml/squircle.cpp b/examples/quick/scenegraph/openglunderqml/squircle.cpp index 6b25756e61..b7082892b8 100644 --- a/examples/quick/scenegraph/openglunderqml/squircle.cpp +++ b/examples/quick/scenegraph/openglunderqml/squircle.cpp @@ -125,22 +125,22 @@ void SquircleRenderer::paint() initializeOpenGLFunctions(); m_program = new QOpenGLShaderProgram(); - m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, - "attribute highp vec4 vertices;" - "varying highp vec2 coords;" - "void main() {" - " gl_Position = vertices;" - " coords = vertices.xy;" - "}"); - m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, - "uniform lowp float t;" - "varying highp vec2 coords;" - "void main() {" - " lowp float i = 1. - (pow(abs(coords.x), 4.) + pow(abs(coords.y), 4.));" - " i = smoothstep(t - 0.8, t + 0.8, i);" - " i = floor(i * 20.) / 20.;" - " gl_FragColor = vec4(coords * .5 + .5, i, i);" - "}"); + m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, + "attribute highp vec4 vertices;" + "varying highp vec2 coords;" + "void main() {" + " gl_Position = vertices;" + " coords = vertices.xy;" + "}"); + m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, + "uniform lowp float t;" + "varying highp vec2 coords;" + "void main() {" + " lowp float i = 1. - (pow(abs(coords.x), 4.) + pow(abs(coords.y), 4.));" + " i = smoothstep(t - 0.8, t + 0.8, i);" + " i = floor(i * 20.) / 20.;" + " gl_FragColor = vec4(coords * .5 + .5, i, i);" + "}"); m_program->bindAttributeLocation("vertices", 0); m_program->link(); diff --git a/examples/quick/scenegraph/rendernode/openglrenderer.cpp b/examples/quick/scenegraph/rendernode/openglrenderer.cpp index 65c2a210bc..c84867797d 100644 --- a/examples/quick/scenegraph/rendernode/openglrenderer.cpp +++ b/examples/quick/scenegraph/rendernode/openglrenderer.cpp @@ -86,8 +86,8 @@ void OpenGLRenderNode::init() " gl_FragColor = col * opacity;\n" "}\n"; - m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource); - m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource); + m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource); + m_program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource); m_program->bindAttributeLocation("posAttr", 0); m_program->bindAttributeLocation("colAttr", 1); m_program->link(); diff --git a/examples/quick/scenegraph/sgengine/window.cpp b/examples/quick/scenegraph/sgengine/window.cpp index 2e4a70d2af..759bbf1fcd 100644 --- a/examples/quick/scenegraph/sgengine/window.cpp +++ b/examples/quick/scenegraph/sgengine/window.cpp @@ -187,7 +187,7 @@ void Window::update() void Window::sync() { QList<QSharedPointer<Item> > validItems; - foreach (QSharedPointer<Item> item, m_items) { + for (QSharedPointer<Item> item : qAsConst(m_items)) { if (!item->isDone()) { validItems.append(item); item->sync(); diff --git a/examples/quick/scenegraph/shared/logorenderer.cpp b/examples/quick/scenegraph/shared/logorenderer.cpp index 06f4892a49..8eb2d44c1e 100644 --- a/examples/quick/scenegraph/shared/logorenderer.cpp +++ b/examples/quick/scenegraph/shared/logorenderer.cpp @@ -70,7 +70,6 @@ void LogoRenderer::initialize() glClearColor(0.1f, 0.1f, 0.2f, 1.0f); - QOpenGLShader *vshader1 = new QOpenGLShader(QOpenGLShader::Vertex, &program1); const char *vsrc1 = "attribute highp vec4 vertex;\n" "attribute mediump vec3 normal;\n" @@ -85,19 +84,16 @@ void LogoRenderer::initialize() " color = clamp(color, 0.0, 1.0);\n" " gl_Position = matrix * vertex;\n" "}\n"; - vshader1->compileSourceCode(vsrc1); - QOpenGLShader *fshader1 = new QOpenGLShader(QOpenGLShader::Fragment, &program1); const char *fsrc1 = "varying mediump vec4 color;\n" "void main(void)\n" "{\n" " gl_FragColor = color;\n" "}\n"; - fshader1->compileSourceCode(fsrc1); - program1.addShader(vshader1); - program1.addShader(fshader1); + program1.addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vsrc1); + program1.addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fsrc1); program1.link(); vertexAttr1 = program1.attributeLocation("vertex"); diff --git a/examples/quick/scenegraph/textureinthread/main.cpp b/examples/quick/scenegraph/textureinthread/main.cpp index 22550cd22b..61d1c5e6dc 100644 --- a/examples/quick/scenegraph/textureinthread/main.cpp +++ b/examples/quick/scenegraph/textureinthread/main.cpp @@ -82,7 +82,7 @@ int main(int argc, char **argv) // As the render threads make use of our QGuiApplication object // to clean up gracefully, wait for them to finish before // QGuiApp is taken off the heap. - foreach (QThread *t, ThreadRenderer::threads) { + for (QThread *t : qAsConst(ThreadRenderer::threads)) { t->wait(); delete t; } |