static void on_paint (ClutterActor *actor, TestState *state) { CoglHandle tex0, tex1; CoglHandle material; gboolean status; GError *error = NULL; float tex_coords[] = { 0, 0, 0.5, 0.5, /* tex0 */ 0.5, 0.5, 1, 1 /* tex1 */ }; /* XXX: * We haven't always had good luck with GL drivers implementing glReadPixels * reliably and skipping the first two frames improves our chances... */ if (state->frame++ <= 2) { g_usleep (G_USEC_PER_SEC); return; } tex0 = make_texture (0x00); tex1 = make_texture (0x11); material = cogl_material_new (); /* An arbitrary color which should be replaced by the first texture layer */ cogl_material_set_color4ub (material, 0x80, 0x80, 0x80, 0x80); cogl_material_set_blend (material, "RGBA = ADD (SRC_COLOR, 0)", NULL); cogl_material_set_layer (material, 0, tex0); cogl_material_set_layer_combine (material, 0, "RGBA = REPLACE (TEXTURE)", NULL); cogl_material_set_layer (material, 1, tex1); status = cogl_material_set_layer_combine (material, 1, "RGBA = ADD (PREVIOUS, TEXTURE)", &error); if (!status) { /* It's not strictly a test failure; you need a more capable GPU or * driver to test this texture combine string. */ g_debug ("Failed to setup texture combine string " "RGBA = ADD (PREVIOUS, TEXTURE): %s", error->message); } cogl_set_source (material); cogl_rectangle_with_multitexture_coords (0, 0, QUAD_WIDTH, QUAD_WIDTH, tex_coords, 8); cogl_handle_unref (material); cogl_handle_unref (tex0); cogl_handle_unref (tex1); /* See what we got... */ assert_region_color (0, 0, QUAD_WIDTH, QUAD_WIDTH, 0x55, 0x55, 0x55, 0x55); /* Comment this out if you want visual feedback for what this test paints */ #if 1 clutter_main_quit (); #endif }
static void on_paint (ClutterActor *actor, TestState *state) { CoglHandle tex0, tex1; CoglHandle material; gboolean status; GError *error = NULL; float tex_coords[] = { 0, 0, 0.5, 0.5, /* tex0 */ 0.5, 0.5, 1, 1 /* tex1 */ }; tex0 = make_texture (0x00); tex1 = make_texture (0x11); material = cogl_material_new (); /* An arbitrary color which should be replaced by the first texture layer */ cogl_material_set_color4ub (material, 0x80, 0x80, 0x80, 0x80); cogl_material_set_blend (material, "RGBA = ADD (SRC_COLOR, 0)", NULL); cogl_material_set_layer (material, 0, tex0); cogl_material_set_layer_combine (material, 0, "RGBA = REPLACE (TEXTURE)", NULL); /* We'll use nearest filtering mode on the textures, otherwise the edge of the quad can pull in texels from the neighbouring quarters of the texture due to imprecision */ cogl_material_set_layer_filters (material, 0, COGL_MATERIAL_FILTER_NEAREST, COGL_MATERIAL_FILTER_NEAREST); cogl_material_set_layer (material, 1, tex1); cogl_material_set_layer_filters (material, 1, COGL_MATERIAL_FILTER_NEAREST, COGL_MATERIAL_FILTER_NEAREST); status = cogl_material_set_layer_combine (material, 1, "RGBA = ADD (PREVIOUS, TEXTURE)", &error); if (!status) { /* It's not strictly a test failure; you need a more capable GPU or * driver to test this texture combine string. */ g_debug ("Failed to setup texture combine string " "RGBA = ADD (PREVIOUS, TEXTURE): %s", error->message); } cogl_set_source (material); cogl_rectangle_with_multitexture_coords (0, 0, QUAD_WIDTH, QUAD_WIDTH, tex_coords, 8); cogl_handle_unref (material); cogl_handle_unref (tex0); cogl_handle_unref (tex1); /* See what we got... */ assert_region_color (0, 0, QUAD_WIDTH, QUAD_WIDTH, 0x55, 0x55, 0x55, 0x55); /* Comment this out if you want visual feedback for what this test paints */ #if 1 clutter_main_quit (); #endif }