Skip to content

Commit 4bf67bf

Browse files
author
Gary Huang
committed
Add QSurfaceFormat to QtGLBuffer
1 parent 200f1ad commit 4bf67bf

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/PGlobal/pglobal.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,24 @@
4343
PB(keyReleased) \
4444
PB(keyTyped)
4545

46-
#ifndef DETECTCXX0X
47-
#define OVERRIDE
46+
#ifndef __has_feature // Optional of course.
47+
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
48+
#endif
49+
50+
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
51+
# define P_COMPILER_EXPLICIT_OVERRIDES
52+
#endif
53+
54+
#ifdef P_COMPILER_EXPLICIT_OVERRIDES
55+
# define OVERRIDE override
56+
# define FINAL final
4857
#else
49-
#define OVERRIDE override
58+
# ifndef OVERRIDE
59+
# define OVERRIDE
60+
# endif
61+
# ifndef FINAL
62+
# define FINAL
63+
# endif
5064
#endif
5165

5266
PROCESSING_BEGIN_NAMESPACE

src/QtEngine/qtglcanvas.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ class QtGLBuffer : public IQtBuffer
2323
QRect rect() const OVERRIDE;
2424

2525
private:
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
3738
QtGLBuffer::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

8086
QImage & 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

Comments
 (0)