<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>

#include <clutter/clutter.h>
#include <cogl/cogl.h>

typedef struct _TestMultiLayerMaterialState
{
  ClutterActor	*group;
  CoglHandle	 material;
  CoglHandle	 alpha_tex;
  CoglHandle	 redhand_tex;
  CoglHandle	 light_tex0;
  gfloat        *tex_coords;

  CoglMatrix	 tex_matrix;
  CoglMatrix	 rot_matrix;

} TestMultiLayerMaterialState;


static void
frame_cb (ClutterTimeline  *timeline,
	  gint		   frame_no,
	  gpointer	   data)
{
  TestMultiLayerMaterialState *state = data;

  cogl_matrix_multiply (&state->tex_matrix,
			&state->tex_matrix,
			&state->rot_matrix);
  cogl_material_set_layer_matrix (state->material, 2, &state->tex_matrix);
}

static void
material_rectangle_paint (ClutterActor *actor, gpointer data)
{
  TestMultiLayerMaterialState *state = data;

  cogl_set_source (state->material);
  cogl_rectangle_with_multitexture_coords (0, 0, 200, 200,
                                           state->tex_coords,
                                           12);
}

G_MODULE_EXPORT int
test_cogl_multitexture_main (int argc, char *argv[])
{
  ClutterTimeline   *timeline;
  ClutterBehaviour  *r_behave;
  ClutterActor	    *stage;
  ClutterColor       stage_color = { 0x61, 0x56, 0x56, 0xff };
  TestMultiLayerMaterialState *state = g_new0 (TestMultiLayerMaterialState, 1);
  ClutterGeometry    geom;
  gfloat             tex_coords[] =
    {
    /* tx1  ty1  tx2  ty2 */
         0,   0,   1,   1,
         0,   0,   1,   1,
         0,   0,   1,   1
    };

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_actor_get_geometry (stage, &geom);

  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  /* We create a non-descript actor that we know doesn't have a
   * default paint handler, so that we can easily control
   * painting in a paint signal handler, without having to
   * sub-class anything etc. */
  state->group = clutter_group_new ();
  clutter_actor_set_position (state->group, geom.width/2, geom.height/2);
  g_signal_connect (state->group, "paint",
		    G_CALLBACK(material_rectangle_paint), state);

  state->alpha_tex =
    cogl_texture_new_from_file ("redhand_alpha.png",
                                COGL_TEXTURE_NO_SLICING,
				COGL_PIXEL_FORMAT_ANY,
				NULL);
  state->redhand_tex =
    cogl_texture_new_from_file ("redhand.png",
                                COGL_TEXTURE_NO_SLICING,
				COGL_PIXEL_FORMAT_ANY,
				NULL);
  state->light_tex0 =
    cogl_texture_new_from_file ("light0.png",
                                COGL_TEXTURE_NO_SLICING,
				COGL_PIXEL_FORMAT_ANY,
				NULL);

  state->material = cogl_material_new ();
  cogl_material_set_layer (state->material, 0, state->alpha_tex);
  cogl_material_set_layer (state->material, 1, state->redhand_tex);
  cogl_material_set_layer (state->material, 2, state->light_tex0);

  state->tex_coords = tex_coords;

  cogl_matrix_init_identity (&state->tex_matrix);
  cogl_matrix_init_identity (&state->rot_matrix);<commit_msg>[test-cogl-multitexture] Print an error if textures can't be loaded<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>

#include <clutter/clutter.h>
#include <cogl/cogl.h>

typedef struct _TestMultiLayerMaterialState
{
  ClutterActor	*group;
  CoglHandle	 material;
  CoglHandle	 alpha_tex;
  CoglHandle	 redhand_tex;
  CoglHandle	 light_tex0;
  gfloat        *tex_coords;

  CoglMatrix	 tex_matrix;
  CoglMatrix	 rot_matrix;

} TestMultiLayerMaterialState;


static void
frame_cb (ClutterTimeline  *timeline,
	  gint		   frame_no,
	  gpointer	   data)
{
  TestMultiLayerMaterialState *state = data;

  cogl_matrix_multiply (&state->tex_matrix,
			&state->tex_matrix,
			&state->rot_matrix);
  cogl_material_set_layer_matrix (state->material, 2, &state->tex_matrix);
}

static void
material_rectangle_paint (ClutterActor *actor, gpointer data)
{
  TestMultiLayerMaterialState *state = data;

  cogl_set_source (state->material);
  cogl_rectangle_with_multitexture_coords (0, 0, 200, 200,
                                           state->tex_coords,
                                           12);
}

G_MODULE_EXPORT int
test_cogl_multitexture_main (int argc, char *argv[])
{
  GError            *error = NULL;
  ClutterTimeline   *timeline;
  ClutterBehaviour  *r_behave;
  ClutterActor	    *stage;
  ClutterColor       stage_color = { 0x61, 0x56, 0x56, 0xff };
  TestMultiLayerMaterialState *state = g_new0 (TestMultiLayerMaterialState, 1);
  ClutterGeometry    geom;
  gfloat             tex_coords[] =
    {
    /* tx1  ty1  tx2  ty2 */
         0,   0,   1,   1,
         0,   0,   1,   1,
         0,   0,   1,   1
    };

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_actor_get_geometry (stage, &geom);

  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  /* We create a non-descript actor that we know doesn't have a
   * default paint handler, so that we can easily control
   * painting in a paint signal handler, without having to
   * sub-class anything etc. */
  state->group = clutter_group_new ();
  clutter_actor_set_position (state->group, geom.width/2, geom.height/2);
  g_signal_connect (state->group, "paint",
		    G_CALLBACK(material_rectangle_paint), state);

  state->alpha_tex =
    cogl_texture_new_from_file ("redhand_alpha.png",
                                COGL_TEXTURE_NO_SLICING,
				COGL_PIXEL_FORMAT_ANY,
				&error);
  if (!state->alpha_tex)
    g_critical ("Failed to load redhand_alpha.png: %s", error->message);

  state->redhand_tex =
    cogl_texture_new_from_file ("redhand.png",
                                COGL_TEXTURE_NO_SLICING,
				COGL_PIXEL_FORMAT_ANY,
				&error);
  if (!state->redhand_tex)
    g_critical ("Failed to load redhand.png: %s", error->message);

  state->light_tex0 =
    cogl_texture_new_from_file ("light0.png",
                                COGL_TEXTURE_NO_SLICING,
				COGL_PIXEL_FORMAT_ANY,
				&error);
  if (!state->light_tex0)
    g_critical ("Failed to load light0.png: %s", error->message);

  state->material = cogl_material_new ();
  cogl_material_set_layer (state->material, 0, state->alpha_tex);
  cogl_material_set_layer (state->material, 1, state->redhand_tex);
  cogl_material_set_layer (state->material, 2, state->light_tex0);

  state->tex_coords = tex_coords;

  cogl_matrix_init_identity (&state->tex_matrix);
  cogl_matrix_init_identity (&state->rot_matrix);
{'fraction_non_alphanumeric': 0.10171289980294074, 'fraction_numerical': 0.014855237229043505, 'mean_word_length': 3.202547770700637, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7547093', 'n_tokens_mistral': 2489, 'n_tokens_neox': 2287, 'n_words': 461}