[QOpenGLWidget] image overshadows main windows



  • Hello!
    I use qt-5.5.1 on Linux x64.
    In application main window I add QOpenGLWidget and inherit from it to subclass.
    Follow subclass code:
    GLWidget::GLWidget(QWidget *parent) :
    QOpenGLWidget(parent)
    {}
    GLWidget::~GLWidget()
    {
    glDeleteTextures(CHANNEL_MAX, _texture);
    }
    void GLWidget::add(QImage image, quint8 pos)
    {
    if (pos < CHANNEL_MAX) {
    qDebug() << func << "add position" << pos;
    glActiveTexture(GL_TEXTURE0 + pos);
    glBindTexture(GL_TEXTURE_2D, _texture[pos]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(),
    0, GL_RGB, GL_UNSIGNED_BYTE, image.constBits());
    update();
    }
    }
    void GLWidget::initializeGL()
    {
    initializeOpenGLFunctions();
    glClearColor(0, 0, 0, 1);
    glEnable(GL_TEXTURE_2D);
    glGenTextures(CHANNEL_MAX, _texture);
    }
    void GLWidget::paintGL()
    {
    qDebug() << func;
    glDrawArrays(GL_TEXTURE_2D_ARRAY, _texture[0], CHANNEL_MAX);
    }
    void GLWidget::resizeGL(int w, int h)
    {}

    All work, but I have several problems:

    • image overshadows mainwindows
    • I always see only one image, but I wait several images to one line

    How can I solve this problem?
    Thank you and excuse my bad english.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.