Graphics on Raspberry Pi with Qt 5

Graphics on Raspberry Pi with Qt 5

Given at Raspberry Pi Community meetup #14 at CLBC.
http://raspberrypi-tw-bdfa45.kktix.cc/events/meetup14

* Integrating OpenGL code into Qt 5 with the new QOpenGL* classes.
* Cross-compiling Qt for Raspbian, where those new classes are not generally available.[*]
* Next-generation support libraries Qt 3D and Qt 3D Canvas (not related with each other) coming with Qt 5.7.

[*]: You might also be interested in my cross-compiling notes.
https://gist.github.com/uranusjr/91c0086109e6c35bbbe48a0b6a405f78

9dafad54b5b4f360b7aae5f482bc1c91?s=128

Tzu-ping Chung

June 27, 2016
Tweet

Transcript

  1. Graphics on Raspberry Pi with Qt 5

  2. Agenda • OpenGL and Gt • Cross-compiling Qt 5.6 •

    Next generation 3D rendering
  3. Me • Call me TP • Follow @uranusjr • https://uranusjr.com

  4. www. .com

  5. Why Qt? • OpenGL is tedious • Long history of

    integration • Qt Quick and QML • Continuous improvements
  6. #include <QApplication> #include <QWidget> int main(int argc, char *argv[]) {

    QApplication app(argc, argv); QWidget w; w.show(); return app.exec(); }
  7. None
  8. How? • Widgets • Put things inside a widget •

    Put widgets in a window • Show windows in an application
  9. How? • Widgets • Add common GUI controls • Put

    widgets in a window • Show windows in an application
  10. How? • Widgets • Draw things with OpenGL • Put

    widgets in a window • Show windows in an application
  11. C++ Classes • QOpenGLWidget • QOpenGLContext • QOpenGLFunctions

  12. #include <QtWidgets/QOpenGLWidget> class MyWidget : public QOpenGLWidget { protected: //

    One-off settings. virtual void initializeGL(); // Set projection. Called on resizing. virtual void resizeGL(int w, int h); // Do actual OpenGL painting. virtual void paintGL(); }
  13. /usr/lib/x86_64-linux-gnu/qt5/examples/gui/openglwindow/

  14. Read the docs. http://doc.qt.io/qt-5/qopenglwidget.html

  15. Problems? • Legacy QtOpenGL module • Raspbian updates slowly •

    We want newer Qt
  16. Cross-Compiling • More up-to-date Qt distribution • Better support for

    add-on modules • Advanced tuning (if you want to)
  17. Read the wiki. https://wiki.qt.io/RaspberryPi_Beginners_Guide

  18. Read my notes. http://bit.ly/rpi-qt5-cross-compile

  19. Demo

  20. Qt 3D • Based on OpenGL • Simple C++ or

    QML usage • Quite powerful
  21. Qt 3D Canvas • Based on OpenGL • JavaScript API

    in Qt Quick • Modelled from WebGL • three.js port!