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. QGLWidget and renderText using Blending Problem [solved]

QGLWidget and renderText using Blending Problem [solved]

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k 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
    stvokr
    wrote on last edited by
    #1

    Hi everyone,

    I have a project with a 2D drawing engine using QPainter as default and QGLWidget with OpenGL as option (which has better performance).
    Now I had to implement a blending function to display semi transparent rectangles (this is new stuff). And I also draw text using the renderText() function of the QGLWidget (this is old stuff). The renderText function works fine so far, but I is not working with blending enabled.

    Here is an example: "Example":http://abload.de/image.php?img=exampleblipy.png

    Does anyone has an idea or a workaround?
    I figured out something about overpainting but I don't how?

    GLWidget inherits QGLWidget

    My code:
    @GLWidget::drawScene()
    {
    ...

    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    glBegin( GL_POLYGON );
    glVertex2f( x1, y1);
    glVertex2f( x1, y2 );
    glVertex2f( x2, y2 );
    glVertex2f( x2, y1 );
    glEnd();

    glDisable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_SRC_ALPHA );

    ...

    qglColor( Qt::black );
    renderText( x, y, text );
    }
    @

    regards,
    Oliver

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stvokr
      wrote on last edited by
      #2

      Hi everyone,

      as always it was my fault. That code above is not the whole code. I used glPolygonMode( GL_FRONT, GL_FILL ); to setup the fill mode of the Polygon. After drawing the polygon I reseted the polygonMode to GL_LINE, which is wrong. That causes the error.

      regards
      Oliver

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Glad you found out and thanks for sharing the solution !

        Can you also update the thread title prepending [solved] so other forum users may know a solution has been found :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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