mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 19:12:04 +00:00
changed ClutterPerspective.fovy from ClutterAngle to degrees
This commit is contained in:
parent
016633db7b
commit
b6a703a99e
@ -168,7 +168,7 @@ ClutterFixed clutter_tani (ClutterAngle angle);
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
#define clutter_cosx(angle) (clutter_fixed_sin((angle) + CFX_PI_2))
|
||||
#define clutter_cosx(angle) (clutter_sinx((angle) + CFX_PI_2))
|
||||
|
||||
/**
|
||||
* clutter_cosi:
|
||||
|
@ -426,7 +426,7 @@ clutter_stage_init (ClutterStage *self)
|
||||
priv->color.blue = 0xff;
|
||||
priv->color.alpha = 0xff;
|
||||
|
||||
priv->perspective.fovy = 171; /* 60 Degrees */
|
||||
priv->perspective.fovy = CFX_60; /* 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);
|
||||
@ -574,7 +574,7 @@ clutter_stage_set_perspective (ClutterStage *stage,
|
||||
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
||||
|
||||
priv = stage->priv;
|
||||
priv->perspective.fovy = CLUTTER_ANGLE_FROM_DEGF(fovy);
|
||||
priv->perspective.fovy = CLUTTER_FLOAT_TO_FIXED(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);
|
||||
@ -601,7 +601,7 @@ clutter_stage_get_perspective (ClutterStage *stage,
|
||||
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
||||
|
||||
priv = stage->priv;
|
||||
*fovy = CLUTTER_ANGLE_TO_DEGF(priv->perspective.fovy);
|
||||
*fovy = CLUTTER_FIXED_TO_FLOAT(priv->perspective.fovy);
|
||||
*aspect = CLUTTER_FIXED_TO_FLOAT(priv->perspective.aspect);
|
||||
*z_near = CLUTTER_FIXED_TO_FLOAT(priv->perspective.z_near);
|
||||
*z_far = CLUTTER_FIXED_TO_FLOAT(priv->perspective.z_far);
|
||||
|
@ -63,7 +63,7 @@ gboolean
|
||||
cogl_check_extension (const gchar *name, const gchar *ext);
|
||||
|
||||
void
|
||||
cogl_perspective (ClutterAngle fovy,
|
||||
cogl_perspective (ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed zNear,
|
||||
ClutterFixed zFar);
|
||||
@ -71,7 +71,7 @@ cogl_perspective (ClutterAngle fovy,
|
||||
void
|
||||
cogl_setup_viewport (guint width,
|
||||
guint height,
|
||||
ClutterAngle fovy,
|
||||
ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far);
|
||||
|
@ -443,13 +443,14 @@ cogl_alpha_func (COGLenum func,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_perspective (ClutterAngle fovy,
|
||||
cogl_perspective (ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed zNear,
|
||||
ClutterFixed zFar)
|
||||
{
|
||||
ClutterFixed xmax, ymax;
|
||||
ClutterFixed x, y, c, d;
|
||||
ClutterFixed fovy_rad_half = CFX_MUL (fovy, CFX_PI) / 360;
|
||||
|
||||
GLfloat m[16];
|
||||
|
||||
@ -461,10 +462,11 @@ cogl_perspective (ClutterAngle fovy,
|
||||
* 1) xmin = -xmax => xmax + xmin == 0 && xmax - xmin == 2 * xmax
|
||||
* same true for y, hence: a == 0 && b == 0;
|
||||
*
|
||||
* 2) When working with small numbers, we can are loosing significant
|
||||
* 2) When working with small numbers, we are loosing significant
|
||||
* precision, hence we use clutter_qmulx() here, not the fast macro.
|
||||
*/
|
||||
ymax = clutter_qmulx (zNear, clutter_tani (fovy >> 1));
|
||||
ymax = clutter_qmulx (zNear, CFX_DIV (clutter_sinx (fovy_rad_half),
|
||||
clutter_cosx (fovy_rad_half)));
|
||||
xmax = clutter_qmulx (ymax, aspect);
|
||||
|
||||
x = CFX_DIV (zNear, xmax);
|
||||
@ -486,12 +488,13 @@ cogl_perspective (ClutterAngle fovy,
|
||||
void
|
||||
cogl_setup_viewport (guint width,
|
||||
guint height,
|
||||
ClutterAngle fovy,
|
||||
ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
{
|
||||
GLfloat z_camera;
|
||||
ClutterFixed fovy_rad = CFX_MUL (fovy, CFX_PI) / 180;
|
||||
|
||||
GE( glViewport (0, 0, width, height) );
|
||||
|
||||
@ -505,8 +508,8 @@ cogl_setup_viewport (guint width,
|
||||
|
||||
/* camera distance from screen, 0.5 * tan (FOV) */
|
||||
#define DEFAULT_Z_CAMERA 0.866025404f
|
||||
z_camera = CLUTTER_FIXED_TO_FLOAT (clutter_tani (fovy) >> 1);
|
||||
|
||||
z_camera = CLUTTER_FIXED_TO_FLOAT (CFX_DIV (clutter_sinx (fovy_rad),
|
||||
clutter_cosx (fovy_rad)) >> 1);
|
||||
GE( glTranslatef (-0.5f, -0.5f, -z_camera) );
|
||||
GE( glScalef ( 1.0f / width,
|
||||
-1.0f / height,
|
||||
|
@ -449,13 +449,14 @@ cogl_alpha_func (COGLenum func,
|
||||
* Fixed point implementation of the perspective function
|
||||
*/
|
||||
void
|
||||
cogl_perspective (ClutterAngle fovy,
|
||||
cogl_perspective (ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed zNear,
|
||||
ClutterFixed zFar)
|
||||
{
|
||||
ClutterFixed xmax, ymax;
|
||||
ClutterFixed x, y, c, d;
|
||||
ClutterFixed fovy_rad_half = CFX_MUL (fovy, CFX_PI) / 360;
|
||||
|
||||
GLfixed m[16];
|
||||
|
||||
@ -470,7 +471,8 @@ cogl_perspective (ClutterAngle fovy,
|
||||
* 2) When working with small numbers, we can are loosing significant
|
||||
* precision, hence we use clutter_qmulx() here, not the fast macro.
|
||||
*/
|
||||
ymax = clutter_qmulx (zNear, clutter_tani (fovy >> 1));
|
||||
ymax = clutter_qmulx (zNear, CFX_DIV (clutter_sinx (fovy_rad_half),
|
||||
clutter_cosx (fovy_rad_half)));
|
||||
xmax = clutter_qmulx (ymax, aspect);
|
||||
|
||||
x = CFX_DIV (zNear, xmax);
|
||||
@ -490,9 +492,9 @@ cogl_perspective (ClutterAngle fovy,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_setup_viewport (guint w,
|
||||
guint h,
|
||||
ClutterAngle fovy,
|
||||
cogl_setup_viewport (guint w,
|
||||
guint h,
|
||||
ClutterFixed fovy,
|
||||
ClutterFixed aspect,
|
||||
ClutterFixed z_near,
|
||||
ClutterFixed z_far)
|
||||
@ -500,6 +502,7 @@ cogl_setup_viewport (guint w,
|
||||
gint width = (gint) w;
|
||||
gint height = (gint) h;
|
||||
ClutterFixed z_camera;
|
||||
ClutterFixed fovy_rad = CFX_MUL (fovy, CFX_PI) / 180;
|
||||
|
||||
GE( glViewport (0, 0, width, height) );
|
||||
GE( glMatrixMode (GL_PROJECTION) );
|
||||
@ -516,7 +519,8 @@ 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;
|
||||
z_camera = CFX_DIV (clutter_sinx (fovy_rad),
|
||||
clutter_cosx (fovy_rad)) >> 1;
|
||||
|
||||
GE( glTranslatex (-1 << 15, -1 << 15, -z_camera));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user