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. Qpainter and OpenGL - Window, Qt 3.3.4
Forum Updated to NodeBB v4.3 + New Features

Qpainter and OpenGL - Window, Qt 3.3.4

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.0k Views 1 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.
  • P Offline
    P Offline
    ptrle
    wrote on last edited by
    #1

    Hi,

    I have a problem with draw ellipse in an OpenGL window.
    OS is Windows 7 and 8 and Qt 3.3.4.
    The problem is that the ellipse has white background and is not white.
    Maybe someone has an idea? Thank you

    greeting

    Peter

    @
    void GLBox::paintGL()
    {
    QPainter *p = new QPainter();
    p->begin(this);
    p->setPen(QPen(white,2)); // xxx xx x
    p->setRasterOp(XorROP);
    p->drawEllipse(10,10, 100,100);
    p->end();

    glClear( GL_COLOR_BUFFER_BIT );
    
    glLoadIdentity();
    glTranslatef( 0.0, 0.0, -10.0 );
    glScalef( scale, scale, scale );
    
    glRotatef( xRot, 1.0, 0.0, 0.0 ); 
    glRotatef( yRot, 0.0, 1.0, 0.0 ); 
    glRotatef( zRot, 0.0, 0.0, 1.0 );
    
    glCallList( object );
    

    }
    @

    !https://www.hidrive.strato.com/wget/HaRk3Vej()!

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

      Hi and welcome to devnet,

      Are you really using Qt 3.3.4 ?

      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
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Judging from the setRasterOp() he really is.

        If it's a new or relatively small app please please upgrade. It's been over a decade for Qt3 and the API has gone through 2 major revisions and a dozen of smaller ones. It's gonna be very hard getting any support for Qt3 since very few people remember it.

        That being said what I say might not be true for Qt3.
        Ellipse is drawn using a pen for the border and a brush for the filling. Try setting a transparent brush on the painter first. Another thing is that you're drawing with painter first and then using OpenGL to clear the window. This is weird.
        With the XOR mode selected it's basically src xor dst. If the background is white before drawing then xoring it with white ellipse would result in black color. I'm guessing that's what you're seeing.
        I would clear the screen to black first and overdraw with painter. If that doesn't help fill the window with black rectangle using QPainter first. Maybe it's a weird interaction of QPainter and OpenGL, but I can't really say, since this sort of thing is done completely different in modern Qt.

        Btw. you have a memory leak (not releasing p). The usual way to work with QPainter is to create it on the stack, pass this in the constructor and not to call the begin/end pair (these are more for when you get a painter pointer from somewhere). Effectively you're now creating another dangling pointer every time you draw.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          ptrle
          wrote on last edited by
          #4

          Unfortunately I have no budget for new version of Qt.
          And I do not come on.
          You might have an example code?
          I need to draw a white ellipse(qpainter) on Opengl windows
          thanks

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Sorry. I can't help you with a sample. These days you would use methods like beginNativePainting() or QOpenGLPaintDevice class which didn't exist in Qt3.

            Have you tried my suggestions (drawing opengl first and drawing a black rectangle first)?

            As for the price - do you know that since Qt4 there's a free LGPL/GPL license?

            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