diff --git a/gl/cogl.c b/gl/cogl.c index bb6853b76..91af4be31 100644 --- a/gl/cogl.c +++ b/gl/cogl.c @@ -549,6 +549,8 @@ cogl_setup_viewport (guint width, ClutterFixed z_near, ClutterFixed z_far) { + GLfloat z_camera; + GE( glViewport (0, 0, width, height) ); GE( glMatrixMode (GL_PROJECTION) ); @@ -562,7 +564,9 @@ cogl_setup_viewport (guint width, /* camera distance from screen, 0.5 * tan (FOV) */ #define DEFAULT_Z_CAMERA 0.866025404f - GE( glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA) ); + z_camera = CLUTTER_FIXED_TO_FLOAT (clutter_tani (fovy) >> 1); + + GE( glTranslatef (-0.5f, -0.5f, -z_camera) ); GE( glScalef ( 1.0f / width, -1.0f / height, 1.0f / width) ); diff --git a/gles/cogl.c b/gles/cogl.c index 0739a7b57..133572438 100644 --- a/gles/cogl.c +++ b/gles/cogl.c @@ -489,7 +489,8 @@ cogl_setup_viewport (guint w, { gint width = (gint) w; gint height = (gint) h; - + ClutterFixed z_camera; + GE( glViewport (0, 0, width, height) ); GE( glMatrixMode (GL_PROJECTION) ); GE( glLoadIdentity () ); @@ -505,10 +506,9 @@ cogl_setup_viewport (guint w, /* camera distance from screen, 0.5 * tan (FOV) */ #define DEFAULT_Z_CAMERA 0.866025404f - - GE( glTranslatex (-1 << 15, - -1 << 15, - -CLUTTER_FLOAT_TO_FIXED(DEFAULT_Z_CAMERA)) ); + z_camera = clutter_tani (fovy) << 1; + + GE( glTranslatex (-1 << 15, -1 << 15, -z_camera ); GE( glScalex ( CFX_ONE / width, -CFX_ONE / height,