Have a go hero – Creating a supporting border for RegularPolygon

What is returned by updatePaintNode() may not just be a single QSGGeometryNode but also a larger tree of QSGNode items. Each node can have any number of child nodes. By returning a node that has two geometry nodes as children, you can draw two separate shapes in the item:

As a challenge, extend RegularPolygon to draw not only the internal filled part of the polygon but also an edge that can be of a different color. You can draw the edge using the GL_QUAD_STRIP drawing mode. Coordinates of the points are easy to calculate—the points closer to the middle of the shape are the same ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.