mardi 21 avril 2015

OpenGL dont clear to fill background color

I write the code to use OpenGL in Qt widget, this code like this:

GL_Widget::GL_Widget(QWidget *parent) :
    QGLWidget(parent)
{
}
void GL_Widget::initializeGL()
{
    glClearColor(0.2,0.2,0.2,1);
}

void GL_Widget::paintGL()
{
   glClear(GL_COLOR_BUFFER_BIT);
}

but the widget dont clear correct color as I code, it display background of desktop like the below image though I already set up widget inherit with my widget class, and set up the background of widget use style sheet. If I draw something like triangles, it clear correctly.But my purpose want clear it dont need to draw, so how can I do that?

Aucun commentaire:

Enregistrer un commentaire