News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer...

36
1 News from the Graphics Stack: Improvements to the core OpenGL enablers in Qt 5.3 & 5.4 Laszlo Agocs The Qt Company © 2014 The Qt Company

Transcript of News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer...

Page 1: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

1

News from the Graphics Stack:Improvements to the core OpenGL enablers in Qt 5.3 & 5.4

Laszlo AgocsThe Qt Company

© 2014 The Qt Company

Page 2: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

2

Who am I?

● Senior software engineer at The Qt Company (formerly Digia) inOslo, Norway

● OpenGL, graphics, windowing systems, platform integration

● Previously at ARM and Nokia

© 2014 The Qt Company

Page 3: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

3

Why are we here?

● QQuickWidget● QQuickRenderControl● QOpenGLWidget● QOpenGLWindow● QRasterWindow

© 2014 The Qt Company

Page 4: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

4

The long road to QQuickWidget

© 2014 The Qt Company

Page 5: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

5 © 2014 The Qt Company

OpenGL in Qt 4

Page 6: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

6 © 2014 The Qt Company

Qt 4

Native windows

Page 7: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

7 © 2014 The Qt Company

Qt 5.0

● QWindow, QOpenGLContext, QSurfaceFormat● QQuickWindow, QQuickView● QGL*

Page 8: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

8 © 2014 The Qt Company

Qt 5.1

● QWidget::createWindowContainer()

Page 9: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

9 © 2014 The Qt Company

Qt 5.3

● New concept: Avoid native windows, render offscreen and composite in thewidget stack

● Essential for embedded

● QQuickWidget

Page 10: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

10 © 2014 The Qt Company

QQuickWidget

is alwaysbetter than

Page 11: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

11 © 2014 The Qt Company

black hasalpha == 0

Page 12: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

12 © 2014 The Qt Company

And it just works. Even on embedded.

A QWidget with two QOpenGLWidgetsrunning on i.MX6 Sabre LITE on eglfs

A Qt Quick 2 scene embedded into a widget UIusing QQuickWidget

Page 13: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

13 © 2014 The Qt Company

● Does this mean all widget apps require OpenGL from now on? No.

● Does this support multisampling? Yes.

● Qt::WA_AlwaysStackOnTop

Composition

Page 14: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

14 © 2014 The Qt Company

● Mirrors QQuickView

● Except that it is a QWidget

QQuickWidget API

Page 15: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

15

QQuickRenderControl

● QQuickWidget● QQuickRenderControl● QOpenGLWidget● QOpenGLWindow● QRasterWindow

© 2014 The Qt Company

Page 16: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

16 © 2014 The Qt Company

QQuickRenderControl

Page 17: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

17 © 2014 The Qt Company

QQuickRenderControl

● No on-screen QQuickWindow.

● The rendering of the scene is redirected into a FBO.

● Texture can be used in arbitrary ways. No costly readbacks.

● Need to send input to Quick? QCoreApplication::sendEvent()

● Integrate Quick into external engines, not the other way round.

Page 18: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

18

QOpenGLWidget

● QQuickWidget● QQuickRenderControl● QOpenGLWidget● QOpenGLWindow● QRasterWindow

© 2014 The Qt Company

Page 19: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

19 © 2014 The Qt Company

Qt 5.4

● Back to widgets. No more boring QML stuff.

● QOpenGLWidget is here

● R.I.P. QGLWidget

10 QOpenGLWidget instances inone top-level window

Page 20: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

20 © 2014 The Qt Company

QOpenGLWidget

● Basic API is familiar

● Can open a QPainter on it

● Utilities like bindTexture() are gone → QOpenGLTexture

Page 21: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

21

QOpenGLWidget

One visible native window only, unlikeQGLWidget.

Page 22: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

22 © 2014 The Qt Company

Animation

● QTimer::singleShot(16, m_legacyQGLWidget, SLOT(updateGL()))

● Swap interval defaults to 1 since Qt 5.3

● QSurfaceFormat::setSwapInterval()

● Schedule repaints with update() and rely on vsync

● Timers with small intervals can be useful, but know what you are doing

Page 23: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

23 © 2014 The Qt Company

Formats and contexts

● QSurfaceFormat::setDefaultFormat()

● Easy to request OpenGL 3+ or core profile for everything in the app

● The new compositing architecture relies heavily on multiple contexts andresource sharing.

● QOpenGLWidget comes with documentation. Use it.

Page 24: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

24 © 2014 The Qt Company

Formats and contexts, cont.

Context 1 Context 2 Context 3 Context 4

Window 1 with twoQOpenGLWidgets

TLW context 1 TLW context 2

Window 2 with twoQOpenGLWidgets

Page 25: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

25 © 2014 The Qt Company

Formats and contexts, cont.

● Qt::AA_ShareOpenGLContexts

Context 1 Context 2 Context 3 Context 4

Window 1 with twoQOpenGLWidgets

Global share context

shar

e

shar

e

TLW context 1 TLW context 2

Window 2 with twoQOpenGLWidgets

Page 26: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

26 © 2014 The Qt Company

High DPI screens

● OpenGL operates in pixel dimensions on retina screens.

● new QOpenGLFramebufferObject(w->devicePixelRatio() * w->size())

● Qt takes care of all the internal framebuffers and viewports. The rest is up to you.

● Watch out for screen changes● screenChanged(QScreen*) signal for QWindow● ScreenChangeInternal event for QWidget

Page 27: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

27

QOpenGLWindow

● QQuickWidget● QQuickRenderControl● QOpenGLWidget● QOpenGLWindow● QRasterWindow

© 2014 The Qt Company

Page 28: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

28 © 2014 The Qt Company

QWindow

● Enough of widgets,I don't want your push buttons.

● QWindow is fine for you then.

● Lightweight and powerful, but...

Page 29: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

29 © 2014 The Qt Company

QOpenGLWindow

Page 30: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

30

QRasterWindow

● QQuickWidget● QQuickRenderControl● QOpenGLWidget● QOpenGLWindow● QRasterWindow

© 2014 The Qt Company

Page 31: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

31 © 2014 The Qt Company

QRasterWindow

● QOpenGLWidget has a little brother: QRasterWindow

● Exactly what the name suggests. Nothing more, nothing less.

Page 32: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

32

Summary

● QQuickWidget● QQuickRenderControl● QOpenGLWidget● QOpenGLWindow● QRasterWindow

© 2014 The Qt Company

Page 33: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

33 © 2014 The Qt Company

Qt Quick 2 application QQuickView orQQmlApplicationEngine

OpenGL without any need for Qtwidgets

QOpenGLWindow

Custom QPainter-based drawingwithout Qt widgets

QRasterWindow

OpenGL content in a widget-basedapplication

QOpenGLWidget

Qt Quick 2 content in a widget-based application

QQuickWidget

Qt Quick 2 content used as atexture in a custom OpenGLrenderer

QOpenGLWindow +QQuickRenderControl

Page 34: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

34

What was left out

● Dynamic OpenGL implementation loading on Windows

● Adoption of existing native OpenGL contexts

© 2014 The Qt Company

Page 35: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

© 2014 The Qt Company

Thank you!

www.qt.io

Page 36: News from the Graphics Stack: Improvements to the core ... · 2 Who am I? Senior software engineer at The Qt Company (formerly Digia) in Oslo, Norway OpenGL, graphics, windowing systems,

© 2014 The Qt Company

www.qt.io

See you there!