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

vbo_exec_eval.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  6.1
00004  *
00005  * Copyright (C) 1999-2004  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 #include "main/glheader.h"
00029 #include "main/context.h"
00030 #include "main/macros.h"
00031 #include "math/m_eval.h"
00032 #include "glapi/dispatch.h"
00033 #include "vbo_exec.h"
00034 
00035 
00036 static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) 
00037 {
00038    exec->eval.map1[attr].map = NULL;
00039 }
00040 
00041 static void clear_active_eval2( struct vbo_exec_context *exec, GLuint attr ) 
00042 {
00043    exec->eval.map2[attr].map = NULL;
00044 }
00045 
00046 static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint dim, 
00047                   struct gl_1d_map *map )
00048 {
00049    if (!exec->eval.map1[attr].map) {
00050       exec->eval.map1[attr].map = map;
00051       exec->eval.map1[attr].sz = dim;
00052    }
00053 } 
00054 
00055 static void set_active_eval2( struct vbo_exec_context *exec, GLuint attr, GLuint dim, 
00056                   struct gl_2d_map *map )
00057 {
00058    if (!exec->eval.map2[attr].map) {
00059       exec->eval.map2[attr].map = map;
00060       exec->eval.map2[attr].sz = dim;
00061    }
00062 } 
00063 
00064 void vbo_exec_eval_update( struct vbo_exec_context *exec )
00065 {
00066    GLcontext *ctx = exec->ctx;
00067    GLuint attr;
00068 
00069    /* Vertex program maps have priority over conventional attribs */
00070 
00071    for (attr = 0; attr < VBO_ATTRIB_FIRST_MATERIAL; attr++) {
00072       clear_active_eval1( exec, attr );
00073       clear_active_eval2( exec, attr );
00074    }
00075 
00076    /* _NEW_PROGRAM */
00077    if (ctx->VertexProgram._Enabled) {
00078       for (attr = 0; attr < VBO_ATTRIB_FIRST_MATERIAL; attr++) {
00079      /* _NEW_EVAL */
00080      if (ctx->Eval.Map1Attrib[attr]) 
00081         set_active_eval1( exec, attr, 4, &ctx->EvalMap.Map1Attrib[attr] );
00082 
00083      if (ctx->Eval.Map2Attrib[attr]) 
00084         set_active_eval2( exec, attr, 4, &ctx->EvalMap.Map2Attrib[attr] );
00085       }
00086    }
00087 
00088    if (ctx->Eval.Map1Color4) 
00089       set_active_eval1( exec, VBO_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map1Color4 );
00090       
00091    if (ctx->Eval.Map2Color4) 
00092       set_active_eval2( exec, VBO_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map2Color4 );
00093 
00094    if (ctx->Eval.Map1TextureCoord4) 
00095       set_active_eval1( exec, VBO_ATTRIB_TEX0, 4, &ctx->EvalMap.Map1Texture4 );
00096    else if (ctx->Eval.Map1TextureCoord3) 
00097       set_active_eval1( exec, VBO_ATTRIB_TEX0, 3, &ctx->EvalMap.Map1Texture3 );
00098    else if (ctx->Eval.Map1TextureCoord2) 
00099       set_active_eval1( exec, VBO_ATTRIB_TEX0, 2, &ctx->EvalMap.Map1Texture2 );
00100    else if (ctx->Eval.Map1TextureCoord1) 
00101       set_active_eval1( exec, VBO_ATTRIB_TEX0, 1, &ctx->EvalMap.Map1Texture1 );
00102 
00103    if (ctx->Eval.Map2TextureCoord4) 
00104       set_active_eval2( exec, VBO_ATTRIB_TEX0, 4, &ctx->EvalMap.Map2Texture4 );
00105    else if (ctx->Eval.Map2TextureCoord3) 
00106       set_active_eval2( exec, VBO_ATTRIB_TEX0, 3, &ctx->EvalMap.Map2Texture3 );
00107    else if (ctx->Eval.Map2TextureCoord2) 
00108       set_active_eval2( exec, VBO_ATTRIB_TEX0, 2, &ctx->EvalMap.Map2Texture2 );
00109    else if (ctx->Eval.Map2TextureCoord1) 
00110       set_active_eval2( exec, VBO_ATTRIB_TEX0, 1, &ctx->EvalMap.Map2Texture1 );
00111 
00112    if (ctx->Eval.Map1Normal) 
00113       set_active_eval1( exec, VBO_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map1Normal );
00114 
00115    if (ctx->Eval.Map2Normal) 
00116       set_active_eval2( exec, VBO_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map2Normal );
00117 
00118    if (ctx->Eval.Map1Vertex4) 
00119       set_active_eval1( exec, VBO_ATTRIB_POS, 4, &ctx->EvalMap.Map1Vertex4 );
00120    else if (ctx->Eval.Map1Vertex3) 
00121       set_active_eval1( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map1Vertex3 );
00122 
00123    if (ctx->Eval.Map2Vertex4) 
00124       set_active_eval2( exec, VBO_ATTRIB_POS, 4, &ctx->EvalMap.Map2Vertex4 );
00125    else if (ctx->Eval.Map2Vertex3) 
00126       set_active_eval2( exec, VBO_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 );
00127 
00128    exec->eval.recalculate_maps = 0;
00129 }
00130 
00131 
00132 
00133 void vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u)
00134 {
00135    GLuint attr;
00136 
00137    for (attr = 1; attr <= VBO_ATTRIB_TEX7; attr++) {
00138       struct gl_1d_map *map = exec->eval.map1[attr].map;
00139       if (map) {
00140      GLfloat uu = (u - map->u1) * map->du;
00141      GLfloat data[4];
00142 
00143      ASSIGN_4V(data, 0, 0, 0, 1);
00144 
00145      _math_horner_bezier_curve(map->Points, data, uu, 
00146                    exec->eval.map1[attr].sz, 
00147                    map->Order);
00148 
00149      COPY_SZ_4V( exec->vtx.attrptr[attr],
00150              exec->vtx.attrsz[attr],
00151              data );
00152       }
00153    }
00154 
00157    if (exec->eval.map1[0].map) {
00158       struct gl_1d_map *map = exec->eval.map1[0].map;
00159       GLfloat uu = (u - map->u1) * map->du;
00160       GLfloat vertex[4];
00161 
00162       ASSIGN_4V(vertex, 0, 0, 0, 1);
00163 
00164       _math_horner_bezier_curve(map->Points, vertex, uu, 
00165                 exec->eval.map1[0].sz, 
00166                 map->Order);
00167 
00168       if (exec->eval.map1[0].sz == 4) 
00169      CALL_Vertex4fv(GET_DISPATCH(), ( vertex ));
00170       else
00171      CALL_Vertex3fv(GET_DISPATCH(), ( vertex )); 
00172    }
00173 }
00174 
00175 
00176 
00177 void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, 
00178                   GLfloat u, GLfloat v )
00179 {   
00180    GLuint attr;
00181 
00182    for (attr = 1; attr <= VBO_ATTRIB_TEX7; attr++) {
00183       struct gl_2d_map *map = exec->eval.map2[attr].map;
00184       if (map) {
00185      GLfloat uu = (u - map->u1) * map->du;
00186      GLfloat vv = (v - map->v1) * map->dv;
00187      GLfloat data[4];
00188 
00189      ASSIGN_4V(data, 0, 0, 0, 1);
00190 
00191      _math_horner_bezier_surf(map->Points, 
00192                   data, 
00193                   uu, vv, 
00194                   exec->eval.map2[attr].sz, 
00195                   map->Uorder, map->Vorder);
00196 
00197      COPY_SZ_4V( exec->vtx.attrptr[attr],
00198              exec->vtx.attrsz[attr],
00199              data );
00200       }
00201    }
00202 
00205    if (exec->eval.map2[0].map) {
00206       struct gl_2d_map *map = exec->eval.map2[0].map;
00207       GLfloat uu = (u - map->u1) * map->du;
00208       GLfloat vv = (v - map->v1) * map->dv;
00209       GLfloat vertex[4];
00210 
00211       ASSIGN_4V(vertex, 0, 0, 0, 1);
00212 
00213       if (exec->ctx->Eval.AutoNormal) {
00214      GLfloat normal[4];
00215          GLfloat du[4], dv[4];
00216 
00217          _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv, 
00218                  exec->eval.map2[0].sz,
00219                  map->Uorder, map->Vorder);
00220 
00221      if (exec->eval.map2[0].sz == 4) {
00222         du[0] = du[0]*vertex[3] - du[3]*vertex[0];
00223         du[1] = du[1]*vertex[3] - du[3]*vertex[1];
00224         du[2] = du[2]*vertex[3] - du[3]*vertex[2];
00225      
00226         dv[0] = dv[0]*vertex[3] - dv[3]*vertex[0];
00227         dv[1] = dv[1]*vertex[3] - dv[3]*vertex[1];
00228         dv[2] = dv[2]*vertex[3] - dv[3]*vertex[2];
00229      }
00230 
00231 
00232          CROSS3(normal, du, dv);
00233          NORMALIZE_3FV(normal);
00234      normal[3] = 1.0;
00235 
00236      COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL],
00237              exec->vtx.attrsz[VBO_ATTRIB_NORMAL],
00238              normal );
00239 
00240       }
00241       else {
00242          _math_horner_bezier_surf(map->Points, vertex, uu, vv, 
00243                   exec->eval.map2[0].sz,
00244                   map->Uorder, map->Vorder);
00245       }
00246 
00247       if (exec->vtx.attrsz[0] == 4) 
00248      CALL_Vertex4fv(GET_DISPATCH(), ( vertex ));
00249       else
00250      CALL_Vertex3fv(GET_DISPATCH(), ( vertex )); 
00251    }
00252 }
00253 
00254 

Generated on Sat May 26 2012 04:19:38 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.