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. OpenGL antialiasing problem
Forum Updated to NodeBB v4.3 + New Features

OpenGL antialiasing problem

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 3.2k Views 2 Watching
  • 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.
  • X Offline
    X Offline
    Xumepoc
    wrote on last edited by
    #1

    Hi fellow programers.
    I have a problem with antialiasing in a QOpenGLWidget dirived widget. In the paintEvent I have

     QPainter painter(this);
     painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
    
    if(refreshAll)
    {
            QPixmap tmpP(width(), height());
            tmpP.fill(QColor(90,90,90));
            QPainter painter_tmp(&tmpP);
            painter_tmp.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
    
          //Some drawing here
    ....
           BackGroundMapP = tmpP.copy(0,0,tmpP.width(), tmpP.height()); //BackGroundMapP is s Pixmap
            refreshAll= false;
    }
    painter.drawPixmap(0,0,BackGroundMapP);
    
    //Some more drawing here
    .....
    
    qDebug() << painter.renderHints(); // This is showing that the flags are set OK.
    

    But the result is without Antialiasing or Text Antialiasing for everything drawn by painter. If I test to see if the flags are set correctly I get that they are. All drawn with painter_tmp is Antialiased though!! So what could be the problem? Apparently there are no driver problems, as everything drawn with painter_tmp is working fine.

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

      Hi,

      What version of Qt ? On what OS ?

      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
      • X Offline
        X Offline
        Xumepoc
        wrote on last edited by
        #3

        Hi,
        It is happening with Qt 5.4.1 on Windows 7 and on Qt 5.6.1 on Windows 10.

        D 1 Reply Last reply
        0
        • X Xumepoc

          Hi,
          It is happening with Qt 5.4.1 on Windows 7 and on Qt 5.6.1 on Windows 10.

          D Offline
          D Offline
          Devopia53
          wrote on last edited by
          #4

          @Xumepoc

          Hi.

          Have you set the surface format for the widget or app.?

          1 Reply Last reply
          0
          • X Offline
            X Offline
            Xumepoc
            wrote on last edited by
            #5

            Well I set the attribute for the app

            a.setAttribute(Qt::AA_UseDesktopOpenGL);
            

            Do I have to set the QSurfaceFormat for the widget too?

            D 1 Reply Last reply
            0
            • X Xumepoc

              Well I set the attribute for the app

              a.setAttribute(Qt::AA_UseDesktopOpenGL);
              

              Do I have to set the QSurfaceFormat for the widget too?

              D Offline
              D Offline
              Devopia53
              wrote on last edited by
              #6

              @Xumepoc

              Of course you need to set the surface format for the widget or app.
              A.setAttribute (Qt :: AA_UseDesktopOpenGL) has nothing to do with this problem.

              1 Reply Last reply
              2
              • X Offline
                X Offline
                Xumepoc
                wrote on last edited by Xumepoc
                #7

                Yep :D :D you were completely right. Set it to sample 10 and everything is crisp and smooth. Thank you very much.

                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