2007-05-04 23:53:49 +00:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
#ifdef USE_PIXBUF
|
2007-05-04 23:53:49 +00:00
|
|
|
GdkPixbuf*
|
|
|
|
make_pixbuf (int width, int height, int bpp, int has_alpha)
|
|
|
|
{
|
|
|
|
#define CHECK_SIZE 20
|
|
|
|
|
|
|
|
GdkPixbuf *px;
|
|
|
|
gint x,y, rowstride, n_channels, i = 0;
|
|
|
|
|
|
|
|
px = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
|
|
|
|
has_alpha,
|
|
|
|
8,
|
|
|
|
width,
|
|
|
|
height);
|
|
|
|
|
|
|
|
if (!px) return NULL;
|
|
|
|
|
|
|
|
rowstride = gdk_pixbuf_get_rowstride (px);
|
|
|
|
n_channels = gdk_pixbuf_get_n_channels (px);
|
|
|
|
|
2007-07-26 11:04:04 +00:00
|
|
|
for (y = 0; y < height; y++)
|
2007-05-04 23:53:49 +00:00
|
|
|
{
|
|
|
|
i = 0;
|
2007-07-26 11:04:04 +00:00
|
|
|
for (x = 0; x < width; x++)
|
2007-05-04 23:53:49 +00:00
|
|
|
{
|
2007-07-26 11:04:04 +00:00
|
|
|
guchar *p;
|
2007-05-04 23:53:49 +00:00
|
|
|
|
|
|
|
p = gdk_pixbuf_get_pixels (px) + y * rowstride + x * n_channels;
|
|
|
|
|
|
|
|
p[0] = p[1] = p[2] = 0; p[3] = 0xff;
|
|
|
|
|
|
|
|
if (x && y && y % CHECK_SIZE && x % CHECK_SIZE)
|
|
|
|
{
|
|
|
|
if (x % CHECK_SIZE == 1)
|
|
|
|
{
|
|
|
|
if (++i > 3)
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
p[i] = 0xff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SPIN() while (g_main_context_pending (NULL)) \
|
|
|
|
g_main_context_iteration (NULL, FALSE);
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
#endif
|
2007-05-04 23:53:49 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
#ifdef USE_PIXBUF
|
2007-05-04 23:53:49 +00:00
|
|
|
ClutterActor *texture;
|
|
|
|
ClutterActor *stage;
|
|
|
|
GdkPixbuf *pixbuf;
|
2008-04-25 13:37:36 +00:00
|
|
|
gint i, j;
|
2007-05-04 23:53:49 +00:00
|
|
|
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
|
|
|
|
stage = clutter_stage_get_default ();
|
|
|
|
clutter_actor_show_all (CLUTTER_ACTOR (stage));
|
|
|
|
|
|
|
|
SPIN();
|
|
|
|
|
|
|
|
for (i=100; i<5000; i += 100)
|
2007-05-09 23:31:08 +00:00
|
|
|
for (j=0; j<4; j++)
|
|
|
|
{
|
|
|
|
pixbuf = make_pixbuf (i+j, i+j, 4, TRUE);
|
|
|
|
|
|
|
|
if (!pixbuf)
|
|
|
|
g_error("%ix%i pixbuf creation failed", i+j, i+j);
|
|
|
|
|
|
|
|
printf("o %ix%i pixbuf... ", i+j, i+j);
|
2008-04-25 13:37:36 +00:00
|
|
|
|
|
|
|
texture = clutter_texture_new ();
|
|
|
|
clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (texture),
|
|
|
|
gdk_pixbuf_get_pixels (pixbuf),
|
|
|
|
gdk_pixbuf_get_has_alpha (pixbuf),
|
|
|
|
gdk_pixbuf_get_width (pixbuf),
|
|
|
|
gdk_pixbuf_get_height (pixbuf),
|
|
|
|
gdk_pixbuf_get_rowstride (pixbuf),
|
|
|
|
gdk_pixbuf_get_has_alpha (pixbuf)
|
|
|
|
? 4 : 3,
|
|
|
|
0, NULL);
|
2007-05-09 23:31:08 +00:00
|
|
|
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
|
|
|
if (!texture)
|
|
|
|
g_error("Pixbuf creation failed");
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
printf("uploaded to texture...\n");
|
2007-05-09 23:31:08 +00:00
|
|
|
|
2007-06-07 14:41:35 +00:00
|
|
|
clutter_container_add (CLUTTER_CONTAINER (stage), texture, NULL);
|
2007-05-09 23:31:08 +00:00
|
|
|
clutter_actor_set_size (texture, 400, 400);
|
|
|
|
clutter_actor_show (texture);
|
2007-07-29 22:55:04 +00:00
|
|
|
|
|
|
|
/* Hide & show to unreaise then realise the texture */
|
|
|
|
clutter_actor_hide (texture);
|
|
|
|
clutter_actor_show (texture);
|
|
|
|
|
2007-05-09 23:31:08 +00:00
|
|
|
SPIN();
|
2007-05-04 23:53:49 +00:00
|
|
|
|
2007-06-07 14:41:35 +00:00
|
|
|
clutter_container_remove (CLUTTER_CONTAINER (stage), texture, NULL);
|
2007-05-04 23:53:49 +00:00
|
|
|
}
|
2008-04-25 13:37:36 +00:00
|
|
|
#endif
|
2007-05-04 23:53:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|