Use color shader to render the background
This commit is contained in:
parent
ae95ab0c43
commit
2703a23abf
1 changed files with 26 additions and 5 deletions
|
@ -247,9 +247,30 @@ void SceneOpenGL::paintGenericScreen(int mask, ScreenPaintData data)
|
||||||
|
|
||||||
void SceneOpenGL::paintBackground(QRegion region)
|
void SceneOpenGL::paintBackground(QRegion region)
|
||||||
{
|
{
|
||||||
// TODO: implement me
|
PaintClipper pc(region);
|
||||||
//glClearColor(0, 0, 0, 1);
|
if (!PaintClipper::clip()) {
|
||||||
//glClear(GL_COLOR_BUFFER_BIT);
|
glClearColor(0, 0, 0, 1);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pc.clip() && pc.paintArea().isEmpty())
|
||||||
|
return; // no background to paint
|
||||||
|
QVector<float> 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//****************************************
|
//****************************************
|
||||||
|
|
Loading…
Reference in a new issue