From 2703a23abf02ebc642e5caeb1c2d1184d594222b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 5 Dec 2010 09:16:56 +0100 Subject: [PATCH] Use color shader to render the background --- scene_opengl_egl.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/scene_opengl_egl.cpp b/scene_opengl_egl.cpp index 39950828e8..d7fa0ab432 100644 --- a/scene_opengl_egl.cpp +++ b/scene_opengl_egl.cpp @@ -245,12 +245,33 @@ void SceneOpenGL::paintGenericScreen(int mask, ScreenPaintData data) Scene::paintGenericScreen(mask, data); } -void SceneOpenGL::paintBackground( QRegion region ) - { - // TODO: implement me - //glClearColor(0, 0, 0, 1); - //glClear(GL_COLOR_BUFFER_BIT); +void SceneOpenGL::paintBackground(QRegion region) +{ + PaintClipper pc(region); + if (!PaintClipper::clip()) { + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + return; } + if (pc.clip() && pc.paintArea().isEmpty()) + return; // no background to paint + QVector verts; + for (PaintClipper::Iterator iterator; !iterator.isDone(); iterator.next()) { + QRect r = iterator.boundingRect(); + verts << r.x() + r.width() << r.y(); + verts << r.x() << r.y(); + verts << r.x() << r.y() + r.height(); + verts << r.x() << r.y() + r.height(); + verts << r.x() + r.width() << r.y() + r.height(); + verts << r.x() + r.width() << r.y(); + } + GLVertexBuffer vbo(GLVertexBuffer::Static); + vbo.setUseColor(true); + vbo.setUseShader(true); + vbo.setData(verts.count() / 2, 2, verts.data(), NULL); + m_colorShader->bind(); + vbo.render(GL_TRIANGLES); +} //**************************************** // SceneOpenGL::Texture