Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

Tzu-ping Chung

June 27, 2016
Tweet

More Decks by Tzu-ping Chung

Other Decks in Programming

Transcript

  1. Graphics on Raspberry Pi
    with Qt 5

    View full-size slide

  2. Agenda
    • OpenGL and Gt
    • Cross-compiling Qt 5.6
    • Next generation 3D rendering

    View full-size slide

  3. Me
    • Call me TP
    • Follow @uranusjr
    • https://uranusjr.com

    View full-size slide

  4. Why Qt?
    • OpenGL is tedious
    • Long history of integration
    • Qt Quick and QML
    • Continuous improvements

    View full-size slide

  5. #include
    #include
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QWidget w;
    w.show();
    return app.exec();
    }

    View full-size slide

  6. How?
    • Widgets
    • Put things inside a widget
    • Put widgets in a window
    • Show windows in an application

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  9. C++ Classes
    • QOpenGLWidget
    • QOpenGLContext
    • QOpenGLFunctions

    View full-size slide

  10. #include
    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();
    }

    View full-size slide

  11. /usr/lib/x86_64-linux-gnu/qt5/examples/gui/openglwindow/

    View full-size slide

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

    View full-size slide

  13. Problems?
    • Legacy QtOpenGL module
    • Raspbian updates slowly
    • We want newer Qt

    View full-size slide

  14. Cross-Compiling
    • More up-to-date Qt distribution
    • Better support for add-on modules
    • Advanced tuning (if you want to)

    View full-size slide

  15. Read the wiki.
    https://wiki.qt.io/RaspberryPi_Beginners_Guide

    View full-size slide

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

    View full-size slide

  17. Qt 3D
    • Based on OpenGL
    • Simple C++ or QML usage
    • Quite powerful

    View full-size slide

  18. Qt 3D Canvas
    • Based on OpenGL
    • JavaScript API in Qt Quick
    • Modelled from WebGL
    • three.js port!

    View full-size slide