コード例 #1
0
ファイル: matrix.c プロジェクト: krnowak/mesa
/**
 * Apply an orthographic projection matrix.
 *
 * \param left left clipping plane coordinate.
 * \param right right clipping plane coordinate.
 * \param bottom bottom clipping plane coordinate.
 * \param top top clipping plane coordinate.
 * \param nearval distance to the near clipping plane.
 * \param farval distance to the far clipping plane.
 *
 * \sa glOrtho().
 *
 * Flushes vertices and validates parameters. Calls _math_matrix_ortho() with
 * the top matrix of the current matrix stack and sets
 * __struct gl_contextRec::NewState.
 */
void GLAPIENTRY
_mesa_Ortho( GLdouble left, GLdouble right,
             GLdouble bottom, GLdouble top,
             GLdouble nearval, GLdouble farval )
{
    GET_CURRENT_CONTEXT(ctx);

    FLUSH_VERTICES(ctx, 0);

    if (MESA_VERBOSE & VERBOSE_API)
        _mesa_debug(ctx, "glOrtho(%f, %f, %f, %f, %f, %f)\n",
                    left, right, bottom, top, nearval, farval);

    if (left == right ||
            bottom == top ||
            nearval == farval)
    {
        _mesa_error( ctx,  GL_INVALID_VALUE, "glOrtho" );
        return;
    }

    _math_matrix_ortho( ctx->CurrentStack->Top,
                        (GLfloat) left, (GLfloat) right,
                        (GLfloat) bottom, (GLfloat) top,
                        (GLfloat) nearval, (GLfloat) farval );
    ctx->NewState |= ctx->CurrentStack->DirtyFlag;
}
コード例 #2
0
ファイル: cogl-matrix.c プロジェクト: rib/clutter
void
cogl_matrix_ortho (CoglMatrix *matrix,
                   float left,
                   float right,
                   float bottom,
                   float top,
                   float near_val,
                   float far_val)
{
#ifndef USE_MESA_MATRIX_API
  CoglMatrix ortho;

  /* column 0 */
  ortho.xx = 2.0 / (right - left);
  ortho.yx = 0.0;
  ortho.zx = 0.0;
  ortho.wx = 0.0;

  /* column 1 */
  ortho.xy = 0.0;
  ortho.yy = 2.0 / (top - bottom);
  ortho.zy = 0.0;
  ortho.wy = 0.0;

  /* column 2 */
  ortho.xz = 0.0;
  ortho.yz = 0.0;
  ortho.zz = -2.0 / (far_val - near_val);
  ortho.wz = 0.0;

  /* column 3 */
  ortho.xw = -(right + left) / (right - left);
  ortho.yw = -(top + bottom) / (top - bottom);
  ortho.zw = -(far_val + near_val) / (far_val - near_val);
  ortho.ww = 1.0;

  cogl_matrix_multiply (matrix, matrix, &ortho);
#else
  _math_matrix_ortho (matrix, left, right, bottom, top, near_val, far_val);
#endif
  _COGL_MATRIX_DEBUG_PRINT (matrix);
}