2006-08-29 15:09:43 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
2007-04-12 08:42:07 -04:00
|
|
|
* Tomas Frydrych <tf@openedhand.com>
|
2006-08-29 15:09:43 -04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2008-10-30 13:04:34 -04:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2006-08-29 15:09:43 -04:00
|
|
|
*/
|
|
|
|
|
2008-10-30 13:04:34 -04:00
|
|
|
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
|
|
|
#error "Only <clutter/clutter.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __CLUTTER_FIXED_H__
|
|
|
|
#define __CLUTTER_FIXED_H__
|
2006-08-29 15:09:43 -04:00
|
|
|
|
2008-04-17 06:08:17 -04:00
|
|
|
#include <glib-object.h>
|
2008-10-30 13:04:34 -04:00
|
|
|
#include <cogl/cogl.h>
|
2006-08-29 15:09:43 -04:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
|
|
|
* ClutterFixed:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point number (16.16)
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
typedef float ClutterFixed;
|
2007-01-17 11:00:00 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ClutterAngle:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2009-01-20 11:20:55 -05:00
|
|
|
* An abstract representation of an angle.
|
2007-01-17 11:00:00 -05:00
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
typedef float ClutterAngle;
|
2006-08-29 15:09:43 -04:00
|
|
|
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_ANGLE_FROM_DEG(x) ((float)(x))
|
|
|
|
#define CLUTTER_ANGLE_FROM_DEGX(x) (CLUTTER_FIXED_TO_FLOAT (x))
|
|
|
|
#define CLUTTER_ANGLE_TO_DEG(x) ((float)(x))
|
|
|
|
#define CLUTTER_ANGLE_TO_DEGX(x) (CLUTTER_FLOAT_TO_FIXED (x))
|
2007-05-25 08:07:24 -04:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/*
|
|
|
|
* some commonly used constants
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CFX_ONE:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* 1.0 represented as a fixed point value.
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_ONE 1.0
|
2007-08-07 07:35:22 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CFX_HALF:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* 0.5 represented as a fixed point value.
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_HALF 0.5
|
2007-08-07 07:35:22 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CFX_MAX:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Maximum fixed point value.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CFX_MAX G_MAXFLOAT
|
2007-01-16 05:39:18 -05:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/**
|
|
|
|
* CFX_MIN:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Minimum fixed point value.
|
2007-01-16 05:39:18 -05:00
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CFX_MIN (-G_MAXFLOAT)
|
2007-01-17 11:00:00 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CFX_PI:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of Pi
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_PI G_PI
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
|
|
|
* CFX_2PI:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of Pi*2
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CFX_2PI (G_PI * 2)
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
2007-06-01 06:00:35 -04:00
|
|
|
* CFX_PI_2:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of Pi/2
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CFX_PI_2 (G_PI / 2)
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
2007-06-01 06:00:35 -04:00
|
|
|
* CFX_PI_4:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of Pi/4
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CFX_PI_4 (G_PI / 4)
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
|
|
|
* CFX_360:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of the number 360
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_360 360.0
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
|
|
|
* CFX_240:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of the number 240
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_240 240.0
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
|
|
|
* CFX_180:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of the number 180
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_180 180.0
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
|
|
|
* CFX_120:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of the number 120
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_120 120.0
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
|
|
|
* CFX_60:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of the number 60
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_60 60.0
|
2008-06-02 08:34:10 -04:00
|
|
|
/**
|
|
|
|
* CFX_RADIANS_TO_DEGREES:
|
|
|
|
*
|
|
|
|
* Fixed point representation of the number 180 / pi
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CFX_RADIANS_TO_DEGREES (180.0 / G_PI)
|
2007-01-17 11:00:00 -05:00
|
|
|
/**
|
|
|
|
* CFX_255:
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-01-17 11:00:00 -05:00
|
|
|
* Fixed point representation of the number 255
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CFX_255 255.0
|
2006-08-29 15:09:43 -04:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/**
|
|
|
|
* CLUTTER_FIXED_TO_FLOAT:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a fixed point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Convert a fixed point value to float.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FIXED_TO_FLOAT(x) (x)
|
2007-08-07 07:35:22 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CLUTTER_FIXED_TO_DOUBLE:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a fixed point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Convert a fixed point value to double.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FIXED_TO_DOUBLE(x) ((double)(x))
|
2007-01-15 13:37:12 -05:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/**
|
|
|
|
* CLUTTER_FLOAT_TO_FIXED:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a floating point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Convert a float value to fixed.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FLOAT_TO_FIXED(x) ((x))
|
2007-08-07 07:35:22 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CLUTTER_FLOAT_TO_INT:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a floating point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Convert a float value to int.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FLOAT_TO_INT(x) ((int)(x))
|
2007-08-07 07:35:22 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CLUTTER_FLOAT_TO_UINT:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a floating point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Convert a float value to unsigned int.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FLOAT_TO_UINT(x) ((unsigned int)(x))
|
2006-08-29 15:09:43 -04:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/**
|
|
|
|
* CLUTTER_INT_TO_FIXED:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: an integer value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Convert an integer value to fixed point.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_INT_TO_FIXED(x) ((float)(x))
|
2007-08-07 07:35:22 -04:00
|
|
|
|
2007-10-02 10:53:32 -04:00
|
|
|
/**
|
|
|
|
* CLUTTER_FIXED_TO_INT:
|
|
|
|
* @x: a fixed point value
|
|
|
|
*
|
|
|
|
* Converts a fixed point value to integer (removing the decimal part).
|
|
|
|
*
|
|
|
|
* Since: 0.6
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FIXED_TO_INT(x) ((int)(x))
|
2007-10-09 09:24:52 -04:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/**
|
|
|
|
* CLUTTER_FIXED_FRACTION:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a fixed point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-10-02 10:53:32 -04:00
|
|
|
* Retrieves the fractionary part of a fixed point value
|
2007-08-07 07:35:22 -04:00
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FIXED_FRACTION(x) ((x)-floorf (x))
|
2007-08-07 07:35:22 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CLUTTER_FIXED_FLOOR:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a fixed point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Round down a fixed point value to an integer.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FIXED_FLOOR(x) (floorf (x))
|
2008-10-30 12:37:55 -04:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/**
|
|
|
|
* CLUTTER_FIXED_CEIL:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a fixed point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Round up a fixed point value to an integer.
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_FIXED_CEIL(x) (ceilf (x))
|
2006-08-29 15:09:43 -04:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/**
|
|
|
|
* CLUTTER_FIXED_MUL:
|
2007-08-07 10:03:58 -04:00
|
|
|
* @x: a fixed point value
|
|
|
|
* @y: a fixed point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 07:35:22 -04:00
|
|
|
* Multiply two fixed point values
|
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CLUTTER_FIXED_MUL(x,y) ((x) * (y))
|
2006-08-29 15:09:43 -04:00
|
|
|
|
2007-08-07 07:35:22 -04:00
|
|
|
/**
|
2007-08-07 10:03:58 -04:00
|
|
|
* CLUTTER_FIXED_DIV:
|
|
|
|
* @x: a fixed point value
|
|
|
|
* @y: a fixed point value
|
2007-11-06 10:46:23 -05:00
|
|
|
*
|
2007-08-07 10:03:58 -04:00
|
|
|
* Divide two fixed point values
|
2007-08-07 07:35:22 -04:00
|
|
|
*/
|
2009-01-20 11:20:54 -05:00
|
|
|
#define CLUTTER_FIXED_DIV(x,y) ((x) / (y))
|
2008-06-02 08:34:10 -04:00
|
|
|
|
2009-01-20 11:20:54 -05:00
|
|
|
#define clutter_qmulx(x,y) ((x) * (y))
|
|
|
|
#define clutter_qdivx(x,y) ((x) / (y))
|
2007-01-17 11:00:00 -05:00
|
|
|
|
2009-01-20 11:20:55 -05:00
|
|
|
#define clutter_sinx(a) sinf (a * (G_PI/180.0))
|
|
|
|
#define clutter_tanx(a) tanf (a * (G_PI/180.0))
|
|
|
|
#define clutter_atanx(a) atanf (a * (G_PI/180.0))
|
|
|
|
#define clutter_atan2x(x,y) atan2f (x, y)
|
|
|
|
#define clutter_cosx(a) cosf (a * (G_PI/180.0))
|
2007-01-19 11:04:06 -05:00
|
|
|
|
2008-04-17 06:08:17 -04:00
|
|
|
#define CLUTTER_TYPE_FIXED (clutter_fixed_get_type ())
|
|
|
|
#define CLUTTER_TYPE_PARAM_FIXED (clutter_param_fixed_get_type ())
|
|
|
|
#define CLUTTER_PARAM_SPEC_FIXED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), CLUTTER_TYPE_PARAM_FIXED, ClutterParamSpecFixed))
|
|
|
|
#define CLUTTER_IS_PARAM_SPEC_FIXED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), CLUTTER_TYPE_PARAM_FIXED))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CLUTTER_VALUE_HOLDS_FIXED:
|
|
|
|
* @x: a #GValue
|
|
|
|
*
|
|
|
|
* Evaluates to %TRUE if @x holds a #ClutterFixed.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
#define CLUTTER_VALUE_HOLDS_FIXED(x) (G_VALUE_HOLDS ((x), CLUTTER_TYPE_FIXED))
|
|
|
|
|
|
|
|
typedef struct _ClutterParamSpecFixed ClutterParamSpecFixed;
|
|
|
|
|
2008-04-17 07:09:27 -04:00
|
|
|
/**
|
|
|
|
* CLUTTER_MAXFIXED:
|
|
|
|
*
|
|
|
|
* Higher boundary for #ClutterFixed
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_MAXFIXED G_MAXFLOAT
|
2008-04-17 07:09:27 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CLUTTER_MINFIXED:
|
|
|
|
*
|
|
|
|
* Lower boundary for #ClutterFixed
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2009-01-20 11:20:55 -05:00
|
|
|
#define CLUTTER_MINFIXED (-G_MAXFLOAT)
|
2008-04-17 07:09:27 -04:00
|
|
|
|
2008-04-17 06:08:17 -04:00
|
|
|
/**
|
|
|
|
* ClutterParamSpecFixed
|
|
|
|
* @minimum: lower boundary
|
|
|
|
* @maximum: higher boundary
|
|
|
|
* @default_value: default value
|
|
|
|
*
|
|
|
|
* #GParamSpec subclass for fixed point based properties
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
struct _ClutterParamSpecFixed
|
|
|
|
{
|
|
|
|
/*< private >*/
|
|
|
|
GParamSpec parent_instance;
|
|
|
|
|
|
|
|
/*< public >*/
|
|
|
|
ClutterFixed minimum;
|
|
|
|
ClutterFixed maximum;
|
|
|
|
ClutterFixed default_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
GType clutter_fixed_get_type (void) G_GNUC_CONST;
|
|
|
|
GType clutter_param_fixed_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
void clutter_value_set_fixed (GValue *value,
|
|
|
|
ClutterFixed fixed_);
|
|
|
|
ClutterFixed clutter_value_get_fixed (const GValue *value);
|
|
|
|
|
|
|
|
GParamSpec * clutter_param_spec_fixed (const gchar *name,
|
|
|
|
const gchar *nick,
|
|
|
|
const gchar *blurb,
|
|
|
|
ClutterFixed minimum,
|
|
|
|
ClutterFixed maximum,
|
|
|
|
ClutterFixed default_value,
|
|
|
|
GParamFlags flags);
|
|
|
|
|
2007-07-04 11:30:44 -04:00
|
|
|
|
2006-08-29 15:09:43 -04:00
|
|
|
G_END_DECLS
|
|
|
|
|
2008-10-30 13:04:34 -04:00
|
|
|
#endif /* __CLUTTER_FIXED_H__ */
|