Added cogl callbacks for more control over rendering
Recently, I've been trying to create a simple 3D game using Cogl for rendering and with a Clutter HUD. However, I encountered a difficulty - although it is possible to embed a CoglPrimitive
in a ClutterPaintNode
, one cannot do much with it and the whole support seems rudimentary. This was my motivation for writing this patch.
This patch incorporates a new callback type, which is passed all the essential parameters. I decided to consider as essential the parameters used by cogl_primitive_draw
(obviously except the self
parameter). The callback has a closure and possibly a closure destructor. This patch integrates it fully with the CoglPaintOperation
system and to all existing CoglPaintNode
subclasses.
Calls to the callback are surrounded by matrix save operations, so the callback must not worry about preserving the matrix. It can manipulate the frame buffer's stacks but it must do it without disrupting it (unbalanced push/pop) and in order (no pop before push).
This patch also includes a short sample program called rotating-cube
. It actually serves both as a Clutter and Cogl demo. The sample, as the name suggests, shows a cube covered by different colors which rotates around some weird vector I chose spontaneously. It resembles glxgears
in spirit.
The areas involved with the patch were tested, the only thing that might need fixing is the reaction of the cube to window resizing in the example (I chose for the cube not to enlarge but to go to the center of the stage). Also, as the documentation for cogl_backend_get_cogl_context()
states, it might currently not work on native macOS, but I suppose it will be fixed at some time.