mtx_transform (const ClutterFixed m[],
fixed_vertex_t *vertex)
{
- ClutterFixed _x, _y, _z, _w;
+ float _x, _y, _z, _w;
_x = vertex->x;
_y = vertex->y;
/* Help macros to scale from OpenGL <-1,1> coordinates system to our
* X-window based <0,window-size> coordinates
*/
-#define MTX_GL_SCALE_X(x,w,v1,v2) (CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((x), (w)) + 1.0) >> 1), (v1)) + (v2))
-#define MTX_GL_SCALE_Y(y,w,v1,v2) ((v1) - CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((y), (w)) + 1.0) >> 1), (v1)) + (v2))
+#define MTX_GL_SCALE_X(x,w,v1,v2) \
+ (CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((x), (w)) + 1.0) / 2), (v1)) + (v2))
+#define MTX_GL_SCALE_Y(y,w,v1,v2) \
+ ((v1) - CLUTTER_FIXED_MUL (((CLUTTER_FIXED_DIV ((y), (w)) + 1.0) / 2), \
+ (v1)) + (v2))
#define MTX_GL_SCALE_Z(z,w,v1,v2) (MTX_GL_SCALE_X ((z), (w), (v1), (v2)))
/* transforms a 4-tuple of coordinates using @matrix and
gboolean is_stage = CLUTTER_IS_STAGE (self);
if (!is_stage)
- cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->allocation.x1),
- CLUTTER_UNITS_TO_FIXED (priv->allocation.y1),
+ cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->allocation.x1),
+ CLUTTER_UNITS_TO_FLOAT (priv->allocation.y1),
0);
/*
if (priv->rzang)
{
- cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->rzx),
- CLUTTER_UNITS_TO_FIXED (priv->rzy),
+ cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->rzx),
+ CLUTTER_UNITS_TO_FLOAT (priv->rzy),
0);
- cogl_rotatex (priv->rzang, 0, 0, 1.0);
+ cogl_rotate (priv->rzang, 0, 0, 1.0);
- cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->rzx),
- CLUTTER_UNITS_TO_FIXED (-priv->rzy),
+ cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->rzx),
+ CLUTTER_UNITS_TO_FLOAT (-priv->rzy),
0);
}
if (priv->ryang)
{
- cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->ryx),
+ cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->ryx),
0,
- CLUTTER_UNITS_TO_FIXED (priv->z + priv->ryz));
+ CLUTTER_UNITS_TO_FLOAT (priv->z + priv->ryz));
- cogl_rotatex (priv->ryang, 0, 1.0, 0);
+ cogl_rotate (priv->ryang, 0, 1.0, 0);
- cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->ryx),
+ cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->ryx),
0,
- CLUTTER_UNITS_TO_FIXED (-(priv->z + priv->ryz)));
+ CLUTTER_UNITS_TO_FLOAT (-(priv->z + priv->ryz)));
}
if (priv->rxang)
{
- cogl_translatex (0,
- CLUTTER_UNITS_TO_FIXED (priv->rxy),
- CLUTTER_UNITS_TO_FIXED (priv->z + priv->rxz));
+ cogl_translate (0,
+ CLUTTER_UNITS_TO_FLOAT (priv->rxy),
+ CLUTTER_UNITS_TO_FLOAT (priv->z + priv->rxz));
- cogl_rotatex (priv->rxang, 1.0, 0, 0);
+ cogl_rotate (priv->rxang, 1.0, 0, 0);
- cogl_translatex (0,
- CLUTTER_UNITS_TO_FIXED (-priv->rxy),
- CLUTTER_UNITS_TO_FIXED (-(priv->z + priv->rxz)));
+ cogl_translate (0,
+ CLUTTER_UNITS_TO_FLOAT (-priv->rxy),
+ CLUTTER_UNITS_TO_FLOAT (-(priv->z + priv->rxz)));
}
if (!is_stage && (priv->anchor_x || priv->anchor_y))
- cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->anchor_x),
- CLUTTER_UNITS_TO_FIXED (-priv->anchor_y),
+ cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->anchor_x),
+ CLUTTER_UNITS_TO_FLOAT (-priv->anchor_y),
0);
if (priv->z)
- cogl_translatex (0, 0, priv->z);
+ cogl_translate (0, 0, priv->z);
}
/* Recursively applies the transforms associated with this actor and
}
}
+#if 0
+/*
+ * The following three functions are left in place for reference
+ * purposes.
+ */
static guint32
sincx1024_func (ClutterAlpha *alpha,
float angle,
x -= (512 * 512 / angle);
- sine = ((sinf (x * (G_PI/180.0)) + offset) / 2)
+ sine = ((cogl_angle_sin (x) + offset) / 2)
* CLUTTER_ALPHA_MAX_ALPHA;
sine = sine >> COGL_FIXED_Q;
return sine;
}
-#if 0
-/*
- * The following two functions are left in place for reference
- * purposes.
- */
static guint32
sincx_func (ClutterAlpha *alpha,
ClutterFixed angle,
x = CLUTTER_FIXED_MUL (x, CFX_PI)
- CLUTTER_FIXED_DIV (CFX_PI, angle);
- sine = (sinf (x) + offset) / 2;
+ sine = (cogl_angle_sin (x) + offset) / 2;
CLUTTER_NOTE (ALPHA, "sine: %2f\n", CLUTTER_FIXED_TO_DOUBLE (sine));
clutter_sine_func (ClutterAlpha *alpha,
gpointer dummy)
{
-#if 0
+#if 1
+ ClutterTimeline *timeline;
+ gint current_frame_num, n_frames;
+ float radians, sine;
+
+ timeline = clutter_alpha_get_timeline (alpha);
+
+ current_frame_num = clutter_timeline_get_current_frame (timeline);
+ n_frames = clutter_timeline_get_n_frames (timeline);
+
+ radians = ((float)current_frame_num / n_frames) * (2.0 * G_PI);
+ sine = sinf (radians);
+
+ /* shift from range [-1, 1] -> [0, 1] */
+ sine = (sine + 1.0) / 2.0;
+
+ CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine);
+
+ return sine * CLUTTER_ALPHA_MAX_ALPHA;
+#elif 0
return sinc_func (alpha, 2.0, 1.0);
-#else
+#elif 0
/* 2.0 above represents full circle */
return sincx1024_func (alpha, 1024, 1.0);
#endif
ClutterTimeline * timeline;
gint frame;
gint n_frames;
- float x;
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = 256 * frame / n_frames;
-
- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
+ radians = ((float)frame / n_frames) * (G_PI / 2);
+ sine = sinf (radians);
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
ClutterTimeline * timeline;
gint frame;
gint n_frames;
- float x;
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = 256 * frame / n_frames + 256;
-
- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
+ radians = ((float)frame / n_frames) * (G_PI / 2);
+ sine = sinf (radians + (G_PI / 2));
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- float x;
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = 512 * frame / n_frames;
+ radians = ((float)frame / n_frames) * G_PI;
+ sine = sinf (radians);
- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
-
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- float x;
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- /* XXX- if we use 768 we overflow */
- x = 256 * frame / n_frames + 767;
+ radians = ((float)frame / n_frames) * (G_PI / 2);
+ sine = sinf (radians - (G_PI / 2));
- sine = (sinf (x * (G_PI/180.0)) + 1) * CLUTTER_ALPHA_MAX_ALPHA;
+ /* shift from range [-1, 0] -> [0, 1] */
+ sine = sine + 1.0;
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- float x;
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = 256 * frame / n_frames;
-
- sine = sinf (x * (G_PI/180.0)) * CLUTTER_ALPHA_MAX_ALPHA;
+ radians = ((float)frame / n_frames) * (G_PI / 2);
+ sine = sinf (radians);
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- float x;
- ClutterFixed sine;
+ float radians;
+ float sine;
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- x = -256 * frame / n_frames + 256;
+ radians = ((float)frame / n_frames) * G_PI;
+ sine = sinf (radians - (G_PI / 2));
- sine = (sinf (x * (G_PI/180.0)) + 1) / 2 * CLUTTER_ALPHA_MAX_ALPHA;
+ /* shift from range [-1, 1] -> [0, 1] */
+ sine = (sine + 1.0) / 2.0;
- return ((guint32) sine) >> COGL_FIXED_Q;
+ return (guint32) (sine * CLUTTER_ALPHA_MAX_ALPHA);
}
/**
ClutterTimeline *timeline;
gint frame;
gint n_frames;
- guint32 r;
- guint32 x;
+ float r;
+ float x;
/*
* The smoothstep function uses f(x) = -2x^3 + 3x^2 where x is from <0,1>,
- * and precission is critical -- we use 8.24 fixed format for this operation.
- * The earlier operations involve division, which we cannot do in 8.24 for
- * numbers in <0,1> we use ClutterFixed.
+ * and precission is critical.
*/
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
- /*
- * Convert x to 8.24 for next step.
- */
- x = CLUTTER_FIXED_DIV (frame, n_frames) << 8;
+ x = (float)frame / n_frames;
/*
* f(x) = -2x^3 + 3x^2
- *
- * Convert result to ClutterFixed to avoid overflow in next step.
*/
- r = ((x >> 12) * (x >> 12) * 3 - (x >> 15) * (x >> 16) * (x >> 16)) >> 8;
+ r = -2 * x * x * x + 3 * x * x;
return (r * CLUTTER_ALPHA_MAX_ALPHA);
}
*
* (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA
*/
-#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff
-#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA
-#endif
+ /* XXX: If this fails:
+ * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */
+ g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0);
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
x = x_alpha_max * frame / n_frames;
- result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
+ result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
return result;
}
*
* (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA
*/
-#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff
-#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA
-#endif
+ /* XXX: If this fails:
+ * Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA */
+ g_assert (CLUTTER_ALPHA_MAX_ALPHA == 65535.0);
timeline = clutter_alpha_get_timeline (alpha);
frame = clutter_timeline_get_current_frame (timeline);
x = (x_alpha_max * (n_frames - frame)) / n_frames;
- result = CLAMP (pow2f (x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
+ result = CLAMP (powf (2, x) - 1, 0, CLUTTER_ALPHA_MAX_ALPHA);
return result;
}
*
* Since: 0.2
*/
-#define CLUTTER_ALPHA_MAX_ALPHA (0xffff)
+#define CLUTTER_ALPHA_MAX_ALPHA (65535.0f)
GType clutter_alpha_get_type (void) G_GNUC_CONST;
static inline float
clamp_angle (float a)
{
- float a1, a2;
gint rounds;
- /* Need to add the 256 offset here, since the user space 0 maps to our
- * -256
- */
- rounds = (a + 256) / 1024;
- a1 = rounds * 1024;
- a2 = a - a1;
+ rounds = a / 360;
+ if (a < 0)
+ rounds--;
- return a2;
+ return a - 360 * rounds;
}
static void
if (priv->direction == CLUTTER_ROTATE_CW && start >= end)
{
- end += 1024;
+ end += 360;
}
else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end)
{
- end -= 1024;
+ end -= 360;
}
angle = (end - start) * alpha / CLUTTER_ALPHA_MAX_ALPHA + start;
switch (prop_id)
{
case PROP_ANGLE_START:
- priv->angle_start =
- COGL_ANGLE_FROM_DEG (g_value_get_double (value)) - 256;
+ priv->angle_start = g_value_get_double (value);
break;
case PROP_ANGLE_END:
- priv->angle_end =
- COGL_ANGLE_FROM_DEG (g_value_get_double (value)) - 256;
+ priv->angle_end = g_value_get_double (value);
break;
case PROP_ANGLE_TILT_X:
- priv->angle_tilt_x =
- COGL_ANGLE_FROM_DEG (g_value_get_double (value));
+ priv->angle_tilt_x = g_value_get_double (value);
break;
case PROP_ANGLE_TILT_Y:
- priv->angle_tilt_y =
- COGL_ANGLE_FROM_DEG (g_value_get_double (value));
+ priv->angle_tilt_y = g_value_get_double (value);
break;
case PROP_ANGLE_TILT_Z:
- priv->angle_tilt_z =
- COGL_ANGLE_FROM_DEG (g_value_get_double (value));
+ priv->angle_tilt_z = g_value_get_double (value);
break;
case PROP_WIDTH:
- priv->a = g_value_get_int (value) >> 1;
+ priv->a = g_value_get_int (value) / 2;
break;
case PROP_HEIGHT:
- priv->b = g_value_get_int (value) >> 1;
+ priv->b = g_value_get_int (value) / 2;
break;
case PROP_CENTER:
{
switch (prop_id)
{
case PROP_ANGLE_START:
- g_value_set_double (value,
- COGL_ANGLE_TO_DEG (priv->angle_start + 256));
+ g_value_set_double (value, priv->angle_start);
break;
case PROP_ANGLE_END:
- g_value_set_double (value,
- COGL_ANGLE_TO_DEG (priv->angle_end + 256));
+ g_value_set_double (value, priv->angle_end);
break;
case PROP_ANGLE_TILT_X:
- g_value_set_double (value,
- COGL_ANGLE_TO_DEG (priv->angle_tilt_x));
+ g_value_set_double (value, priv->angle_tilt_x);
break;
case PROP_ANGLE_TILT_Y:
- g_value_set_double (value,
- COGL_ANGLE_TO_DEG (priv->angle_tilt_y));
+ g_value_set_double (value, priv->angle_tilt_y);
break;
case PROP_ANGLE_TILT_Z:
- g_value_set_double (value,
- COGL_ANGLE_TO_DEG (priv->angle_tilt_z));
+ g_value_set_double (value, priv->angle_tilt_z);
break;
case PROP_WIDTH:
- g_value_set_int (value, (priv->a << 1));
+ g_value_set_int (value, (priv->a * 2));
break;
case PROP_HEIGHT:
- g_value_set_int (value, (priv->b << 1));
+ g_value_set_int (value, (priv->b * 2));
break;
case PROP_CENTER:
g_value_set_boxed (value, &priv->center);
priv->direction = CLUTTER_ROTATE_CW;
- /* The inital values have to reflect the 90 degree offset between the normal
- * mathematical space and the clutter clock-based space; the default end
- * value of 360 is clamped to 0.
- */
- priv->angle_start = -256;
- priv->angle_end = -256;
+ priv->angle_start = 0;
+ priv->angle_end = 0;
}
/**
"width", width,
"height", height,
"direction", direction,
- "angle-start", COGL_ANGLE_FROM_DEGX (start),
- "angle-end", COGL_ANGLE_FROM_DEGX (end),
+ "angle-start", (double)CLUTTER_FIXED_TO_FLOAT (start),
+ "angle-end", (double)CLUTTER_FIXED_TO_FLOAT (end),
NULL);
}
priv = self->priv;
- if (priv->a != width >> 1)
+ if (priv->a != width / 2)
{
- priv->a = width >> 1;
+ priv->a = width / 2;
g_object_notify (G_OBJECT (self), "width");
}
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0);
- return self->priv->a << 1;
+ return self->priv->a * 2;
}
/**
priv = self->priv;
- if (priv->b != height >> 1)
+ if (priv->b != height / 2)
{
- priv->b = height >> 1;
+ priv->b = height / 2;
g_object_notify (G_OBJECT (self), "height");
}
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0);
- return self->priv->b << 1;
+ return self->priv->b * 2;
}
/**
clutter_behaviour_ellipse_set_angle_start (ClutterBehaviourEllipse *self,
gdouble angle_start)
{
+ ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_start);
+
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
- clutter_behaviour_ellipse_set_angle_startx (self,
- CLUTTER_FLOAT_TO_FIXED (angle_start));
+ clutter_behaviour_ellipse_set_angle_startx (self, new_angle);
}
/**
float new_angle;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
- new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_start) - 256);
+ new_angle = clamp_angle (CLUTTER_FIXED_TO_FLOAT (angle_start));
priv = self->priv;
if (priv->angle_start != new_angle)
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0);
- return COGL_ANGLE_TO_DEG (self->priv->angle_start + 256);
+ return (double)self->priv->angle_start;
}
/**
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0);
- return COGL_ANGLE_TO_DEGX (self->priv->angle_start);
+ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_start);
}
/**
clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self,
gdouble angle_end)
{
+ ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_end);
+
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
- clutter_behaviour_ellipse_set_angle_endx (self,
- CLUTTER_FLOAT_TO_FIXED (angle_end));
+ clutter_behaviour_ellipse_set_angle_endx (self, new_angle);
}
/**
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
- new_angle = clamp_angle (COGL_ANGLE_FROM_DEGX (angle_end) - 256);
+ new_angle = clamp_angle (CLUTTER_FIXED_TO_FLOAT (angle_end));
priv = self->priv;
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0);
- return COGL_ANGLE_TO_DEG (self->priv->angle_end + 256);
+ return self->priv->angle_end;
}
/**
{
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0);
- return COGL_ANGLE_TO_DEGX (self->priv->angle_end);
+ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_end);
}
/**
ClutterRotateAxis axis,
gdouble angle_tilt)
{
+ ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_tilt);
+
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
- clutter_behaviour_ellipse_set_angle_tiltx (self,
- axis,
- CLUTTER_FLOAT_TO_FIXED (angle_tilt));
+ clutter_behaviour_ellipse_set_angle_tiltx (self, axis, new_angle);
}
/**
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
- new_angle = COGL_ANGLE_FROM_DEGX (angle_tilt);
+ new_angle = CLUTTER_FIXED_TO_FLOAT (angle_tilt);
priv = self->priv;
switch (axis)
{
case CLUTTER_X_AXIS:
- return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_x);
+ return self->priv->angle_tilt_x;
case CLUTTER_Y_AXIS:
- return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_y);
+ return self->priv->angle_tilt_y;
case CLUTTER_Z_AXIS:
- return COGL_ANGLE_TO_DEG (self->priv->angle_tilt_z);
+ return self->priv->angle_tilt_z;
}
return 0;
switch (axis)
{
case CLUTTER_X_AXIS:
- return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_x);
+ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_x);
case CLUTTER_Y_AXIS:
- return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_y);
+ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_y);
case CLUTTER_Z_AXIS:
- return COGL_ANGLE_TO_DEGX (self->priv->angle_tilt_z);
+ return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_z);
}
return 0;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
- new_angle_x = COGL_ANGLE_FROM_DEG (angle_tilt_x);
- new_angle_y = COGL_ANGLE_FROM_DEG (angle_tilt_y);
- new_angle_z = COGL_ANGLE_FROM_DEG (angle_tilt_z);
+ new_angle_x = (float)angle_tilt_x;
+ new_angle_y = (float)angle_tilt_y;
+ new_angle_z = (float)angle_tilt_z;
priv = self->priv;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
- new_angle_x = COGL_ANGLE_FROM_DEGX (angle_tilt_x);
- new_angle_y = COGL_ANGLE_FROM_DEGX (angle_tilt_y);
- new_angle_z = COGL_ANGLE_FROM_DEGX (angle_tilt_z);
+ new_angle_x = CLUTTER_FIXED_TO_FLOAT (angle_tilt_x);
+ new_angle_y = CLUTTER_FIXED_TO_FLOAT (angle_tilt_y);
+ new_angle_z = CLUTTER_FIXED_TO_FLOAT (angle_tilt_z);
priv = self->priv;
priv = self->priv;
if (angle_tilt_x)
- *angle_tilt_x = COGL_ANGLE_TO_DEG (priv->angle_tilt_x);
+ *angle_tilt_x = priv->angle_tilt_x;
if (angle_tilt_y)
- *angle_tilt_y = COGL_ANGLE_TO_DEG (priv->angle_tilt_y);
+ *angle_tilt_y = priv->angle_tilt_y;
if (angle_tilt_z)
- *angle_tilt_z = COGL_ANGLE_TO_DEG (priv->angle_tilt_z);
+ *angle_tilt_z = priv->angle_tilt_z;
}
/**
priv = self->priv;
if (angle_tilt_x)
- *angle_tilt_x = COGL_ANGLE_TO_DEGX (priv->angle_tilt_x);
+ *angle_tilt_x = priv->angle_tilt_x;
if (angle_tilt_y)
- *angle_tilt_y = COGL_ANGLE_TO_DEGX (priv->angle_tilt_y);
+ *angle_tilt_y = priv->angle_tilt_y;
if (angle_tilt_z)
- *angle_tilt_z = COGL_ANGLE_TO_DEGX (priv->angle_tilt_z);
+ *angle_tilt_z = priv->angle_tilt_z;
}
/**
int x = _clutter_bezier_t2x (b, t);
int y = _clutter_bezier_t2y (b, t);
- guint l = clutter_sqrti ((y - yp)*(y - yp) + (x - xp)*(x - xp));
+ guint l = cogl_sqrti ((y - yp)*(y - yp) + (x - xp)*(x - xp));
l += length[i-1];
{
ClutterParamSpecFixed *fspec = CLUTTER_PARAM_SPEC_FIXED (pspec);
- fspec->minimum = COGL_FIXED_MIN;
- fspec->maximum = COGL_FIXED_MAX;
+ fspec->minimum = CLUTTER_MAXFIXED;
+ fspec->maximum = CLUTTER_MINFIXED;
fspec->default_value = 0;
}
* If we are using limited precision sqrti implementation, fallback on
* clib sqrt if the precission would be less than 10%
*/
-#if INT_MAX > CLUTTER_SQRTI_ARG_10_PERCENT
+#if INT_MAX > COGL_SQRTI_ARG_10_PERCENT
if (t <= COGL_SQRTI_ARG_10_PERCENT)
return cogl_sqrti (t);
else
- return COGL_FLOAT_TO_INT (sqrt(t));
+ return COGL_FLOAT_TO_INT (sqrtf(t));
#else
return cogl_sqrti (t);
#endif
/* Set up a projection matrix so that the actor will be projected as
if it was drawn at its original location */
- tan_angle = tanf (COGL_ANGLE_FROM_DEGX (perspective.fovy / 2 * (G_PI/180.0)));
+ tan_angle = tanf ((perspective.fovy / 2) * (G_PI/180.0));
near_size = CLUTTER_FIXED_MUL (perspective.z_near, tan_angle);
cogl_frustum (CLUTTER_FIXED_MUL (tx_min, near_size),
gdouble alpha);
/**
- * cogl_color_set_from_4x:
+ * cogl_color_set_from_4f:
* @dest: return location for a #CoglColor
* @red: value of the red channel, between 0 and %1.0
* @green: value of the green channel, between 0 and %1.0
*
* Since: 1.0
*/
-void cogl_color_set_from_4x (CoglColor *dest,
+void cogl_color_set_from_4f (CoglColor *dest,
float red,
float green,
float blue,
* Sets the source color using normalized values for each component.
* This color will be used for any subsequent drawing operation.
*
- * See also cogl_set_source_color4ub() and cogl_set_source_color4x()
+ * See also cogl_set_source_color4ub() and cogl_set_source_color4f()
* if you already have the color components.
*
* Since: 1.0
guint8 alpha);
/**
- * cogl_set_source_color4x:
+ * cogl_set_source_color4f:
* @red: value of the red channel, between 0 and %1.0
* @green: value of the green channel, between 0 and %1.0
* @blue: value of the blue channel, between 0 and %1.0
*
* Since: 1.0
*/
-void cogl_set_source_color4x (float red,
+void cogl_set_source_color4f (float red,
float green,
float blue,
float alpha);
CoglFixed cogl_fixed_sin (CoglFixed angle);
/**
+ * cogl_fixed_tan:
+ * @angle: a #CoglFixed number
+ *
+ * Computes the tangent of @angle.
+ *
+ * Return value: the tangent of the passed angle, in fixed point notation
+ *
+ * Since: 1.0
+ */
+CoglFixed cogl_fixed_tan (CoglFixed angle);
+
+/**
* cogl_fixed_cos:
* @angle: a #CoglFixed number
*
* Fills a rectangle at the given coordinates with the current
* drawing color in a highly optimizied fashion.
**/
-void cogl_rectangle (gint x,
- gint y,
- guint width,
- guint height);
-
-/**
- * cogl_rectanglex:
- * @x: X coordinate of the top-left corner
- * @y: Y coordinate of the top-left corner
- * @width: Width of the rectangle
- * @height: Height of the rectangle
- *
- * A fixed-point version of cogl_fast_fill_rectangle.
- **/
-void cogl_rectanglex (float x,
- float y,
- float width,
- float height);
+void cogl_rectangle (float x,
+ float y,
+ float width,
+ float height);
/**
* cogl_path_fill:
float y);
/**
- * cogl_translatex:
+ * cogl_translate:
* @x: Distance to translate along the x-axis
* @y: Distance to translate along the y-axis
* @z: Distance to translate along the z-axis
* Multiplies the current model-view matrix by one that translates the
* model along all three axes according to the given values.
*/
-void cogl_translatex (float x,
- float y,
- float z);
-
-/**
- * cogl_translate:
- * @x: Distance to translate along the x-axis
- * @y: Distance to translate along the y-axis
- * @z: Distance to translate along the z-axis
- *
- * Integer version of cogl_translatex(). Multiplies the current
- * model-view matrix by one that translates the model along all three
- * axes according to the given values.
- */
-void cogl_translate (gint x,
- gint y,
- gint z);
+void cogl_translate (float x,
+ float y,
+ float z);
/**
- * cogl_rotatex:
+ * cogl_rotate:
* @angle: Angle in degrees to rotate.
* @x: X-component of vertex to rotate around.
* @y: Y-component of vertex to rotate around.
* degrees about the vertex (0, 0, 1) causes a small counter-clockwise
* rotation.
*/
-void cogl_rotatex (float angle,
- gint x,
- gint y,
- gint z);
-
-/**
- * cogl_rotate:
- * @angle: Angle in degrees to rotate.
- * @x: X-component of vertex to rotate around.
- * @y: Y-component of vertex to rotate around.
- * @z: Z-component of vertex to rotate around.
- *
- * Integer version of cogl_rotatex(). Multiplies the current
- * model-view matrix by one that rotates the model around the vertex
- * specified by @x, @y and @z.
- */
-void cogl_rotate (gint angle,
- gint x,
- gint y,
- gint z);
+void cogl_rotate (float angle,
+ float x,
+ float y,
+ float z);
/**
* cogl_get_modelview_matrix:
* comparing with the value in @ref. The default function is CGL_ALWAYS the
* initial reference value is 1.0.
*/
-void cogl_alpha_func (COGLenum func,
+void cogl_alpha_func (COGLenum func,
float ref);
/**
}
void
-cogl_color_set_from_4x (CoglColor *dest,
+cogl_color_set_from_4f (CoglColor *dest,
float red,
float green,
float blue,
}
void
-cogl_set_source_color4x (float red,
+cogl_set_source_color4f (float red,
float green,
float blue,
float alpha)
{
CoglColor c = { 0, };
- cogl_color_set_from_4x (&c, red, green, blue, alpha);
+ cogl_color_set_from_4f (&c, red, green, blue, alpha);
cogl_set_source_color (&c);
}
}
CoglFixed
+cogl_fixed_tan (CoglFixed angle)
+{
+ return cogl_angle_tan (COGL_ANGLE_FROM_DEGX (angle));
+}
+
+CoglFixed
cogl_angle_tan (CoglAngle angle)
{
int sign = 1;
#include <string.h>
#include <gmodule.h>
+#include <math.h>
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16
float y);
void _cogl_path_fill_nodes ();
void _cogl_path_stroke_nodes ();
-void _cogl_rectangle (gint x,
- gint y,
- guint width,
- guint height);
-void _cogl_rectanglex (float x,
- float y,
- float width,
- float height);
+void _cogl_rectangle (float x,
+ float y,
+ float width,
+ float height);
void
-cogl_rectangle (gint x,
- gint y,
- guint width,
- guint height)
+cogl_rectangle (float x,
+ float y,
+ float width,
+ float height)
{
cogl_clip_ensure ();
}
void
-cogl_rectanglex (float x,
- float y,
- float width,
- float height)
-{
- cogl_clip_ensure ();
-
- _cogl_rectanglex (x, y, width, height);
-}
-
-
-void
cogl_path_fill (void)
{
cogl_path_fill_preserve ();
#include <string.h>
#include <gmodule.h>
+#include <math.h>
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16
void
-_cogl_rectangle (gint x,
- gint y,
- guint width,
- guint height)
+_cogl_rectangle (float x,
+ float y,
+ float width,
+ float height)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_enable (ctx->color_alpha < 255
? COGL_ENABLE_BLEND : 0);
- GE( glRecti (x, y, x + width, y + height) );
-}
-
-
-void
-_cogl_rectanglex (float x,
- float y,
- float width,
- float height)
-{
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- cogl_enable (ctx->color_alpha < 255
- ? COGL_ENABLE_BLEND : 0);
-
- GE( glRectf ( (x),
- (y),
- (x + width),
- (y + height)) );
+ GE( glRectf (x, y, x + width, y + height) );
}
void
static void
_cogl_path_get_bounds (floatVec2 nodes_min,
floatVec2 nodes_max,
- gint *bounds_x,
- gint *bounds_y,
- guint *bounds_w,
- guint *bounds_h)
+ float *bounds_x,
+ float *bounds_y,
+ float *bounds_w,
+ float *bounds_h)
{
- *bounds_x = floorf (nodes_min.x);
- *bounds_y = floorf (nodes_min.y);
- *bounds_w = ceilf (nodes_max.x
- - (float)(*bounds_x));
- *bounds_h = ceilf (nodes_max.y
- - (float)(*bounds_y));
+ *bounds_x = nodes_min.x;
+ *bounds_y = nodes_min.y;
+ *bounds_w = nodes_max.x - *bounds_x;
+ *bounds_h = nodes_max.y - *bounds_y;
}
void
{
guint path_start = 0;
guint sub_path_num = 0;
- gint bounds_x;
- gint bounds_y;
- guint bounds_w;
- guint bounds_h;
+ float bounds_x;
+ float bounds_y;
+ float bounds_w;
+ float bounds_h;
_cogl_path_get_bounds (nodes_min, nodes_max,
&bounds_x, &bounds_y, &bounds_w, &bounds_h);
void
_cogl_path_fill_nodes ()
{
- gint bounds_x;
- gint bounds_y;
- guint bounds_w;
- guint bounds_h;
+ float bounds_x;
+ float bounds_y;
+ float bounds_w;
+ float bounds_h;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
#include <string.h>
#include <stdlib.h>
+#include <math.h>
/*
#define COGL_DEBUG 1
guint wx, wy;
src = source_bmp->data
- + (src_y + (y_iter.intersect_start)
+ + (src_y + ((int)y_iter.intersect_start)
- dst_y)
* source_bmp->rowstride
+ (src_x + x_span->start + x_span->size - x_span->waste
guint copy_width;
src = source_bmp->data
- + (src_x + (x_iter.intersect_start)
+ + (src_x + ((int)x_iter.intersect_start)
- dst_x)
* bpp
+ (src_y + y_span->start + y_span->size - y_span->waste
void
cogl_scale (float x, float y)
{
- glScaled ((double)(x),
- (double)(y),
+ glScalef ((float)(x),
+ (float)(y),
1.0);
}
void
-cogl_translatex (float x, float y, float z)
+cogl_translate (float x, float y, float z)
{
- glTranslated ((double)(x),
- (double)(y),
- (double)(z));
+ glTranslatef (x, y, z);
}
void
-cogl_translate (gint x, gint y, gint z)
+cogl_rotate (float angle, float x, float y, float z)
{
- glTranslatef ((float)x, (float)y, (float)z);
-}
-
-void
-cogl_rotatex (float angle, gint x, gint y, gint z)
-{
- glRotated ((double)(angle),
- (double)(x),
- (double)(y),
- (double)(z));
-}
-
-void
-cogl_rotate (gint angle, gint x, gint y, gint z)
-{
- glRotatef ((float)angle, (float)x, (float)y, (float)z);
+ glRotatef (angle, x, y, z);
}
static inline gboolean
* 2) When working with small numbers, we are loosing significant
* precision
*/
- ymax =
- (zNear *
- (sinf (fovy_rad_half) /
- cosf (fovy_rad_half)));
-
+ ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half)));
xmax = (ymax * aspect);
x = (zNear / xmax);
y = (zNear / ymax);
c = (-(zFar + zNear) / ( zFar - zNear));
- d = cogl_fixed_mul_div (-(2 * zFar), zNear, (zFar - zNear));
+ d = (-(2 * zFar) * zNear) / (zFar - zNear);
#define M(row,col) m[col*4+row]
M(0,0) = (x);
GE( glMatrixMode (GL_PROJECTION) );
GE( glLoadIdentity () );
- GE( glFrustum ((double)(left),
- (double)(right),
- (double)(bottom),
- (double)(top),
- (double)(z_near),
- (double)(z_far)) );
+ GE( glFrustum ((GLdouble)(left),
+ (GLdouble)(right),
+ (GLdouble)(bottom),
+ (GLdouble)(top),
+ (GLdouble)(z_near),
+ (GLdouble)(z_far)) );
GE( glMatrixMode (GL_MODELVIEW) );
{
float fovy_rad = (fovy * G_PI) / 180;
- z_camera =
- ((sinf (fovy_rad) /
- cosf (fovy_rad)) >> 1);
+ z_camera = ((sinf (fovy_rad) / cosf (fovy_rad)) / 2);
}
GE( glTranslatef (-0.5f, -0.5f, -z_camera) );
void
cogl_get_modelview_matrix (float m[16])
{
- GLdouble md[16];
-
- glGetDoublev(GL_MODELVIEW_MATRIX, &md[0]);
-
-#define M(m,row,col) m[col*4+row]
- M(m,0,0) = (M(md,0,0));
- M(m,0,1) = (M(md,0,1));
- M(m,0,2) = (M(md,0,2));
- M(m,0,3) = (M(md,0,3));
-
- M(m,1,0) = (M(md,1,0));
- M(m,1,1) = (M(md,1,1));
- M(m,1,2) = (M(md,1,2));
- M(m,1,3) = (M(md,1,3));
-
- M(m,2,0) = (M(md,2,0));
- M(m,2,1) = (M(md,2,1));
- M(m,2,2) = (M(md,2,2));
- M(m,2,3) = (M(md,2,3));
-
- M(m,3,0) = (M(md,3,0));
- M(m,3,1) = (M(md,3,1));
- M(m,3,2) = (M(md,3,2));
- M(m,3,3) = (M(md,3,3));
-#undef M
+ glGetFloatv (GL_MODELVIEW_MATRIX, m);
}
void
cogl_get_projection_matrix (float m[16])
{
- GLdouble md[16];
-
- glGetDoublev(GL_PROJECTION_MATRIX, &md[0]);
-
-#define M(m,row,col) m[col*4+row]
- M(m,0,0) = (M(md,0,0));
- M(m,0,1) = (M(md,0,1));
- M(m,0,2) = (M(md,0,2));
- M(m,0,3) = (M(md,0,3));
-
- M(m,1,0) = (M(md,1,0));
- M(m,1,1) = (M(md,1,1));
- M(m,1,2) = (M(md,1,2));
- M(m,1,3) = (M(md,1,3));
-
- M(m,2,0) = (M(md,2,0));
- M(m,2,1) = (M(md,2,1));
- M(m,2,2) = (M(md,2,2));
- M(m,2,3) = (M(md,2,3));
-
- M(m,3,0) = (M(md,3,0));
- M(m,3,1) = (M(md,3,1));
- M(m,3,2) = (M(md,3,2));
- M(m,3,3) = (M(md,3,3));
-#undef M
+ glGetFloatv (GL_PROJECTION_MATRIX, m);
}
void
cogl_get_viewport (float v[4])
{
- GLdouble vd[4];
- glGetDoublev(GL_VIEWPORT, &vd[0]);
-
- v[0] = (vd[0]);
- v[1] = (vd[1]);
- v[2] = (vd[2]);
- v[3] = (vd[3]);
+ glGetFloatv (GL_VIEWPORT, v);
}
void
}
void
-cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a)
-{
- glClearColor ( (r),
- (g),
- (b),
- (a));
-}
-
-void
cogl_wrap_glPushMatrix ()
{
const float *src;
}
void
-cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a)
+cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a)
{
- glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB,
- (r),
- (g),
- (b),
- (a));
+ glVertexAttrib4f (COGL_GLES2_WRAPPER_COLOR_ATTRIB, r, g, b, a);
}
void
/* FIXME */
}
-static void
-cogl_gles2_float_array_to_fixed (int size,
- const GLfloat *floats,
- GLfloat *fixeds)
-{
- while (size-- > 0)
- *(fixeds++) = (*(floats++));
-}
-
void
cogl_wrap_glGetIntegerv (GLenum pname, GLint *params)
{
}
void
-cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params)
+cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params)
{
_COGL_GET_GLES2_WRAPPER (w, NO_RETVAL);
switch (pname)
{
case GL_MODELVIEW_MATRIX:
- cogl_gles2_float_array_to_fixed (16, w->modelview_stack
- + w->modelview_stack_pos * 16,
- params);
+ memcpy (params, w->modelview_stack + w->modelview_stack_pos * 16,
+ sizeof (GLfloat) * 16);
break;
case GL_PROJECTION_MATRIX:
- cogl_gles2_float_array_to_fixed (16, w->projection_stack
- + w->projection_stack_pos * 16,
- params);
+ memcpy (params, w->projection_stack + w->projection_stack_pos * 16,
+ sizeof (GLfloat) * 16);
break;
case GL_VIEWPORT:
- {
- GLfloat v[4];
-
- glGetFloatv (GL_VIEWPORT, v);
- cogl_gles2_float_array_to_fixed (4, v, params);
- }
+ glGetFloatv (GL_VIEWPORT, params);
break;
}
}
void cogl_gles2_wrapper_init (CoglGles2Wrapper *wrapper);
void cogl_gles2_wrapper_deinit (CoglGles2Wrapper *wrapper);
-void cogl_wrap_glClearColorx (GLclampx r, GLclampx g, GLclampx b, GLclampx a);
-
void cogl_wrap_glPushMatrix ();
void cogl_wrap_glPopMatrix ();
void cogl_wrap_glMatrixMode (GLenum mode);
void cogl_wrap_glAlphaFunc (GLenum func, GLclampf ref);
-void cogl_wrap_glColor4f (GLclampx r, GLclampx g, GLclampx b, GLclampx a);
+void cogl_wrap_glColor4f (GLclampf r, GLclampf g, GLclampf b, GLclampf a);
void cogl_wrap_glClipPlanef (GLenum plane, GLfloat *equation);
void cogl_wrap_glGetIntegerv (GLenum pname, GLint *params);
-void cogl_wrap_glGetFixedv (GLenum pname, GLfloat *params);
+void cogl_wrap_glGetFloatv (GLenum pname, GLfloat *params);
void cogl_wrap_glFogf (GLenum pname, GLfloat param);
void cogl_wrap_glFogfv (GLenum pname, const GLfloat *params);
/* If we're not using GL ES 2 then just use the GL functions
directly */
-#define cogl_wrap_glClearColorx glClearColorx
#define cogl_wrap_glDrawArrays glDrawArrays
#define cogl_wrap_glDrawElements glDrawElements
#define cogl_wrap_glPushMatrix glPushMatrix
#define cogl_wrap_glPopMatrix glPopMatrix
#define cogl_wrap_glMatrixMode glMatrixMode
#define cogl_wrap_glLoadIdentity glLoadIdentity
-#define cogl_wrap_glMultMatrixf glMultMatrixx
-#define cogl_wrap_glFrustumf glFrustumx
-#define cogl_wrap_glScalef glScalex
-#define cogl_wrap_glTranslatef glTranslatex
-#define cogl_wrap_glRotatef glRotatex
-#define cogl_wrap_glOrthof glOrthox
+#define cogl_wrap_glMultMatrixf glMultMatrixf
+#define cogl_wrap_glFrustumf glFrustumf
+#define cogl_wrap_glScalef glScalef
+#define cogl_wrap_glTranslatef glTranslatef
+#define cogl_wrap_glRotatef glRotatef
+#define cogl_wrap_glOrthof glOrthof
#define cogl_wrap_glEnable glEnable
#define cogl_wrap_glDisable glDisable
#define cogl_wrap_glTexCoordPointer glTexCoordPointer
#define cogl_wrap_glVertexPointer glVertexPointer
#define cogl_wrap_glColorPointer glColorPointer
#define cogl_wrap_glNormalPointer glNormalPointer
-#define cogl_wrap_glTexEnvf glTexEnvx
+#define cogl_wrap_glTexEnvf glTexEnvf
#define cogl_wrap_glEnableClientState glEnableClientState
#define cogl_wrap_glDisableClientState glDisableClientState
#define cogl_wrap_glAlphaFunc glAlphaFunc
-#define cogl_wrap_glColor4f glColor4x
-#define cogl_wrap_glClipPlanef glClipPlanex
+#define cogl_wrap_glColor4f glColor4f
+#define cogl_wrap_glClipPlanef glClipPlanef
#define cogl_wrap_glGetIntegerv glGetIntegerv
-#define cogl_wrap_glGetFixedv glGetFixedv
-#define cogl_wrap_glFogf glFogx
-#define cogl_wrap_glFogfv glFogxv
+#define cogl_wrap_glGetFloatv glGetFloatv
+#define cogl_wrap_glFogf glFogf
+#define cogl_wrap_glFogfv glFogfv
#define cogl_wrap_glTexParameteri glTexParameteri
/* The extra third parameter of the bind texture wrapper isn't needed
#include <string.h>
#include <gmodule.h>
+#include <math.h>
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16
void
-_cogl_rectangle (gint x,
- gint y,
- guint width,
- guint height)
+_cogl_rectangle (float x,
+ float y,
+ float width,
+ float height)
{
- /* 32-bit integers are not supported as coord types
- in GLES . Fixed type has got 16 bits left of the
- point which is equal to short anyway. */
-
- GLshort rect_verts[8] = {
- (GLshort) x, (GLshort) y,
- (GLshort) (x + width), (GLshort) y,
- (GLshort) x, (GLshort) (y + height),
- (GLshort) (x + width), (GLshort) (y + height)
+ GLfloat rect_verts[8] = {
+ (GLfloat) x, (GLfloat) y,
+ (GLfloat) (x + width), (GLfloat) y,
+ (GLfloat) x, (GLfloat) (y + height),
+ (GLfloat) (x + width), (GLfloat) (y + height)
};
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_enable (COGL_ENABLE_VERTEX_ARRAY
| (ctx->color_alpha < 255 ? COGL_ENABLE_BLEND : 0));
- GE ( cogl_wrap_glVertexPointer (2, GL_SHORT, 0, rect_verts ) );
+ GE ( cogl_wrap_glVertexPointer (2, GL_FLOAT, 0, rect_verts ) );
GE ( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
}
-
-void
-_cogl_rectanglex (float x,
- float y,
- float width,
- float height)
-{
- GLfloat rect_verts[8] = {
- x, y,
- x + width, y,
- x, y + height,
- x + width, y + height
- };
-
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- cogl_enable (COGL_ENABLE_VERTEX_ARRAY
- | (ctx->color_alpha < 255
- ? COGL_ENABLE_BLEND : 0));
-
- GE( cogl_wrap_glVertexPointer (2, GL_FIXED, 0, rect_verts) );
- GE( cogl_wrap_glDrawArrays (GL_TRIANGLE_STRIP, 0, 4) );
-
-}
-
void
_cogl_path_add_node (gboolean new_sub_path,
float x,
static void
_cogl_path_get_bounds (floatVec2 nodes_min,
floatVec2 nodes_max,
- gint *bounds_x,
- gint *bounds_y,
- guint *bounds_w,
- guint *bounds_h)
+ float *bounds_x,
+ float *bounds_y,
+ float *bounds_w,
+ float *bounds_h)
{
- *bounds_x = floorf (nodes_min.x);
- *bounds_y = floorf (nodes_min.y);
- *bounds_w = ceilf (nodes_max.x
- - (float)(*bounds_x));
- *bounds_h = ceilf (nodes_max.y
- - (float)(*bounds_y));
+ *bounds_x = nodes_min.x;
+ *bounds_y = nodes_min.y;
+ *bounds_w = nodes_max.x - *bounds_x;
+ *bounds_h = nodes_max.y - *bounds_y;
}
static gint compare_ints (gconstpointer a,
{
guint path_start = 0;
guint sub_path_num = 0;
- gint bounds_x;
- gint bounds_y;
- guint bounds_w;
- guint bounds_h;
+ float bounds_x;
+ float bounds_y;
+ float bounds_w;
+ float bounds_h;
_cogl_path_get_bounds (nodes_min, nodes_max,
&bounds_x, &bounds_y, &bounds_w, &bounds_h);
GE( cogl_wrap_glMatrixMode (GL_PROJECTION) );
GE( cogl_wrap_glPushMatrix () );
GE( cogl_wrap_glLoadIdentity () );
- cogl_rectanglex (-1.0, -1.0,
- (float)(2),
- (float)(2));
- cogl_rectanglex (-1.0, -1.0,
- (float)(2),
- (float)(2));
+ cogl_rectangle (-1.0, -1.0, 2, 2);
+ cogl_rectangle (-1.0, -1.0, 2, 2);
GE( cogl_wrap_glPopMatrix () );
GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) );
GE( cogl_wrap_glPopMatrix () );
void
_cogl_path_fill_nodes ()
{
- gint bounds_x;
- gint bounds_y;
- guint bounds_w;
- guint bounds_h;
+ float bounds_x;
+ float bounds_y;
+ float bounds_w;
+ float bounds_h;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
#include <string.h>
#include <stdlib.h>
+#include <math.h>
#define glVertexPointer cogl_wrap_glVertexPointer
#define glTexCoordPointer cogl_wrap_glTexCoordPointer
guint wx, wy;
src = source_bmp->data
- + (src_y + (y_iter.intersect_start)
+ + (src_y + ((int)y_iter.intersect_start)
- dst_y)
* source_bmp->rowstride
+ (src_x + x_span->start + x_span->size - x_span->waste
guint copy_width;
src = source_bmp->data
- + (src_x + (x_iter.intersect_start)
+ + (src_x + ((int)x_iter.intersect_start)
- dst_x)
* bpp
+ (src_y + y_span->start + y_span->size - y_span->waste
#include "cogl-context.h"
#include "cogl-gles2-wrapper.h"
+#include <math.h>
/* GL error to string conversion */
#if COGL_DEBUG
fprintf(stderr, "\n ============== Paint Start ================ \n");
#endif
- cogl_wrap_glClearColorx (cogl_color_get_red (color),
- cogl_color_get_green (color),
- cogl_color_get_blue (color),
- 0);
+ glClearColor (cogl_color_get_red (color),
+ cogl_color_get_green (color),
+ cogl_color_get_blue (color),
+ 0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
cogl_wrap_glDisable (GL_LIGHTING);
}
void
-cogl_translatex (float x, float y, float z)
+cogl_translate (float x, float y, float z)
{
GE( cogl_wrap_glTranslatef (x, y, z) );
}
void
-cogl_translate (gint x, gint y, gint z)
+cogl_rotate (float angle, float x, float y, float z)
{
- GE( cogl_wrap_glTranslatef ((float)(x),
- (float)(y),
- (float)(z)) );
-}
-
-void
-cogl_rotatex (float angle,
- float x,
- float y,
- float z)
-{
- GE( cogl_wrap_glRotatef (angle,x,y,z) );
-}
-
-void
-cogl_rotate (gint angle, gint x, gint y, gint z)
-{
- GE( cogl_wrap_glRotatef ((float)(angle),
- (float)(x),
- (float)(y),
- (float)(z)) );
+ GE( cogl_wrap_glRotatef (angle, x, y, z) );
}
static inline gboolean
/* Calculate the angle between the axes and the line crossing the
two points */
- angle = (atan2f (vertex_b[1] - vertex_a[1] *
- vertex_b[0] - vertex_a[0]),
- COGL_RADIANS_TO_DEGREES);
+ angle = atan2f (vertex_b[1] - vertex_a[1],
+ vertex_b[0] - vertex_a[0]) * (180.0/G_PI);
GE( cogl_wrap_glPushMatrix () );
/* Load the identity matrix and multiply by the reverse of the
float vertex_br[4] = { x_offset + width, y_offset + height,
0, 1.0 };
- GE( cogl_wrap_glGetFixedv (GL_MODELVIEW_MATRIX, modelview) );
- GE( cogl_wrap_glGetFixedv (GL_PROJECTION_MATRIX, projection) );
+ GE( cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, modelview) );
+ GE( cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, projection) );
project_vertex (modelview, projection, vertex_tl);
project_vertex (modelview, projection, vertex_tr);
GE( glStencilFunc (GL_NEVER, 0x1, 0x1) );
GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) );
- cogl_rectanglex (x_offset, y_offset, width, height);
+ cogl_rectangle (x_offset, y_offset, width, height);
}
else
{
rectangle */
GE( glStencilFunc (GL_NEVER, 0x1, 0x3) );
GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) );
- cogl_rectanglex (x_offset, y_offset, width, height);
+ cogl_rectangle (x_offset, y_offset, width, height);
/* Subtract one from all pixels in the stencil buffer so that
only pixels where both the original stencil buffer and the
GE( cogl_wrap_glMatrixMode (GL_PROJECTION) );
GE( cogl_wrap_glPushMatrix () );
GE( cogl_wrap_glLoadIdentity () );
- cogl_rectanglex (-1.0, -1.0,
- (float)(2),
- (float)(2));
+ cogl_rectangle (-1.0, -1.0, 2, 2);
GE( cogl_wrap_glPopMatrix () );
GE( cogl_wrap_glMatrixMode (GL_MODELVIEW) );
GE( cogl_wrap_glPopMatrix () );
* 2) When working with small numbers, we can are loosing significant
* precision
*/
- ymax = (zNear *
- (sinf (fovy_rad_half) /
- cosf (fovy_rad_half)));
+ ymax = (zNear * (sinf (fovy_rad_half) / cosf (fovy_rad_half)));
xmax = (ymax * aspect);
x = (zNear / xmax);
y = (zNear / ymax);
c = (-(zFar + zNear) / ( zFar - zNear));
- d = (-((2 * zFar * zNear)) / (zFar - zNear));
+ d = (-(2 * zFar) * zNear) / (zFar - zNear);
#define M(row,col) m[col*4+row]
M(0,0) = x;
if (fovy != 60.0)
{
float fovy_rad = (fovy * G_PI) / 180;
-
- z_camera = (sinf (fovy_rad) /
- cosf (fovy_rad)) >> 1;
+
+ z_camera = (sinf (fovy_rad) / cosf (fovy_rad)) / 2;
}
- GE( cogl_wrap_glTranslatef (-1 << 15, -1 << 15, -z_camera) );
+
+ GE( cogl_wrap_glTranslatef (-0.5f, -0.5f, -z_camera) );
GE( cogl_wrap_glScalef ( 1.0 / width,
-1.0 / height,
void
cogl_get_modelview_matrix (float m[16])
{
- cogl_wrap_glGetFixedv(GL_MODELVIEW_MATRIX, &m[0]);
+ cogl_wrap_glGetFloatv (GL_MODELVIEW_MATRIX, m);
}
void
cogl_get_projection_matrix (float m[16])
{
- cogl_wrap_glGetFixedv(GL_PROJECTION_MATRIX, &m[0]);
+ cogl_wrap_glGetFloatv (GL_PROJECTION_MATRIX, m);
}
void
*(p++) = cache_value->tx2; *(p++) = cache_value->ty2;
}
-#define COGL_PANGO_UNIT_TO_FIXED(x) ((x) << (COGL_FIXED_Q - 10))
-
static void cogl_pango_renderer_finalize (GObject *object);
static void cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer,
PangoFont *font,
}
else
{
- *xout = COGL_PANGO_UNIT_TO_FIXED (xin);
- *yout = COGL_PANGO_UNIT_TO_FIXED (yin);
+ *xout = PANGO_PIXELS (xin);
+ *yout = PANGO_PIXELS (yin);
}
}
x + width, y + height,
&x2, &y2);
- cogl_rectanglex (x1, y1, x2 - x1, y2 - y1);
+ cogl_rectangle (x1, y1, x2 - x1, y2 - y1);
}
static void
cogl_path_stroke_preserve
cogl_set_source_color
cogl_set_source_color4ub
-cogl_set_source_color4x
+cogl_set_source_color4f
<SUBSECTION>
cogl_rectangle
cogl_color_free
cogl_color_set_from_4ub
cogl_color_set_from_4d
-cogl_color_set_from_4x
+cogl_color_set_from_4f
<SUBSECTION>
cogl_color_get_red
/* Set the color to white so that all the textures will be drawn
at their own color */
- cogl_set_source_color4x (1.0, 1.0,
+ cogl_set_source_color4f (1.0, 1.0,
1.0, 1.0);
x2 = x1 + (float)(TEXTURE_SIZE);
x2 = x1 + (float)(TEXTURE_SIZE);
/* Draw a regular rectangle (this should always show) */
- cogl_set_source_color4x (1.0, 0, 0, 1.0);
+ cogl_set_source_color4f (1.0, 0, 0, 1.0);
cogl_rectangle ( (x1), (y1),
(x2 - x1), (y2 - y1));
ClutterFixed sin_frame, cos_frame;
ClutterFixed frac_frame;
gint t;
- sin_frame = clutter_sini (CLUTTER_ANGLE_FROM_DEG (priv->frame));
- cos_frame = clutter_cosi (CLUTTER_ANGLE_FROM_DEG (priv->frame));
+ sin_frame = clutter_sinx (priv->frame);
+ cos_frame = clutter_cosx (priv->frame);
pingpong_frame = (priv->frame <= 180 ? priv->frame : 360 - priv->frame);
frac_frame = (CLUTTER_INT_TO_FIXED (pingpong_frame) /
- CLUTTER_INT_TO_FIXED (180));
- frac_frame += (1.0 >> 1);
- frac_frame <<= 1;
+ CLUTTER_INT_TO_FIXED (180));
+ frac_frame += 0.5;
+ frac_frame *= 2;
for (t=0; t<4; t+=2)
{