cogl: removes unused _cogl_setup_viewport

Clutter has now taken responsibility for managing its viewport,
projection matrix and view transform as part of ClutterStage so
_cogl_setup_viewport is no longer used by anything, and since it's quite
an obscure API anyway it's we've taken the opportunity to remove the
function.
This commit is contained in:
Robert Bragg 2010-09-07 23:35:26 +01:00
parent 95ff71d01c
commit 105451d1be
2 changed files with 0 additions and 100 deletions

View File

@ -411,80 +411,6 @@ cogl_viewport (unsigned int width,
cogl_set_viewport (0, 0, width, height); cogl_set_viewport (0, 0, width, height);
} }
void
_cogl_setup_viewport (unsigned int width,
unsigned int height,
float fovy,
float aspect,
float z_near,
float z_far)
{
float z_camera;
CoglMatrix projection_matrix;
CoglMatrixStack *modelview_stack;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
cogl_set_viewport (0, 0, width, height);
/* For Ortho projection.
* _cogl_matrix_stack_ortho (projection_stack, 0, width, 0, height, -1, 1);
*/
cogl_perspective (fovy, aspect, z_near, z_far);
/*
* In theory, we can compute the camera distance from screen as:
*
* 0.5 * tan (FOV)
*
* However, it's better to compute the z_camera from our projection
* matrix so that we get a 1:1 mapping at the screen distance. Consider
* the upper-left corner of the screen. It has object coordinates
* (0,0,0), so by the transform below, ends up with eye coordinate
*
* x_eye = x_object / width - 0.5 = - 0.5
* y_eye = (height - y_object) / width - 0.5 = 0.5
* z_eye = z_object / width - z_camera = - z_camera
*
* From cogl_perspective(), we know that the projection matrix has
* the form:
*
* (x, 0, 0, 0)
* (0, y, 0, 0)
* (0, 0, c, d)
* (0, 0, -1, 0)
*
* Applied to the above, we get clip coordinates of
*
* x_clip = x * (- 0.5)
* y_clip = y * 0.5
* w_clip = - 1 * (- z_camera) = z_camera
*
* Dividing through by w to get normalized device coordinates, we
* have, x_nd = x * 0.5 / z_camera, y_nd = - y * 0.5 / z_camera.
* The upper left corner of the screen has normalized device coordinates,
* (-1, 1), so to have the correct 1:1 mapping, we have to have:
*
* z_camera = 0.5 * x = 0.5 * y
*
* If x != y, then we have a non-uniform aspect ration, and a 1:1 mapping
* doesn't make sense.
*/
cogl_get_projection_matrix (&projection_matrix);
z_camera = 0.5 * projection_matrix.xx;
modelview_stack =
_cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ());
_cogl_matrix_stack_load_identity (modelview_stack);
_cogl_matrix_stack_translate (modelview_stack, -0.5f, -0.5f, -z_camera);
_cogl_matrix_stack_scale (modelview_stack,
1.0f / width, -1.0f / height, 1.0f / width);
_cogl_matrix_stack_translate (modelview_stack,
0.0f, -1.0 * height, 0.0f);
}
CoglFeatureFlags CoglFeatureFlags
cogl_get_features (void) cogl_get_features (void)
{ {

View File

@ -290,32 +290,6 @@ cogl_ortho (float left,
float near, float near,
float far); float far);
/*
* _cogl_setup_viewport:
* @width: Width of the viewport
* @height: Height of the viewport
* @fovy: Field of view angle in degrees
* @aspect: Aspect ratio to determine the field of view along the x-axis
* @z_near: Nearest visible point along the z-axis
* @z_far: Furthest visible point along the z-axis
*
* Replaces the current viewport and projection matrix with the given
* values. The viewport is placed at the top left corner of the window
* with the given width and height. The projection matrix is replaced
* with one that has a viewing angle of @fovy along the y-axis and a
* view scaled according to @aspect along the x-axis. The view is
* clipped according to @z_near and @z_far on the z-axis.
*
* This function is used only by Clutter.
*/
void
_cogl_setup_viewport (unsigned int width,
unsigned int height,
float fovy,
float aspect,
float z_near,
float z_far);
#ifndef COGL_DISABLE_DEPRECATED #ifndef COGL_DISABLE_DEPRECATED
/** /**