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 Slide

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

    View Slide

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

    View Slide

  4. www. .com

    View Slide

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

    View Slide

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

    View Slide

  7. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  12. #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 Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  19. Demo

    View Slide

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

    View Slide

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

    View Slide