Nominate our 2022 Qt Champions!

Problem using QPainter for overpainting in QGLWidget (textures destroyed)

  • Sorry for my english.
    Translate translator from Google :).

    I took an official example about overpainting.
    Added there a method to load the texture from a jpeg file:

    @void Scene3D::genTextures()

    QPixmap pixMap(QString("../textures/test.jpg"));

    textureID = bindTexture( pixMap, GL_TEXTURE_2D);

    This method is called in the initializeGL().

    Then, in the method paintEvent() I put the following lines:
    @ glPushAttrib( GL_TEXTURE_BIT );

    glBindTexture( GL_TEXTURE_2D, textureID );

    glColor4f(1.0, 1.0, 1.0, 1.0);
    glTexCoord2d( 0, 0 );
    glVertex2f(-0.2, -0.2);

    glTexCoord2f( 1, 0 );
    glVertex2f(0.2, -0.2);

    glTexCoord2d( 1, 1 );
    glVertex2f(0.2, 0.2);

    glTexCoord2d( 0, 1 );
    glVertex2f(-0.2, 0.2);

    ...before creating qpainter to draw a quad with a texture.
    After starting the program all works well until about 1500 redraws. I see a square with a picture from a file.

    But then it seems the texture is destroyed. And I see just a white square!

    System: OpenSUSE Linux 11.4 64-bits.
    OpenGL renderer string: Gallium 0.4 on ATI RV530

    P.S. If you turn on the Software rendering, the picture does not change. I see just a white square!

  • I'm not overly familiar with ATI on linux, however, I watch my colleague suffer all day long attempting to get things working in opengl on ATI / linux. I know that there are problems with the win32 drivers esp with regard to texture management, and the code for the proprietary ATI drivers is mostly the same in windows and linux.

    What I would suggest is that:

    1. Verify your code is not at fault:
      Try on an NVidia setup using NVidia's proprietary driver.
      Also try with intel / mesa.
    2. Try using gDEBugger (search on google) to validate that you don't have hidden opengl issues.

    Good luck.


  • Thank you very much.
    I tried the computer with the drivers from Mesa and intel video:
    Mesa DRI Intel(R) 965GM GEM 20100330
    Mesa version 7.10
    The effect is the same :(

    But on Nvidia yesterday, if I remember correctly, the code worked good.

    It is interesting, but if you draw the texture using QGLFramebufferObject, for example:
    @glBindTexture( GL_TEXTURE_2D, texture_fbo->texture() );@
    everything is working well.

    I'll try in addition gDEBugger.

  • gDEBugger showed that after a while the texture object in memory exists, but its size is zero

Log in to reply