@@ -23,12 +23,13 @@ class QtGLBuffer : public IQtBuffer
2323 QRect rect () const OVERRIDE;
2424
2525private:
26- QRect drawRect ;
26+ QSurfaceFormat format ;
2727 QWindow window;
2828 QOpenGLContext context;
2929 QOpenGLFramebufferObjectFormat fbo_format;
3030 QOpenGLFramebufferObject *fbo;
3131 QOpenGLPaintDevice *device;
32+ QRect drawRect;
3233 QPainter painter;
3334 QImage image;
3435 bool painting;
@@ -37,11 +38,16 @@ class QtGLBuffer : public IQtBuffer
3738QtGLBuffer::QtGLBuffer (int width, int height)
3839 : painting(false )
3940{
41+ // format.setMajorVersion(3);
42+ // format.setMinorVersion(2);
43+
4044 window.setSurfaceType (QWindow::OpenGLSurface);
45+ window.setFormat (format);
4146 window.create ();
4247
48+ context.setFormat (format);
4349 if (!context.create ())
44- qFatal (" Cannot create the requested OpenGL context!" );
50+ qFatal (" Error: cannot create the requested OpenGL context!" );
4551 context.makeCurrent (&window);
4652
4753 drawRect = QRect (0 , 0 , width, height);
@@ -79,7 +85,7 @@ QPainter & QtGLBuffer::getPainter()
7985
8086QImage & QtGLBuffer::getImage ()
8187{
82- if (fbo-> isBound () )
88+ if (painting )
8389 {
8490 painter.end ();
8591 fbo->release ();
@@ -117,7 +123,7 @@ void QtGLWidget::paintEvent(QPaintEvent *event)
117123 QPainter painter;
118124 QRect dirtyRect = event->rect ();
119125 painter.begin (this );
120- painter.setRenderHint (QPainter::Antialiasing);
126+ painter.setRenderHints (QPainter::Antialiasing | QPainter::HighQualityAntialiasing );
121127 QImage & image = helper->getBuffer ()->getImage ();
122128 painter.drawImage (dirtyRect, image, dirtyRect);
123129 painter.end ();
0 commit comments