Re: [clutter] Using cogl without clutter

2010-04-07 Thread Oscar Lazzarino
On Tue, Apr 6, 2010 at 6:07 PM, Robert Bragg b...@o-hand.com wrote:

 The long term goal is for Cogl to become a standalone 3D graphics API
 and we are incrementally working towards this goal.

 Cogl will also have a window system abstraction (only as far as
 framebuffer management is concerned, I don't mean anything relating
 input events etc) that could make it possible to integrate tightly with
 GTK in one way or another.

 Integrating with a GL context not owned by Cogl adds additional
 complexity but theoretically it would be possible to create a Cogl
 winsys that allowed this.

 Sorry that doesn't really help you, but you might be interested to know
 it may be possible one day.


OK, let's try lowering the bar ;-)

Would it be possible to use cogl_pango outside of the clutter_text
actor (i.e. in a custom actor)?

The cogl_pango functions are treated as private functions and not
documented, as far as I can see, and the simple approach

CoglColor *lWhite = cogl_color_new();
cogl_color_set_from_4f(lWhite, 1.0, 1.0, 1.0, 1.0);
cogl_set_source_color(lWhite);

PangoContext *lPangoCtx = pango_context_new();
PangoFontDescription *lPangoFontDescr = pango_font_description_new();
pango_font_description_set_family(lPangoFontDescr, Sans);
pango_font_description_set_size(lPangoFontDescr, 10 * PANGO_SCALE);
PangoLayout *lPangoLayout = pango_layout_new(lPangoCtx);
pango_layout_set_font_description(lPangoLayout, lPangoFontDescr);
pango_layout_set_text(lPangoLayout, Sopra la panca la capra
campa, strlen(Sopra la panca la capra campa));
cogl_pango_render_layout(lPangoLayout, mWidth/2, mHeight/2, lWhite, 0);

cogl_path_ellipse(mWidth/2.0, mHeight/2.0, mWidth/4.0, mHeight/4.0);
cogl_path_stroke();

cogl_color_free(lWhite);

shows me the ellipse, but not the text.

I get the message

(testCOGL:13610): CoglPango-CRITICAL **:
cogl_pango_get_renderer_from_context: assertion
`COGL_PANGO_IS_FONT_MAP (font_map)' failed

Any hints?

Thanks

O.
-- 
To unsubscribe send a mail to clutter+unsubscr...@o-hand.com



Re: [clutter] Using cogl without clutter

2010-04-07 Thread Emmanuele Bassi
On Wed, 2010-04-07 at 16:16 +0200, Oscar Lazzarino wrote:

 OK, let's try lowering the bar ;-)
 
 Would it be possible to use cogl_pango outside of the clutter_text
 actor (i.e. in a custom actor)?

yes.

 The cogl_pango functions are treated as private functions and not
 documented, as far as I can see, and the simple approach

the fact that are undocumented has nothing to do with whether they are
private or not. :-)

private functions in clutter or cogl are prefixed by an underscore.

 CoglColor *lWhite = cogl_color_new();
 cogl_color_set_from_4f(lWhite, 1.0, 1.0, 1.0, 1.0);

don't allocate a new CoglColor - use it on the stack:

  CoglColor white;

  cogl_color_set_from_4f (white, 1.0, 1.0, 1.0, 1.0);

 cogl_set_source_color(lWhite);
 
 PangoContext *lPangoCtx = pango_context_new();

use:

  layout = clutter_actor_create_pango_layout (actor, some text);

instead of creating the layout and context yourself.

 pango_font_description_set_family(lPangoFontDescr, Sans);
 pango_font_description_set_size(lPangoFontDescr, 10 * PANGO_SCALE);
 pango_layout_set_font_description(lPangoLayout, lPangoFontDescr);

 cogl_pango_render_layout(lPangoLayout, mWidth/2, mHeight/2, lWhite, 0);
 

this should work.

 shows me the ellipse, but not the text.
 
 I get the message
 
 (testCOGL:13610): CoglPango-CRITICAL **:
 cogl_pango_get_renderer_from_context: assertion
 `COGL_PANGO_IS_FONT_MAP (font_map)' failed
 
 Any hints?

yes: you should not use generic PangoCairo context and layouts, and use
the ones that Clutter creates for you. :-)

ciao,
 Emmanuele.

-- 
Emmanuele Bassi, Open Source Software Engineer
Intel Open Source Technology Center

-- 
To unsubscribe send a mail to clutter+unsubscr...@o-hand.com



Re: [clutter] Using cogl without clutter

2010-04-07 Thread Oscar Lazzarino
On Wed, Apr 7, 2010 at 4:43 PM, Neil Roberts n...@linux.intel.com wrote:

 You can't call the cogl_pango_* functions using a layout created with a
 regular pango context - instead it has to be a context created with the
 special Cogl font map. The cogl_pango functions in cogl-pango.h are
 meant to be public so it is safe to use them. The lack of documentation
 is an oversight not an attempt to hide them.

 The usual way to paint custom text in an actor is to call
 clutter_actor_create_pango_layout() and then render it with
 cogl_pango_render_layout(). This will take advantage of the CoglPango
 glyph cache and render the text from textures so it should be relatively
 efficient.

 Hope that helps

 - Neil


I did as you said, and it works :)

Actually, just out of curiosity, I also tried to create the Pango
context like this

PangoFontMap *lPangoFontMap = cogl_pango_font_map_new();
PangoContext *lPangoCtx = pango_font_map_create_context(lPangoFontMap);

and it also works.

Thanks to everyone who answered :)

O.
-- 
To unsubscribe send a mail to clutter+unsubscr...@o-hand.com