mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 03:50:47 -05:00
[gles] Fix computation of camera distance
Port the fix in commit f409b58e
to the GLES implementation of
COGL.
This commit is contained in:
parent
f409b58e89
commit
e1ab6f972e
@ -615,8 +615,8 @@ cogl_viewport (guint width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_setup_viewport (guint w,
|
cogl_setup_viewport (guint w,
|
||||||
guint h,
|
guint h,
|
||||||
float fovy,
|
float fovy,
|
||||||
float aspect,
|
float aspect,
|
||||||
float z_near,
|
float z_near,
|
||||||
@ -625,6 +625,7 @@ cogl_setup_viewport (guint w,
|
|||||||
gint width = (gint) w;
|
gint width = (gint) w;
|
||||||
gint height = (gint) h;
|
gint height = (gint) h;
|
||||||
float z_camera;
|
float z_camera;
|
||||||
|
float projection_matrix[16];
|
||||||
|
|
||||||
GE( glViewport (0, 0, width, height) );
|
GE( glViewport (0, 0, width, height) );
|
||||||
|
|
||||||
@ -634,24 +635,16 @@ cogl_setup_viewport (guint w,
|
|||||||
|
|
||||||
cogl_perspective (fovy, aspect, z_near, z_far);
|
cogl_perspective (fovy, aspect, z_near, z_far);
|
||||||
|
|
||||||
GE( cogl_wrap_glLoadIdentity () );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* camera distance from screen, 0.5 * tan (FOV)
|
* camera distance from screen
|
||||||
*
|
*
|
||||||
* See comments in ../gl/cogl.c
|
* See comments in ../gl/cogl.c
|
||||||
*/
|
*/
|
||||||
#define DEFAULT_Z_CAMERA 0.869f
|
|
||||||
z_camera = (DEFAULT_Z_CAMERA);
|
|
||||||
|
|
||||||
if (fovy != 60.0)
|
|
||||||
{
|
|
||||||
float fovy_rad = (fovy * G_PI) / 180;
|
|
||||||
|
|
||||||
z_camera = (sinf (fovy_rad) / cosf (fovy_rad)) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
cogl_get_projection_matrix (projection_matrix);
|
||||||
|
z_camera = 0.5 * projection_matrix[0];
|
||||||
|
|
||||||
|
GE( cogl_wrap_glLoadIdentity () );
|
||||||
|
|
||||||
GE( cogl_wrap_glTranslatef (-0.5f, -0.5f, -z_camera) );
|
GE( cogl_wrap_glTranslatef (-0.5f, -0.5f, -z_camera) );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user