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

t_vb_cull.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  6.5
00004  *
00005  * Copyright (C) 1999-2006  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  * Authors:
00025  *    Keith Whitwell <keith@tungstengraphics.com>
00026  */
00027 
00028 
00029 #include "main/glheader.h"
00030 #include "main/colormac.h"
00031 #include "main/context.h"
00032 #include "main/macros.h"
00033 #include "main/imports.h"
00034 #include "main/mtypes.h"
00035 
00036 #include "math/m_xform.h"
00037 
00038 #include "t_context.h"
00039 #include "t_pipeline.h"
00040 
00041 
00042 
00043 /* EXT_vertex_cull.  Not really a big win, but probably depends on
00044  * your application.  This stage not included in the default pipeline.
00045  */
00046 static GLboolean run_cull_stage( GLcontext *ctx,
00047                  struct tnl_pipeline_stage *stage )
00048 {
00049    TNLcontext *tnl = TNL_CONTEXT(ctx);
00050    struct vertex_buffer *VB = &tnl->vb;
00051 
00052    const GLfloat a = ctx->Transform.CullObjPos[0];
00053    const GLfloat b = ctx->Transform.CullObjPos[1];
00054    const GLfloat c = ctx->Transform.CullObjPos[2];
00055    GLfloat *norm = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
00056    GLuint stride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
00057    GLuint count = VB->Count;
00058    GLuint i;
00059 
00060    if (ctx->VertexProgram._Current ||
00061        !ctx->Transform.CullVertexFlag) 
00062       return GL_TRUE;
00063 
00064    VB->ClipOrMask &= ~CLIP_CULL_BIT;
00065    VB->ClipAndMask |= CLIP_CULL_BIT;
00066 
00067    for (i = 0 ; i < count ; i++) {
00068       GLfloat dp = (norm[0] * a + 
00069             norm[1] * b +
00070             norm[2] * c);
00071 
00072       if (dp < 0) {
00073      VB->ClipMask[i] |= CLIP_CULL_BIT;
00074      VB->ClipOrMask |= CLIP_CULL_BIT;
00075       }
00076       else {
00077      VB->ClipMask[i] &= ~CLIP_CULL_BIT;
00078      VB->ClipAndMask &= ~CLIP_CULL_BIT;
00079       }
00080 
00081       STRIDE_F(norm, stride);
00082    }
00083 
00084    return !(VB->ClipAndMask & CLIP_CULL_BIT);
00085 }
00086 
00087 
00088 
00089 const struct tnl_pipeline_stage _tnl_vertex_cull_stage =
00090 {
00091    "EXT_cull_vertex",
00092    NULL,            /* private data */
00093    NULL,                /* ctr */
00094    NULL,                /* destructor */
00095    NULL,
00096    run_cull_stage       /* run -- initially set to init */
00097 };

Generated on Sun May 27 2012 04:20:45 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.