ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

clip.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  6.3
00004  *
00005  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this software and associated documentation files (the "Software"),
00009  * to deal in the Software without restriction, including without limitation
00010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011  * and/or sell copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included
00015  * in all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00025 
00026 #include "glheader.h"
00027 #include "clip.h"
00028 #include "context.h"
00029 #include "macros.h"
00030 #include "mtypes.h"
00031 
00032 #include "math/m_xform.h"
00033 #include "math/m_matrix.h"
00034 
00035 
00036 
00037 /**********************************************************************/
00038 /*                     Get/Set User clip-planes.                      */
00039 /**********************************************************************/
00040 
00041 
00042 
00043 void GLAPIENTRY
00044 _mesa_ClipPlane( GLenum plane, const GLdouble *eq )
00045 {
00046    GET_CURRENT_CONTEXT(ctx);
00047    GLint p;
00048    GLfloat equation[4];
00049    ASSERT_OUTSIDE_BEGIN_END(ctx);
00050 
00051    p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
00052    if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) {
00053       _mesa_error( ctx, GL_INVALID_ENUM, "glClipPlane" );
00054       return;
00055    }
00056 
00057    equation[0] = (GLfloat) eq[0];
00058    equation[1] = (GLfloat) eq[1];
00059    equation[2] = (GLfloat) eq[2];
00060    equation[3] = (GLfloat) eq[3];
00061 
00062    /*
00063     * The equation is transformed by the transpose of the inverse of the
00064     * current modelview matrix and stored in the resulting eye coordinates.
00065     *
00066     * KW: Eqn is then transformed to the current clip space, where user
00067     * clipping now takes place.  The clip-space equations are recalculated
00068     * whenever the projection matrix changes.
00069     */
00070    if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top))
00071       _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
00072 
00073    _mesa_transform_vector( equation, equation,
00074                            ctx->ModelviewMatrixStack.Top->inv );
00075 
00076    if (TEST_EQ_4V(ctx->Transform.EyeUserPlane[p], equation))
00077       return;
00078 
00079    FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
00080    COPY_4FV(ctx->Transform.EyeUserPlane[p], equation);
00081 
00082    /* Update derived state.  This state also depends on the projection
00083     * matrix, and is recalculated on changes to the projection matrix by
00084     * code in _mesa_update_state().
00085     */
00086    if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
00087       if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
00088          _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
00089 
00090       _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
00091                ctx->Transform.EyeUserPlane[p],
00092                ctx->ProjectionMatrixStack.Top->inv );
00093    }
00094 
00095    if (ctx->Driver.ClipPlane)
00096       ctx->Driver.ClipPlane( ctx, plane, equation );
00097 }
00098 
00099 
00100 void GLAPIENTRY
00101 _mesa_GetClipPlane( GLenum plane, GLdouble *equation )
00102 {
00103    GET_CURRENT_CONTEXT(ctx);
00104    GLint p;
00105    ASSERT_OUTSIDE_BEGIN_END(ctx);
00106 
00107    p = (GLint) (plane - GL_CLIP_PLANE0);
00108    if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) {
00109       _mesa_error( ctx, GL_INVALID_ENUM, "glGetClipPlane" );
00110       return;
00111    }
00112 
00113    equation[0] = (GLdouble) ctx->Transform.EyeUserPlane[p][0];
00114    equation[1] = (GLdouble) ctx->Transform.EyeUserPlane[p][1];
00115    equation[2] = (GLdouble) ctx->Transform.EyeUserPlane[p][2];
00116    equation[3] = (GLdouble) ctx->Transform.EyeUserPlane[p][3];
00117 }
00118 
00119 void GLAPIENTRY 
00120 _mesa_CullParameterfvEXT (GLenum cap, GLfloat *v)
00121 {
00122    GET_CURRENT_CONTEXT(ctx);
00123    ASSERT_OUTSIDE_BEGIN_END(ctx);
00124 
00125    switch (cap) {
00126    case GL_CULL_VERTEX_EYE_POSITION_EXT:
00127       FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
00128       COPY_4FV(ctx->Transform.CullEyePos, v);
00129       
00130       _mesa_transform_vector( ctx->Transform.CullObjPos, 
00131                   ctx->Transform.CullEyePos,
00132                   ctx->ModelviewMatrixStack.Top->inv );
00133       break;
00134 
00135    case GL_CULL_VERTEX_OBJECT_POSITION_EXT:
00136       FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
00137       COPY_4FV(ctx->Transform.CullObjPos, v);
00138 
00139       _mesa_transform_vector( ctx->Transform.CullEyePos, 
00140                   ctx->Transform.CullObjPos,
00141                   ctx->ModelviewMatrixStack.Top->m );
00142      break;
00143    default:
00144       _mesa_error( ctx, GL_INVALID_ENUM, "glCullParameterfvEXT" );
00145    }
00146 }
00147 
00148 void GLAPIENTRY 
00149 _mesa_CullParameterdvEXT (GLenum cap, GLdouble *v)
00150 {
00151    GLfloat f[4];
00152    
00153    f[0] = (GLfloat)v[0];
00154    f[1] = (GLfloat)v[1];
00155    f[2] = (GLfloat)v[2];
00156    f[3] = (GLfloat)v[3];
00157 
00158    _mesa_CullParameterfvEXT(cap, f);
00159 }
00160 

Generated on Sun May 27 2012 04:20:10 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.