Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Problem using QPainter for overpainting in QGLWidget (textures destroyed)
Forum Update on Monday, May 27th 2025

Problem using QPainter for overpainting in QGLWidget (textures destroyed)

Scheduled Pinned Locked Moved Game Development
4 Posts 2 Posters 3.5k 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.
  • I Offline
    I Offline
    ilisashka
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bms20
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ilisashka
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          ilisashka
          wrote on last edited by
          #4

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

          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