Results 1 to 3 of 3

Thread: How render native opengl and mix with QPainter on QwtPolarPlot?

  1. #1
    Join Date
    Mar 2016
    Posts
    19
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Question How render native opengl and mix with QPainter on QwtPolarPlot?

    Hi
    I need to mixed shader render opengl with QPainter that render on QwtPolarPlot that is inside of draw function of QwtPolarItem!!!
    but how can do this?
    I do that but don't see anything with follow code:
    Qt Code:
    1. class Item :public QwtPolarItem
    2. {
    3.  
    4.  
    5. void draw(QPainter *painter, const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
    6. const QPointF &pole, double radius, const QRectF &canvasRect)
    7. {
    8. Q_UNUSED(center);
    9. Q_UNUSED(elapsed);
    10.  
    11. painter->scale(0.1, 0.1);
    12. painter->setPen(...);
    13.  
    14. painter->setRenderHint(QPainter::HighQualityAntialiasing);
    15.  
    16. painter->drawPie(...);
    17.  
    18. painter->setPen(...);
    19. painter->drawEllipse(...);
    20. painter->setPen(...);
    21. painter->drawLine(...);
    22.  
    23. painter->setPen(...);
    24. painter->drawEllipse(...);
    25.  
    26. painter->save();
    27.  
    28. QMatrix mx;
    29. mx.reset();
    30. painter->setMatrix(mx);
    31.  
    32. painter->beginNativePainting();
    33. glClearColor(0, 0, 0, 1);
    34. glClear(GL_COLOR_BUFFER_BIT);
    35. glLoadIdentity();
    36. //glTranslatef(center.x(), center.y(), 0);
    37. glColor3b(255, 255, 255);
    38.  
    39. glBegin(GL_LINES);
    40. glVertex2d(0, 0);
    41. glVertex2d(100, 0);
    42. glVertex2d(0, 100);
    43. glVertex2d(100, 100);
    44. glEnd();
    45. glFlush();
    46. painter->endNativePainting();
    47.  
    48. painter->restore();
    49. }
    50. ...
    51. }
    To copy to clipboard, switch view to plain text mode 

    Also I know some mistake for example don't set clear color and clear color buffer and flush buffer.
    Also I must render first painter then opengl.
    please answer me for this code and typical way to render and please say any problem you see in my code.
    thanks.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,318
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How render native opengl and mix with QPainter on QwtPolarPlot?

    QwtPolarPlot is no QOpenGLWidget, so all you can do is to render to an FBO, translate it to an QImage and then draw the image.
    But converting a FBO into a QImage is an expensive operation and such a setup won't be the right setup if you need very high refresh rates.

    Uwe

  3. #3
    Join Date
    Mar 2016
    Posts
    19
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Question Re: How render native opengl and mix with QPainter on QwtPolarPlot?

    thanks @Uwe
    but I need to realtime and hight refresh rate so Do you say no any way to do that work in default render function qwtpolarItem?
    because QPainter is using opengl in background so should have a way for do this work,but why can't?

Similar Threads

  1. Replies: 2
    Last Post: 5th July 2017, 14:28
  2. Do offscreen render(openGL) with Qt5
    By stereoMatching in forum Qt Programming
    Replies: 4
    Last Post: 26th June 2013, 12:34
  3. QPainter native painting
    By Talei in forum Qt Programming
    Replies: 2
    Last Post: 25th September 2012, 20:52
  4. QPrinter & QPainter render() problem
    By Mannion in forum Qt Programming
    Replies: 31
    Last Post: 28th March 2012, 18:18
  5. OpenGL render to texture
    By Nicuvëo in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2011, 13:07

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.