Problem using QPainter for overpainting in QGLWidget (textures destroyed)



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

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

    @void Scene3D::genTextures()
    {
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

    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 );
    glEnable(GL_TEXTURE_2D);

    glBindTexture( GL_TEXTURE_2D, textureID );

    glBegin(GL_QUADS);
    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);

    glEnd();
    glPopAttrib();@
    ...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!
    HELP!

    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.

    -BMS



  • 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
 

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