ClutterBehaviourEllipse api changes; z_camera calculation
This commit is contained in:
parent
d2efd34eb5
commit
bf8996215e
32
ChangeLog
32
ChangeLog
@ -1,3 +1,35 @@
|
||||
2007-05-25 Tomas Frydrych <tf@openedhand.com>
|
||||
|
||||
* clutter/clutter-actor.c:
|
||||
* clutter/clutter-actor.h:
|
||||
Renamed clutter_actor_scalex() to clutter_actor_set_scale_with_gravityx
|
||||
Added floating point version clutter_actor_set_scale_with_gravity.
|
||||
|
||||
* clutter/clutter-units.h:
|
||||
* clutter/clutter-actor.h:
|
||||
typedef ClutterUnit
|
||||
|
||||
* clutter/clutter-fixed.h:
|
||||
* clutter/clutter-stage.c:
|
||||
CLUTTER_ANGLE_FROM_DEG(), CLUTTER_ANGLE_FROM_DEGX()
|
||||
renamed CLUTTER_DEGF_TO_CLUTTER_ANGLE to CLUTTER_ANGLE_FROM_DEGF
|
||||
|
||||
* clutter/clutter-behaviour-ellipse.h:
|
||||
* clutter/clutter-behaviour-ellipse.c:
|
||||
* examples/behave.c:
|
||||
(clutter_behaviour_ellipse_new):
|
||||
Changed signature to take angles in degrees, and x,y offsets.
|
||||
(clutter_behaviour_ellipse_newx):
|
||||
Fixed version clutter_behaviour_ellipse_new.
|
||||
(clutter_behaviour_ellipse_set_center):
|
||||
(clutter_behaviour_ellipse_get_center):
|
||||
Changed signature to take x,y coords instead of ClutterKnot.
|
||||
|
||||
clutter/cogl/gl/cogl.c:
|
||||
clutter/cogl/gles/cogl.c:
|
||||
(cogl_setup_viewport):
|
||||
Added z_camera calculation.
|
||||
|
||||
2007-05-25 Matthew Allum <mallum@openedhand.com>
|
||||
|
||||
* Makefile.am:
|
||||
|
@ -1428,7 +1428,31 @@ clutter_actor_get_scale (ClutterActor *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_scalex:
|
||||
* clutter_actor_set_scale_with_gravity:
|
||||
* @self: A #ClutterActor
|
||||
* @scale_x: scaling factor for x axis
|
||||
* @scale_y: scaling factor for y axis
|
||||
* @gravity: #ClutterGravity to apply to scaling.
|
||||
*
|
||||
* Scales the actor by scale_x, scale_y taking into consideration the
|
||||
* required gravity.
|
||||
*
|
||||
* Since: 0.4
|
||||
*/
|
||||
void
|
||||
clutter_actor_set_scale_with_gravity (ClutterActor *self,
|
||||
gfloat scale_x,
|
||||
gfloat scale_y,
|
||||
ClutterGravity gravity)
|
||||
{
|
||||
clutter_actor_set_scale_with_gravityx (self,
|
||||
CLUTTER_FLOAT_TO_FIXED (scale_x),
|
||||
CLUTTER_FLOAT_TO_FIXED (scale_y),
|
||||
gravity);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_set_scale_with_gravityx:
|
||||
* @self: A #ClutterActor
|
||||
* @scale_x: #ClutterFixed scaling factor for x axis
|
||||
* @scale_y: #ClutterFixed scaling factor for y axis
|
||||
@ -1440,7 +1464,7 @@ clutter_actor_get_scale (ClutterActor *self,
|
||||
* Since: 0.4
|
||||
*/
|
||||
void
|
||||
clutter_actor_scalex (ClutterActor *self,
|
||||
clutter_actor_set_scale_with_gravityx (ClutterActor *self,
|
||||
ClutterFixed scale_x,
|
||||
ClutterFixed scale_y,
|
||||
ClutterGravity gravity)
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter-fixed.h>
|
||||
#include <clutter/clutter-units.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -101,7 +102,7 @@ typedef enum
|
||||
CLUTTER_ACTOR_REALIZED = 1 << 2
|
||||
} ClutterActorFlags;
|
||||
|
||||
struct _ClutterActorBox { gint32 x1, y1, x2, y2; };
|
||||
struct _ClutterActorBox { ClutterUnit x1, y1, x2, y2; };
|
||||
|
||||
GType clutter_actor_box_get_type (void) G_GNUC_CONST;
|
||||
|
||||
@ -250,11 +251,16 @@ void clutter_actor_get_scale (ClutterActor *sel
|
||||
gdouble *scale_x,
|
||||
gdouble *scale_y);
|
||||
|
||||
void clutter_actor_scalex (ClutterActor *self,
|
||||
void clutter_actor_set_scale_with_gravityx (ClutterActor *self,
|
||||
ClutterFixed scale_x,
|
||||
ClutterFixed scale_y,
|
||||
ClutterGravity gravity);
|
||||
|
||||
void clutter_actor_set_scale_with_gravity (ClutterActor *self,
|
||||
gfloat scale_x,
|
||||
gfloat scale_y,
|
||||
ClutterGravity gravity);
|
||||
|
||||
void clutter_actor_get_abs_size (ClutterActor *self,
|
||||
guint *width,
|
||||
guint *height);
|
||||
|
@ -217,7 +217,12 @@ clutter_behaviour_ellipse_set_property (GObject *gobject,
|
||||
priv->b = g_value_get_int (value) >> 1;
|
||||
break;
|
||||
case PROP_CENTER:
|
||||
clutter_behaviour_ellipse_set_center (el, g_value_get_boxed (value));
|
||||
{
|
||||
ClutterKnot * k = g_value_get_boxed (value);
|
||||
if (k)
|
||||
clutter_behaviour_ellipse_set_center (el, k->x, k->y);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
@ -393,12 +398,13 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self)
|
||||
/**
|
||||
* clutter_behaviour_ellipse_new:
|
||||
* @alpha: a #ClutterAlpha, or %NULL
|
||||
* @center: center of the ellipse as #ClutterKnot
|
||||
* @x: x coordinace of the center
|
||||
* @y: y coordiance of the center
|
||||
* @width: width of the ellipse
|
||||
* @height: height of the ellipse
|
||||
* @begin: #ClutterAngle at which movement begins
|
||||
* @end: #ClutterAngle at which movement ends
|
||||
* @tilt: #ClutterAngle with which the ellipse should be tilted around its
|
||||
* @begin: angle in degrees at which movement begins
|
||||
* @end: angle in degrees at which movement ends
|
||||
* @tilt: angle in degrees with which the ellipse should be tilted around its
|
||||
* center
|
||||
*
|
||||
* Creates a behaviour that drives actors along an elliptical path with
|
||||
@ -412,34 +418,93 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self)
|
||||
*/
|
||||
ClutterBehaviour *
|
||||
clutter_behaviour_ellipse_new (ClutterAlpha * alpha,
|
||||
ClutterKnot * center,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
ClutterAngle begin,
|
||||
ClutterAngle end,
|
||||
ClutterAngle tilt)
|
||||
gdouble begin,
|
||||
gdouble end,
|
||||
gdouble tilt)
|
||||
{
|
||||
ClutterBehaviourEllipse *bc;
|
||||
|
||||
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
|
||||
|
||||
ClutterKnot center;
|
||||
center.x = x;
|
||||
center.y = y;
|
||||
|
||||
bc = g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE,
|
||||
"alpha", alpha,
|
||||
"center", center,
|
||||
"center", ¢er,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"angle-begin", begin,
|
||||
"angle-end", end,
|
||||
"angle-tilt", tilt,
|
||||
"angle-begin", CLUTTER_ANGLE_FROM_DEG (begin),
|
||||
"angle-end", CLUTTER_ANGLE_FROM_DEG (end),
|
||||
"angle-tilt", CLUTTER_ANGLE_FROM_DEG (tilt),
|
||||
NULL);
|
||||
|
||||
return CLUTTER_BEHAVIOUR (bc);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_behaviour_ellipse_newx:
|
||||
* @alpha: a #ClutterAlpha, or %NULL
|
||||
* @x: x coordinace of the center
|
||||
* @y: y coordiance of the center
|
||||
* @width: width of the ellipse
|
||||
* @height: height of the ellipse
|
||||
* @begin: #ClutterFixed angle in degrees at which movement begins
|
||||
* @end: #ClutterFixed angle in degrees at which movement ends
|
||||
* @tilt: #ClutterFixed angle in degrees with which the ellipse should be tilted around its
|
||||
* center
|
||||
*
|
||||
* Creates a behaviour that drives actors along an elliptical path with
|
||||
* given center, width and height; the movement begins at angle_begin and
|
||||
* ends at angle_end; if angle_end > angle_begin, the movement is in
|
||||
* counter-clockwise direction, clockwise other wise.
|
||||
*
|
||||
* Return value: a #ClutterBehaviour
|
||||
*
|
||||
* Since: 0.4
|
||||
*/
|
||||
ClutterBehaviour *
|
||||
clutter_behaviour_ellipse_newx (ClutterAlpha * alpha,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
ClutterFixed begin,
|
||||
ClutterFixed end,
|
||||
ClutterFixed tilt)
|
||||
{
|
||||
ClutterBehaviourEllipse *bc;
|
||||
|
||||
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
|
||||
|
||||
ClutterKnot center;
|
||||
center.x = x;
|
||||
center.y = y;
|
||||
|
||||
bc = g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE,
|
||||
"alpha", alpha,
|
||||
"center", ¢er,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"angle-begin", CLUTTER_ANGLE_FROM_DEGX (begin),
|
||||
"angle-end", CLUTTER_ANGLE_FROM_DEGX (end),
|
||||
"angle-tilt", CLUTTER_ANGLE_FROM_DEGX (tilt),
|
||||
NULL);
|
||||
|
||||
return CLUTTER_BEHAVIOUR (bc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* clutter_behaviour_ellipse_set_center
|
||||
* @self: a #ClutterBehaviourEllipse
|
||||
* @knot: a #ClutterKnot center for the ellipse
|
||||
* @x: x coordinace of centre
|
||||
* @y: y coordinace of centre
|
||||
*
|
||||
* Sets the center of the elliptical path to the point represented by knot.
|
||||
*
|
||||
@ -447,12 +512,14 @@ clutter_behaviour_ellipse_new (ClutterAlpha * alpha,
|
||||
*/
|
||||
void
|
||||
clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self,
|
||||
ClutterKnot * knot)
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
if (self->priv->center.x != knot->x || self->priv->center.y != knot->y)
|
||||
if (self->priv->center.x != x || self->priv->center.y != y)
|
||||
{
|
||||
g_object_ref (self);
|
||||
self->priv->center = *knot;
|
||||
self->priv->center.x = x;
|
||||
self->priv->center.y = y;
|
||||
g_object_notify (G_OBJECT (self), "center");
|
||||
g_object_unref (self);
|
||||
}
|
||||
@ -461,7 +528,8 @@ clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self,
|
||||
/**
|
||||
* clutter_behaviour_ellipse_get_center
|
||||
* @self: a #ClutterBehaviourEllipse
|
||||
* @knot: a #ClutterKnot where to store the center of the ellipse
|
||||
* @x: location to store the x coordinace of the center, or NULL
|
||||
* @y: location to store the y coordinace of the center, or NULL
|
||||
*
|
||||
* Gets the center of the elliptical path path.
|
||||
*
|
||||
@ -469,9 +537,14 @@ clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self,
|
||||
*/
|
||||
void
|
||||
clutter_behaviour_ellipse_get_center (ClutterBehaviourEllipse * self,
|
||||
ClutterKnot * knot)
|
||||
gint * x,
|
||||
gint * y)
|
||||
{
|
||||
*knot = self->priv->center;
|
||||
if (x)
|
||||
*x = self->priv->center.x;
|
||||
|
||||
if (y)
|
||||
*y = self->priv->center.y;
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,17 +82,30 @@ struct _ClutterBehaviourEllipseClass
|
||||
GType clutter_behaviour_ellipse_get_type (void) G_GNUC_CONST;
|
||||
|
||||
ClutterBehaviour *clutter_behaviour_ellipse_new (ClutterAlpha * alpha,
|
||||
ClutterKnot * center,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
ClutterAngle start,
|
||||
ClutterAngle end,
|
||||
ClutterAngle tilt);
|
||||
gdouble start,
|
||||
gdouble end,
|
||||
gdouble tilt);
|
||||
|
||||
ClutterBehaviour *clutter_behaviour_ellipse_newx (ClutterAlpha * alpha,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
ClutterFixed start,
|
||||
ClutterFixed end,
|
||||
ClutterFixed tilt);
|
||||
|
||||
void clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self,
|
||||
ClutterKnot * knot);
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void clutter_behaviour_ellipse_get_center (ClutterBehaviourEllipse * bs,
|
||||
ClutterKnot * knot);
|
||||
gint * x,
|
||||
gint * y);
|
||||
|
||||
void clutter_behaviour_ellipse_set_width (ClutterBehaviourEllipse * self,
|
||||
gint width);
|
||||
|
@ -83,7 +83,7 @@ scale_frame_foreach (ClutterBehaviour *behaviour,
|
||||
ClutterFixed scale = GPOINTER_TO_UINT (data);
|
||||
ClutterGravity gravity = priv->gravity;
|
||||
|
||||
clutter_actor_scalex (actor, scale, scale, gravity);
|
||||
clutter_actor_set_scale_with_gravityx (actor, scale, scale, gravity);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -46,6 +46,13 @@ typedef gint32 ClutterFixed;
|
||||
*/
|
||||
typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
|
||||
|
||||
#define CLUTTER_ANGLE_FROM_DEG(x) CLUTTER_FLOAT_TO_INT((x*1024.0)/360.0)
|
||||
|
||||
#define CLUTTER_ANGLE_FROM_DEGF(x) CLUTTER_FLOAT_TO_INT(((float)x*1024.0f)/360.0f)
|
||||
#define CLUTTER_ANGLE_TO_DEGF(x) (((float)x * 360.0)/ 1024.0)
|
||||
|
||||
#define CLUTTER_ANGLE_FROM_DEGX(x) CFX_INT(((x*1024)/360) + CFX_HALF)
|
||||
|
||||
#define CFX_Q 16 /* Decimal part size in bits */
|
||||
#define CFX_ONE (1 << CFX_Q) /* 1 */
|
||||
#define CFX_HALF 32768
|
||||
@ -135,10 +142,6 @@ typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
|
||||
#define CLUTTER_FIXED_MUL(x,y) ((x) >> 8) * ((y) >> 8)
|
||||
#define CLUTTER_FIXED_DIV(x,y) ((((x) << 8)/(y)) << 8)
|
||||
|
||||
#define CLUTTER_DEGF_TO_CLUTTER_ANGLE(x) CLUTTER_FLOAT_TO_INT ((x / 360.0) * 1024)
|
||||
|
||||
#define CLUTTER_ANGLE_TO_DEGF(x) (((float)x * 360.0)/ 1024.0)
|
||||
|
||||
/* some handy short aliases to avoid exessively long lines */
|
||||
|
||||
#define CFX_INT CLUTTER_FIXED_INT
|
||||
|
@ -557,7 +557,7 @@ clutter_stage_set_perspective (ClutterStage *stage,
|
||||
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
||||
|
||||
priv = stage->priv;
|
||||
priv->perspective.fovy = CLUTTER_DEGF_TO_CLUTTER_ANGLE(fovy);
|
||||
priv->perspective.fovy = CLUTTER_ANGLE_FROM_DEGF(fovy);
|
||||
priv->perspective.aspect = CLUTTER_FLOAT_TO_FIXED(aspect);
|
||||
priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED(z_near);
|
||||
priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED(z_far);
|
||||
|
@ -49,6 +49,10 @@
|
||||
|
||||
#include <clutter/clutter-fixed.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef gint32 ClutterUnit;
|
||||
|
||||
/*
|
||||
* Currently CLUTTER_UNIT maps directly onto ClutterFixed. Nevertheless, the
|
||||
* _FROM_FIXED and _TO_FIXED macros should always be used in case that we
|
||||
@ -71,4 +75,6 @@
|
||||
|
||||
#define CLUTTER_UNITS_FROM_PANGO_UNIT(x) (x << 6)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _HAVE_CLUTTER_UNITS_H */
|
||||
|
@ -549,6 +549,8 @@ cogl_setup_viewport (guint width,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
{
|
||||
GLfloat z_camera;
|
||||
|
||||
GE( glViewport (0, 0, width, height) );
|
||||
|
||||
GE( glMatrixMode (GL_PROJECTION) );
|
||||
@ -562,7 +564,9 @@ cogl_setup_viewport (guint width,
|
||||
/* camera distance from screen, 0.5 * tan (FOV) */
|
||||
#define DEFAULT_Z_CAMERA 0.866025404f
|
||||
|
||||
GE( glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA) );
|
||||
z_camera = CLUTTER_FIXED_TO_FLOAT (clutter_tani (fovy) >> 1);
|
||||
|
||||
GE( glTranslatef (-0.5f, -0.5f, -z_camera) );
|
||||
GE( glScalef ( 1.0f / width,
|
||||
-1.0f / height,
|
||||
1.0f / width) );
|
||||
|
@ -489,6 +489,7 @@ cogl_setup_viewport (guint w,
|
||||
{
|
||||
gint width = (gint) w;
|
||||
gint height = (gint) h;
|
||||
ClutterFixed z_camera;
|
||||
|
||||
GE( glViewport (0, 0, width, height) );
|
||||
GE( glMatrixMode (GL_PROJECTION) );
|
||||
@ -505,10 +506,9 @@ cogl_setup_viewport (guint w,
|
||||
|
||||
/* camera distance from screen, 0.5 * tan (FOV) */
|
||||
#define DEFAULT_Z_CAMERA 0.866025404f
|
||||
z_camera = clutter_tani (fovy) << 1;
|
||||
|
||||
GE( glTranslatex (-1 << 15,
|
||||
-1 << 15,
|
||||
-CLUTTER_FLOAT_TO_FIXED(DEFAULT_Z_CAMERA)) );
|
||||
GE( glTranslatex (-1 << 15, -1 << 15, -z_camera );
|
||||
|
||||
GE( glScalex ( CFX_ONE / width,
|
||||
-CFX_ONE / height,
|
||||
|
@ -79,7 +79,8 @@ ClutterBehaviourEllipse
|
||||
</para>
|
||||
|
||||
@alpha:
|
||||
@center:
|
||||
@x:
|
||||
@y:
|
||||
@width:
|
||||
@height:
|
||||
@start:
|
||||
@ -94,7 +95,8 @@ ClutterBehaviourEllipse
|
||||
</para>
|
||||
|
||||
@self:
|
||||
@knot:
|
||||
@x:
|
||||
@y:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION clutter_behaviour_ellipse_get_center ##### -->
|
||||
@ -103,7 +105,8 @@ ClutterBehaviourEllipse
|
||||
</para>
|
||||
|
||||
@bs:
|
||||
@knot:
|
||||
@x:
|
||||
@y:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION clutter_behaviour_ellipse_get_angle_begin ##### -->
|
||||
|
@ -24,6 +24,7 @@ clutter-feature
|
||||
|
||||
@CLUTTER_FEATURE_TEXTURE_RECTANGLE:
|
||||
@CLUTTER_FEATURE_SYNC_TO_VBLANK:
|
||||
@CLUTTER_FEATURE_TEXTURE_YUV:
|
||||
@CLUTTER_FEATURE_TEXTURE_READ_PIXELS:
|
||||
|
||||
<!-- ##### FUNCTION clutter_feature_available ##### -->
|
||||
|
@ -38,8 +38,8 @@ Macro evaluating to the height of the #ClutterStage
|
||||
|
||||
@fovy:
|
||||
@aspect:
|
||||
@zNear:
|
||||
@zFar:
|
||||
@z_near:
|
||||
@z_far:
|
||||
|
||||
<!-- ##### FUNCTION clutter_perspective_copy ##### -->
|
||||
<para>
|
||||
|
@ -116,20 +116,6 @@ ClutterTexture
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION clutter_texture_set_from_data ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@texture:
|
||||
@data:
|
||||
@has_alpha:
|
||||
@width:
|
||||
@height:
|
||||
@rowstride:
|
||||
@bpp:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION clutter_texture_set_pixbuf ##### -->
|
||||
<para>
|
||||
|
||||
@ -137,6 +123,8 @@ ClutterTexture
|
||||
|
||||
@texture:
|
||||
@pixbuf:
|
||||
@error:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION clutter_texture_get_pixbuf ##### -->
|
||||
|
@ -165,8 +165,8 @@ main (int argc, char *argv[])
|
||||
break;
|
||||
case PATH_ELLIPSE:
|
||||
p_behave =
|
||||
clutter_behaviour_ellipse_new (alpha, &origin, 400, 300,
|
||||
0, 1024, 0);
|
||||
clutter_behaviour_ellipse_new (alpha, 200, 200, 400, 300,
|
||||
0.0, 360.0, 0.0);
|
||||
break;
|
||||
|
||||
case PATH_BSPLINE:
|
||||
|
Loading…
Reference in New Issue
Block a user