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. replacing QGLWidget in QOpenGLWidget is not working

replacing QGLWidget in QOpenGLWidget is not working

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 366 Views
  • 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.
  • S Offline
    S Offline
    sueyllam
    wrote on last edited by
    #1

    I have the following slot in a program written for Qt4:

    void MyGLWidget::newAVIImage(QImage image)
    {
        //image = image.mirrored();
    //    bindTexture(image);
          glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.bits());
        update();
    }
    

    As shown porting this to Qt5 by using QOpenGLWidget instead of QGLWidget by replacing updateGL with update and replacing bindtexture with glTexImage2D and generating and binding an unsigned int to GL_TEXTURE_2D in initializeGL. gives a white window (the original Qt4 worked fine). Also, after running the Qt5 version, trying to revert to the original Qt4 version gives a white screen with a
    DirectShow renderer error for a while, then later the Qt4 version is working again.
    Is there an explanation for this behavior, also what is the correct way for replacing bindtexture in QGLWidget?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sueyllam
      wrote on last edited by
      #2
      void MyGLWidget::newAVIImage(QImage image)
      {
      	static int ss =0;
          image = image.mirrored();
      //    bindTexture(image);
      	glBindTexture(GL_TEXTURE_2D, m_tex);
      	image = image.convertToFormat(QImage::Format_RGB888);
              if (ss==0) {
      	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.bits());
      	ss=1;
      }
      else {
      	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image.width(), image.height(), GL_RGB, GL_UNSIGNED_BYTE, image.bits());
      }
      
          update();
      }
      
      

      The above code solved the problem, that is using glTexImage2D for all frames was the culprit, it should be used only for the first frame. Subseqent frames should use glTexSubImage2D.

      1 Reply Last reply
      0
      • S sueyllam has marked this topic as solved on

      • Login

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