O'Reilly logo

Game Programming Using Qt by Lorenz Haas, Witold Wysota

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating a regular polygon item

Let's learn about the scene-graph by delivering an item class for rendering convex regular polygons. We will draw the polygon using the OpenGL drawing mode called "triangle fan." It draws a set of triangles that all have a common vertex. Subsequent triangles are defined by the shared vertex, the vertex from the previous triangle, and the next vertex specified. Have a look at the diagram to see how to draw a hexagon as a triangle fan using 8 vertices as control points:

Time for action – creating a regular polygon item

The same method applies for any regular polygon. The first vertex defined is always the shared vertex occupying the center of the shape. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required