Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QOpenglWindow PaintGL() Native gl calls cause painter to disappear SOLVED

QOpenglWindow PaintGL() Native gl calls cause painter to disappear SOLVED

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 825 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tdphys
    wrote on last edited by
    #1

    I've subclassed a QOpenglWindow, connected its update slot to its frameSwapped signal, and it merrily animates along.

    I'm able to use Qpainter on the window to render some nice animated text, with glClear wiping the buffer each frame.

    However, when I add some more fancy gl calls, the painter stuff gets wiped out. Remove the other gl calls, it's back. I've tried painting before and after the gl calls, wrapping them in beginNativePanting() and endNativePainting(), to no avail. Does anybody have any ideas?

    Thanks

    Here's my paintGL function, minus some non-drawing animation stuff:
    @
    void PlaybackWindow::paintGL()
    {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
                    
                                                                               
                                                                               
    //painter.beginNativePainting();                                           
    
    
    m_program->bind();
    
    QMatrix4x4 matrix;
    matrix.setToIdentity();
    matrix.perspective(60, 4.0/3.0, 0.1, 100.0);
    matrix.lookAt(QVector3D(0.0,8.0,-20.0),QVector3D(0,0,0),QVector3D(0,1,0));
    m_program->setUniformValue(m_matrixUniform, matrix);
    

    if(validbuffer && pb1size > 0)
    {
    glBindBuffer(GL_ARRAY_BUFFER,vertex_buffer_1);
    glEnableVertexAttribArray(m_posAttr);
    glVertexAttribPointer(m_posAttr,3 , GL_FLOAT, GL_FALSE, 0, 0);

        glPointSize(4);
        glDrawArrays(GL_POINTS, 0, pb1size);
    }
    
    
    glDisableVertexAttribArray(m_posAttr);
    
    m_program->release();
    

    //painter.endNativePainting();

    QPainter painter;
    painter.begin(this);
    painter.setPen(Qt::white);
    painter.setFont(QFont("Arial", 30));
    painter.drawText(10,120, QString::number(m_Engine->GetFrameNum()) );
    painter.end();
    }
    @

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tdphys
      wrote on last edited by
      #2

      FIxed it by declaring

      glBindBuffer(GL_ARRAY_BUFFER,0);

      after releasing the program.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved