[test-cogl-tex-tile] Fix breakages from ClutterFixed removal and timelines
The test has been broken since the change to use floats instead of fixed point because it was passing degrees to sin and cos but they expect radians. It was further broken since the timeline changes because it was directly using the parameter of the new-frame signal as a frame number but it now represents the elapsed time.
This commit is contained in:
parent
9d82995773
commit
0dfc1dd284
@ -71,7 +71,7 @@ G_DEFINE_TYPE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR);
|
|||||||
struct _TestCoglboxPrivate
|
struct _TestCoglboxPrivate
|
||||||
{
|
{
|
||||||
CoglHandle cogl_tex_id;
|
CoglHandle cogl_tex_id;
|
||||||
gint frame;
|
gdouble animation_progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Coglbox implementation
|
/* Coglbox implementation
|
||||||
@ -82,26 +82,23 @@ test_coglbox_paint (ClutterActor *self)
|
|||||||
{
|
{
|
||||||
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self);
|
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self);
|
||||||
gfloat texcoords[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
gfloat texcoords[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
gfloat sin_frame, cos_frame;
|
gfloat angle;
|
||||||
gfloat frac_frame;
|
gfloat frac;
|
||||||
gint pingpong_frame;
|
|
||||||
gint t;
|
gint t;
|
||||||
|
|
||||||
sin_frame = sinf ((float) priv->frame);
|
angle = priv->animation_progress * 2 * G_PI;
|
||||||
cos_frame = cosf ((float) priv->frame);
|
|
||||||
|
|
||||||
pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame);
|
frac = ((priv->animation_progress <= 0.5f
|
||||||
frac_frame = (float) pingpong_frame / 180.0;
|
? priv->animation_progress
|
||||||
frac_frame += 0.5;
|
: 1.0f - priv->animation_progress) + 0.5f) * 2.0f;
|
||||||
frac_frame *= 2;
|
|
||||||
|
|
||||||
for (t=0; t<4; t+=2)
|
for (t=0; t<4; t+=2)
|
||||||
{
|
{
|
||||||
texcoords[t] += cos_frame;
|
texcoords[t] += cos (angle);
|
||||||
texcoords[t+1] += sin_frame;
|
texcoords[t+1] += sin (angle);
|
||||||
|
|
||||||
texcoords[t] = (texcoords[t] * frac_frame);
|
texcoords[t] *= frac;
|
||||||
texcoords[t+1] = (texcoords[t+1] * frac_frame);
|
texcoords[t+1] *= frac;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv = TEST_COGLBOX_GET_PRIVATE (self);
|
priv = TEST_COGLBOX_GET_PRIVATE (self);
|
||||||
@ -170,12 +167,12 @@ test_coglbox_new (void)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
frame_cb (ClutterTimeline *timeline,
|
frame_cb (ClutterTimeline *timeline,
|
||||||
gint frame_num,
|
gint msecs,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data);
|
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data);
|
||||||
|
|
||||||
priv->frame = frame_num;
|
priv->animation_progress = clutter_timeline_get_progress (timeline);
|
||||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (data));
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +195,7 @@ test_cogl_tex_tile_main (int argc, char *argv[])
|
|||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);
|
||||||
|
|
||||||
/* Timeline for animation */
|
/* Timeline for animation */
|
||||||
timeline = clutter_timeline_new (6000); /* num frames, fps */
|
timeline = clutter_timeline_new (6000); /* 6 second duration */
|
||||||
clutter_timeline_set_loop (timeline, TRUE);
|
clutter_timeline_set_loop (timeline, TRUE);
|
||||||
g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox);
|
g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox);
|
||||||
clutter_timeline_start (timeline);
|
clutter_timeline_start (timeline);
|
||||||
|
Loading…
Reference in New Issue
Block a user