cluttermm-1.0: Cairo context problem



Hello,

I have attached a simple code, please take a look, it just draws a circle. I have two problems and will really appreciate some help on *both* of them.

1. It crashes if I do:

Glib::RefPtr<Clutter::Cairo::Texture> circle = Clutter::Cairo::Texture::create(100, 100);
Glib::RefPtr<Cairo::Context> crmm = circle->create_context();

Of course everything is fine using C API:

ClutterActor *ctex = clutter_cairo_texture_new(100, 100);
cairo_t *cr = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(ctex));


2. It doesn't work when I try to wrap like this:

Glib::RefPtr<Cairo::Context> crmm(new Cairo::Context::Context(cr, true));

--
Aarto
#include <cluttermm.h>

int main(int argc, char** argv)
{
	Clutter::init(&argc, &argv);

	Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default();
	stage->set_size(200, 200);
	stage->set_color(Clutter::Color(0, 0, 0));
	stage->show();

	// Segfault
	/*
	Glib::RefPtr<Clutter::Cairo::Texture> circle = Clutter::Cairo::Texture::create(100, 100);
	Glib::RefPtr<Cairo::Context> crmm = circle->create_context();
	*/

	// Doesn't work
	/*
	Glib::RefPtr<Cairo::Context> crmm(new Cairo::Context::Context(cr, true));
	crmm->set_source_rgb(1.0, 1.0, 1.0);
	crmm->translate(50, 50);
	crmm->arc(0, 0, 50, 0, M_PI * 2);
	crmm->fill();
	*/
	
	ClutterActor *ctex = clutter_cairo_texture_new(100, 100);
	cairo_t *cr = clutter_cairo_texture_create(CLUTTER_CAIRO_TEXTURE(ctex));

	cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
	cairo_translate(cr, 50, 50);
	cairo_arc(cr, 0, 0, 50, 0, M_PI * 2);
	cairo_fill(cr);
	cairo_destroy(cr);

	Glib::RefPtr<Clutter::Actor> circle = Glib::wrap(ctex, true);

	circle->set_position(50, 50);
	stage->add_actor(circle);

	Clutter::main();
	return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]