Hi,
Is it possible to implement a container that renders to an offscreen
framebuffer object and have a ClutterTexture as a child? As far as I
understand, the implementation of cogl_draw_buffer and its usage in
ClutterTexture makes that impossible.
What I have in my mind is a class, say, FancyEffectContainer that
implements a ClutterContainer interface. This is what happens in its
paint function:
---8<--
CoglHandle texture;
CoglHandle offscreen;
texture = cogl_texture_new_with_size (width_of_container,
height_of_container, 0, 0, COGL_PIXEL_FORMAT_RGBA_4444);
offscreen = cogl_offscreen_new_to_texture (texture);
cogl_draw_buffer (COGL_OFFSCREEN_BUFFER, offscreen);
for (each child) {
paint(child);
}
cogl_draw_buffer (COGL_WINDOW_BUFFER, COGL_INVALID_HANDLE);
/* Paint the offscreen buffer using fancy effects. */
---8<---
The problem is that ClutterTexture has the following statements in
its paint function:
---8<---
/* Redirect drawing to the fbo */
cogl_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->fbo_handle);
...
/* Restore drawing to the frame buffer */
cogl_draw_buffer (COGL_WINDOW_BUFFER, COGL_INVALID_HANDLE);
---8<---
As far as I understand, the offscreen rendering of my
FancyEffectContainer is canceled when (and after) a ClutterTexture
paints its content as a child of my container. The buffer cannot be
redirected and restored recursively with the cogl_draw_buffer function.
I think the drawing buffer should be put on a stack, so that when an
actor resumes from offscreen rendering, a possible earlier offscreen
buffer is restored instead of the window buffer. This is what I mean:
Container:
---8<---
cogl_push_draw_buffer (COGL_OFFSCREEN_BUFFER, offscreen);
for (each child) {
paint(child);
}
/* Restore to the window buffer or a previous frame buffer */
cogl_pop_draw_buffer ();
/* Paint the offscreen buffer using fancy effects. */
---8<---
Child, such as ClutterTexture:
---8<---
/* Redirect drawing to the fbo */
cogl_push_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->fbo_handle);
...
/* Restore drawing to the frame buffer */
cogl_pop_draw_buffer ();
---8<---
Or have I misunderstood the whole thing?
BR,
Henrik
--
Henrik Hedberg - http://www.henrikhedberg.net/
--
To unsubscribe send a mail to [email protected]