2007-05-31 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-actor.c: * clutter/clutter-actor.h: Add clutter_actor_get_transformed_point() * clutter/clutter-main.c: Plug in perspective setup to redraw * clutter/clutter-stage.c: * clutter/clutter-stage.h: Remove audience code for now.
This commit is contained in:
parent
4d8bf8f3b8
commit
fb6d22f95d
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
2007-05-31 Matthew Allum <mallum@openedhand.com>
|
||||
|
||||
* clutter/clutter-actor.c:
|
||||
* clutter/clutter-actor.h:
|
||||
Add clutter_actor_get_transformed_point()
|
||||
|
||||
* clutter/clutter-main.c:
|
||||
Plug in perspective setup to redraw
|
||||
|
||||
* clutter/clutter-stage.c:
|
||||
* clutter/clutter-stage.h:
|
||||
Remove audience code for now.
|
||||
|
||||
2007-05-31 Matthew Allum <mallum@openedhand.com>
|
||||
|
||||
* clutter/egl/clutter-backend-egl.c:
|
||||
|
@ -453,25 +453,12 @@ mtx_transform (ClutterFixed *m,
|
||||
CFX_MUL (M (m,2,2), _z) + M (m,2,3);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_get_transformed_vertices:
|
||||
* @self: A #ClutterActor
|
||||
* @verts: Pointer to a location of #ClutterVertices where to store the result.
|
||||
* Calculates the vertices of the translated, rotated and scaled actor in 3D
|
||||
* space.
|
||||
*
|
||||
* Since: 0.4
|
||||
**/
|
||||
void
|
||||
clutter_actor_get_transformed_vertices (ClutterActor * self,
|
||||
ClutterVertices * verts)
|
||||
static void
|
||||
mtx_create (ClutterActor *self, ClutterFixed *mtx)
|
||||
{
|
||||
ClutterActorPrivate * priv;
|
||||
ClutterFixed mtx[16];
|
||||
ClutterFixed x, y, z;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||
priv = self->priv;
|
||||
ClutterActorPrivate *priv = self->priv;
|
||||
|
||||
/* FIXME: need to apply perspective / viewport transforms */
|
||||
|
||||
mtx_identity (&mtx[0]);
|
||||
|
||||
@ -481,9 +468,9 @@ clutter_actor_get_transformed_vertices (ClutterActor * self,
|
||||
* 0,0 to where our actor is.
|
||||
*/
|
||||
mtx_translate (&mtx[0],
|
||||
CLUTTER_UNITS_TO_FIXED (priv->coords.x1),
|
||||
CLUTTER_UNITS_TO_FIXED (priv->coords.y1),
|
||||
CLUTTER_INT_TO_FIXED (priv->z));
|
||||
CLUTTER_UNITS_TO_FIXED (priv->coords.x1),
|
||||
CLUTTER_UNITS_TO_FIXED (priv->coords.y1),
|
||||
CLUTTER_INT_TO_FIXED (priv->z));
|
||||
|
||||
if (self->priv->rzang)
|
||||
{
|
||||
@ -537,6 +524,69 @@ clutter_actor_get_transformed_vertices (ClutterActor * self,
|
||||
{
|
||||
mtx_scale (&mtx[0], priv->scale_x, priv->scale_y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_get_transformed_point:
|
||||
* @self: A #ClutterActor
|
||||
* @x: X screen position in pixels
|
||||
* @y: Y screen position in pixels
|
||||
* @x_return: location to store tranformed X Axis value in #ClutterUnits
|
||||
* @y_return: location to store tranformed Y Axis value in #ClutterUnits
|
||||
* @z_return: location to store tranformed Z Axis value in #ClutterUnits
|
||||
*
|
||||
* Transforms a 2D point (relative to the actor) into 3D space defined by
|
||||
* the actors current tranformation matrix.
|
||||
*
|
||||
* Since: 0.4
|
||||
**/
|
||||
void
|
||||
clutter_actor_get_transformed_point (ClutterActor *actor,
|
||||
gint x,
|
||||
gint y,
|
||||
ClutterUnit *x_return,
|
||||
ClutterUnit *y_return,
|
||||
ClutterUnit *z_return)
|
||||
{
|
||||
ClutterFixed mtx[16];
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
|
||||
|
||||
mtx_create (actor, &mtx[0]);
|
||||
|
||||
*x_return = CLUTTER_UNITS_FROM_INT(x);
|
||||
*y_return = CLUTTER_UNITS_FROM_INT(y);
|
||||
*z_return = 0;
|
||||
|
||||
mtx_transform (&mtx[0], x_return, y_return, z_return);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_actor_get_transformed_vertices:
|
||||
* @self: A #ClutterActor
|
||||
* @verts: Pointer to a location of #ClutterVertices where to store the result.
|
||||
* Calculates the vertices of the translated, rotated and scaled actor in 3D
|
||||
* space.
|
||||
*
|
||||
* Since: 0.4
|
||||
**/
|
||||
void
|
||||
clutter_actor_get_transformed_vertices (ClutterActor * self,
|
||||
ClutterVertices * verts)
|
||||
{
|
||||
ClutterFixed mtx[16];
|
||||
ClutterFixed x, y, z;
|
||||
ClutterActorPrivate *priv;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||
|
||||
/* FIXME: we should probably call allocate_cords on the actor to make
|
||||
* sure untransformed box is up to date.
|
||||
*/
|
||||
|
||||
priv = self->priv;
|
||||
|
||||
mtx_create (self, &mtx[0]);
|
||||
|
||||
#if 0
|
||||
g_debug ("Matrix\n"
|
||||
|
@ -309,6 +309,13 @@ void clutter_actor_move_by (ClutterActor *sel
|
||||
void clutter_actor_get_transformed_vertices (ClutterActor *self,
|
||||
ClutterVertices * verts);
|
||||
|
||||
void clutter_actor_get_transformed_point (ClutterActor *actor,
|
||||
gint x,
|
||||
gint y,
|
||||
ClutterUnit *x_return,
|
||||
ClutterUnit *y_return,
|
||||
ClutterUnit *z_return);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _HAVE_CLUTTER_ACTOR_H */
|
||||
|
@ -119,12 +119,16 @@ clutter_redraw (void)
|
||||
*/
|
||||
if (CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_SYNC_MATRICES)
|
||||
{
|
||||
ClutterPerspective perspective;
|
||||
|
||||
clutter_stage_get_perspectivex (stage, &perspective);
|
||||
|
||||
cogl_setup_viewport (clutter_actor_get_width (stage),
|
||||
clutter_actor_get_height (stage),
|
||||
171, /* 60 degrees */
|
||||
CFX_ONE,
|
||||
CLUTTER_FLOAT_TO_FIXED (0.1),
|
||||
CLUTTER_FLOAT_TO_FIXED (100.0));
|
||||
perspective.fovy,
|
||||
perspective.aspect,
|
||||
perspective.z_near,
|
||||
perspective.z_far);
|
||||
}
|
||||
|
||||
/* Setup the initial paint */
|
||||
|
@ -57,7 +57,6 @@ struct _ClutterStagePrivate
|
||||
{
|
||||
ClutterColor color;
|
||||
ClutterPerspective perspective;
|
||||
ClutterAudience audience;
|
||||
|
||||
guint is_fullscreen : 1;
|
||||
guint is_offscreen : 1;
|
||||
@ -73,7 +72,6 @@ enum
|
||||
PROP_OFFSCREEN,
|
||||
PROP_CURSOR_VISIBLE,
|
||||
PROP_PERSPECTIVE,
|
||||
PROP_AUDIENCE
|
||||
};
|
||||
|
||||
enum
|
||||
@ -149,9 +147,6 @@ clutter_stage_set_property (GObject *object,
|
||||
case PROP_PERSPECTIVE:
|
||||
clutter_stage_set_perspectivex (stage, g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_AUDIENCE:
|
||||
clutter_stage_set_audience (stage, g_value_get_boxed (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -167,7 +162,6 @@ clutter_stage_get_property (GObject *object,
|
||||
ClutterStage *stage;
|
||||
ClutterStagePrivate *priv;
|
||||
ClutterColor color;
|
||||
ClutterAudience audience;
|
||||
ClutterPerspective perspective;
|
||||
|
||||
stage = CLUTTER_STAGE(object);
|
||||
@ -192,10 +186,6 @@ clutter_stage_get_property (GObject *object,
|
||||
clutter_stage_get_perspectivex (stage, &perspective);
|
||||
g_value_set_boxed (value, &perspective);
|
||||
break;
|
||||
case PROP_AUDIENCE:
|
||||
clutter_stage_get_audience (stage, &audience);
|
||||
g_value_set_boxed (value, &audience);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -410,6 +400,11 @@ clutter_stage_init (ClutterStage *self)
|
||||
priv->color.green = 0xff;
|
||||
priv->color.blue = 0xff;
|
||||
priv->color.alpha = 0xff;
|
||||
|
||||
priv->perspective.fovy = 171; /* 60 Degrees */
|
||||
priv->perspective.aspect = CFX_ONE;
|
||||
priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED (0.1);
|
||||
priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED (100.0);
|
||||
|
||||
clutter_actor_set_size (CLUTTER_ACTOR (self), 640, 480);
|
||||
}
|
||||
@ -587,21 +582,6 @@ clutter_stage_get_perspective (ClutterStage *stage,
|
||||
*z_far = CLUTTER_FIXED_TO_FLOAT(priv->perspective.z_far);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
clutter_stage_set_audience (ClutterStage *stage,
|
||||
ClutterAudience *audience)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
clutter_stage_get_audience (ClutterStage *stage,
|
||||
ClutterAudience *audience)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_stage_fullscreen:
|
||||
* @stage: a #ClutterStage
|
||||
@ -789,8 +769,6 @@ clutter_stage_get_actor_at_pos (ClutterStage *stage,
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
glReadPixels(x, viewport[3] - y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
|
||||
|
||||
/* printf("x: %i , y: %i %x:%x:%x\n", x, y, pixel[0], pixel[1], pixel[2]); */
|
||||
|
||||
if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff)
|
||||
return CLUTTER_ACTOR(stage);
|
||||
|
||||
@ -932,57 +910,3 @@ clutter_perspective_get_type (void)
|
||||
return our_type;
|
||||
}
|
||||
|
||||
/*** Audience boxed type ******/
|
||||
|
||||
/**
|
||||
* clutter_audience_copy:
|
||||
* @audience: a #ClutterAudience
|
||||
*
|
||||
* Makes a copy of the audience structure. The result must be
|
||||
* freed using clutter_audience_free().
|
||||
*
|
||||
* Return value: an allocated copy of @audience.
|
||||
*
|
||||
* Since: 0.4
|
||||
*/
|
||||
ClutterAudience *
|
||||
clutter_audience_copy (const ClutterAudience *audience)
|
||||
{
|
||||
ClutterAudience *result;
|
||||
|
||||
g_return_val_if_fail (audience != NULL, NULL);
|
||||
|
||||
result = g_slice_new (ClutterAudience);
|
||||
*result = *audience;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_audience_free:
|
||||
* @audience: a #ClutterAudience
|
||||
*
|
||||
* Frees a audience structure created with clutter_audience_copy().
|
||||
*
|
||||
* Since: 0.4
|
||||
*/
|
||||
void
|
||||
clutter_audience_free (ClutterAudience *audience)
|
||||
{
|
||||
g_return_if_fail (audience != NULL);
|
||||
|
||||
g_slice_free (ClutterAudience, audience);
|
||||
}
|
||||
|
||||
GType
|
||||
clutter_audience_get_type (void)
|
||||
{
|
||||
static GType our_type = 0;
|
||||
|
||||
if (!our_type)
|
||||
our_type = g_boxed_type_register_static
|
||||
("ClutterAudience",
|
||||
(GBoxedCopyFunc) clutter_audience_copy,
|
||||
(GBoxedFreeFunc) clutter_audience_free);
|
||||
return our_type;
|
||||
}
|
||||
|
@ -132,21 +132,9 @@ struct _ClutterPerspective
|
||||
ClutterFixed z_far;
|
||||
};
|
||||
|
||||
#define CLUTTER_TYPE_AUDIENCE (clutter_audience_get_type ())
|
||||
|
||||
typedef struct _ClutterAudience ClutterAudience;
|
||||
|
||||
struct _ClutterAudience
|
||||
{
|
||||
};
|
||||
|
||||
GType clutter_perspective_get_type (void) G_GNUC_CONST;
|
||||
ClutterPerspective *clutter_perspective_copy (const ClutterPerspective *perspective);
|
||||
void clutter_perspective_free (ClutterPerspective *perspective);
|
||||
GType clutter_audience_get_type (void) G_GNUC_CONST;
|
||||
ClutterAudience *clutter_audience_copy (const ClutterAudience *audience);
|
||||
void clutter_audience_free (ClutterAudience *audience);
|
||||
|
||||
GType clutter_stage_get_type (void) G_GNUC_CONST;
|
||||
|
||||
ClutterActor *clutter_stage_get_default (void);
|
||||
@ -169,10 +157,6 @@ void clutter_stage_get_perspective (ClutterStage *stage,
|
||||
gfloat *aspect,
|
||||
gfloat *z_near,
|
||||
gfloat *z_far);
|
||||
void clutter_stage_set_audience (ClutterStage *stage,
|
||||
ClutterAudience *audience);
|
||||
void clutter_stage_get_audience (ClutterStage *stage,
|
||||
ClutterAudience *audience);
|
||||
void clutter_stage_fullscreen (ClutterStage *stage);
|
||||
void clutter_stage_unfullscreen (ClutterStage *stage);
|
||||
void clutter_stage_show_cursor (ClutterStage *stage);
|
||||
|
Loading…
Reference in New Issue
Block a user