Luca Bruno <letha...@gmail.com> wrote:
> In addition to this consider that the example never tries to read
> pixels, therefore the journal is useless (this is the main reason why
> journal exists if I'm not wrong).
The journal is more useful than just an optimisation for avoiding
glReadPixels. In fact that was only added relatively recently and the
journal has existed for much longer. Without the journal any quads to
draw would have to be submitted to OpenGL individually with separate
draw calls. GPUs are designed to be efficient for drawing large batches
of geometry and there can therefore be a fairly large overhead to set up
the drawing pipeline. If you go through this effort to only paint one
quad then the overhead is pretty much wasted.
In the crate example the crate is actually drawn using a CoglPrimitive
instead of drawing rectangles so it doesn't actually use the journal at
all. I'd imagine the reason you're seeing upload_vertices being called
is instead because of the text. The glyphs for short runs of text are
rendered using cogl_rectangles which ends up getting put in the
journal. In this particular example the journal doesn't actually help
much because because there is only one label. But usually in a typical
2D application there will be many quads in a single frame which can
benefit a lot from being batched together.
If you use Cogl to make a 3D-style game where the models are drawn using
CoglPrimitives then the journal will stay out of the way and you can
have more direct control over how stuff is rendered. However if you want
the convenience of just being able to paint rectangles without having to
collaborate with other components of the application to get it to render
efficiently (like Clutter would) then the journal can help a lot.
Regards,
- Neil