Vertex shading on scene while painting
I have a task of painting a heat map using some data points. The problem stems from my inability paint using a rectangle with vertex shading on a QGraphicsScene.
I read through http://doc.qt.io/qt-5/qtgui-openglwindow-example.html, but maybe I was just unable to understand it.
Might someone be able to link me to an example for drawing a rectangle with vertex shader having 4 different colors at its vertices?
@Ankit.Jain Well, you can subclass a QGraphicsItem and implement the paint() function of it. There you can draw using OpenGL functions if the painters paint engine is of the OpenGL type. If you pass a QGLwidget or these days a QOpenGLWidget to the setViewport() function of a QGraphicsView that is what you will get. I have done this with a QGLWidget and it worked well but I must admit I have not yet used a QOpenGLWidget in this way.
Why not give it a try it is quite easy to do for a simple rectangular object.
you can find how to do it here.
@kenchan Thanks for the idea. I had no idea that normal gl functions could be used with QOpenGLWidget. The answer turned out to be a bit easier after that. There is a function grabFramebuffer() which directly returns the image. Thanks again