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

m_xform.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  5.1
00004  *
00005  * Copyright (C) 1999-2003  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 /*
00027  * Matrix/vertex/vector transformation stuff
00028  *
00029  *
00030  * NOTES:
00031  * 1. 4x4 transformation matrices are stored in memory in column major order.
00032  * 2. Points/vertices are to be thought of as column vectors.
00033  * 3. Transformation of a point p by a matrix M is: p' = M * p
00034  */
00035 
00036 #include "main/glheader.h"
00037 #include "main/macros.h"
00038 
00039 #include "m_eval.h"
00040 #include "m_matrix.h"
00041 #include "m_translate.h"
00042 #include "m_xform.h"
00043 #include "mathmod.h"
00044 
00045 
00046 #ifdef DEBUG_MATH
00047 #include "m_debug.h"
00048 #endif
00049 
00050 #ifdef USE_X86_ASM
00051 #include "x86/common_x86_asm.h"
00052 #endif
00053 
00054 #ifdef USE_X86_64_ASM
00055 #include "x86-64/x86-64.h"
00056 #endif
00057 
00058 #ifdef USE_SPARC_ASM
00059 #include "sparc/sparc.h"
00060 #endif
00061 
00062 #ifdef USE_PPC_ASM
00063 #include "ppc/common_ppc_features.h"
00064 #endif
00065 
00066 clip_func _mesa_clip_tab[5];
00067 clip_func _mesa_clip_np_tab[5];
00068 dotprod_func _mesa_dotprod_tab[5];
00069 vec_copy_func _mesa_copy_tab[0x10];
00070 normal_func _mesa_normal_tab[0xf];
00071 transform_func *_mesa_transform_tab[5];
00072 
00073 
00074 /* Raw data format used for:
00075  *    - Object-to-eye transform prior to culling, although this too
00076  *      could be culled under some circumstances.
00077  *    - Eye-to-clip transform (via the function above).
00078  *    - Cliptesting
00079  *    - And everything else too, if culling happens to be disabled.
00080  *
00081  * GH: It's used for everything now, as clipping/culling is done
00082  *     elsewhere (most often by the driver itself).
00083  */
00084 #define TAG(x) x
00085 #define TAG2(x,y) x##y
00086 #define STRIDE_LOOP for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) )
00087 #define LOOP for ( i = 0 ; i < n ; i++ )
00088 #define ARGS
00089 #include "m_xform_tmp.h"
00090 #include "m_clip_tmp.h"
00091 #include "m_norm_tmp.h"
00092 #include "m_dotprod_tmp.h"
00093 #include "m_copy_tmp.h"
00094 #undef TAG
00095 #undef TAG2
00096 #undef LOOP
00097 #undef ARGS
00098 
00099 
00100 
00101 
00102 GLvector4f *_mesa_project_points( GLvector4f *proj_vec,
00103                   const GLvector4f *clip_vec )
00104 {
00105    const GLuint stride = clip_vec->stride;
00106    const GLfloat *from = (GLfloat *)clip_vec->start;
00107    const GLuint count = clip_vec->count;
00108    GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start;
00109    GLuint i;
00110 
00111    for (i = 0 ; i < count ; i++, STRIDE_F(from, stride))
00112    {
00113      GLfloat oow = 1.0F / from[3];
00114      vProj[i][3] = oow;
00115      vProj[i][0] = from[0] * oow;
00116      vProj[i][1] = from[1] * oow;
00117      vProj[i][2] = from[2] * oow;
00118    }
00119 
00120    proj_vec->flags |= VEC_SIZE_4;
00121    proj_vec->size = 3;
00122    proj_vec->count = clip_vec->count;
00123    return proj_vec;
00124 }
00125 
00126 
00127 
00128 
00129 
00130 
00131 /*
00132  * Transform a 4-element row vector (1x4 matrix) by a 4x4 matrix.  This
00133  * function is used for transforming clipping plane equations and spotlight
00134  * directions.
00135  * Mathematically,  u = v * m.
00136  * Input:  v - input vector
00137  *         m - transformation matrix
00138  * Output:  u - transformed vector
00139  */
00140 void _mesa_transform_vector( GLfloat u[4], const GLfloat v[4], const GLfloat m[16] )
00141 {
00142    GLfloat v0=v[0], v1=v[1], v2=v[2], v3=v[3];
00143 #define M(row,col)  m[row + col*4]
00144    u[0] = v0 * M(0,0) + v1 * M(1,0) + v2 * M(2,0) + v3 * M(3,0);
00145    u[1] = v0 * M(0,1) + v1 * M(1,1) + v2 * M(2,1) + v3 * M(3,1);
00146    u[2] = v0 * M(0,2) + v1 * M(1,2) + v2 * M(2,2) + v3 * M(3,2);
00147    u[3] = v0 * M(0,3) + v1 * M(1,3) + v2 * M(2,3) + v3 * M(3,3);
00148 #undef M
00149 }
00150 
00151 
00152 /* Useful for one-off point transformations, as in clipping.
00153  * Note that because the matrix isn't analysed we do too many
00154  * multiplies, and that the result is always 4-clean.
00155  */
00156 void _mesa_transform_point_sz( GLfloat Q[4], const GLfloat M[16],
00157                 const GLfloat P[4], GLuint sz )
00158 {
00159    if (Q == P)
00160       return;
00161 
00162    if (sz == 4)
00163    {
00164       Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] *  P[2] + M[12] * P[3];
00165       Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] *  P[2] + M[13] * P[3];
00166       Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3];
00167       Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3];
00168    }
00169    else if (sz == 3)
00170    {
00171       Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] *  P[2] + M[12];
00172       Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] *  P[2] + M[13];
00173       Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14];
00174       Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15];
00175    }
00176    else if (sz == 2)
00177    {
00178       Q[0] = M[0] * P[0] + M[4] * P[1] +                M[12];
00179       Q[1] = M[1] * P[0] + M[5] * P[1] +                M[13];
00180       Q[2] = M[2] * P[0] + M[6] * P[1] +                M[14];
00181       Q[3] = M[3] * P[0] + M[7] * P[1] +                M[15];
00182    }
00183    else if (sz == 1)
00184    {
00185       Q[0] = M[0] * P[0] +                              M[12];
00186       Q[1] = M[1] * P[0] +                              M[13];
00187       Q[2] = M[2] * P[0] +                              M[14];
00188       Q[3] = M[3] * P[0] +                              M[15];
00189    }
00190 }
00191 
00192 
00193 /*
00194  * This is called only once.  It initializes several tables with pointers
00195  * to optimized transformation functions.  This is where we can test for
00196  * AMD 3Dnow! capability, Intel SSE, etc. and hook in the right code.
00197  */
00198 void
00199 _math_init_transformation( void )
00200 {
00201    init_c_transformations();
00202    init_c_norm_transform();
00203    init_c_cliptest();
00204    init_copy0();
00205    init_dotprod();
00206 
00207 #ifdef DEBUG_MATH
00208    _math_test_all_transform_functions( "default" );
00209    _math_test_all_normal_transform_functions( "default" );
00210    _math_test_all_cliptest_functions( "default" );
00211 #endif
00212 
00213 #ifdef USE_X86_ASM
00214    _mesa_init_all_x86_transform_asm();
00215 #elif defined( USE_SPARC_ASM )
00216    _mesa_init_all_sparc_transform_asm();
00217 #elif defined( USE_PPC_ASM )
00218    _mesa_init_all_ppc_transform_asm();
00219 #elif defined( USE_X86_64_ASM )
00220    _mesa_init_all_x86_64_transform_asm();
00221 #endif
00222 }
00223 
00224 void
00225 _math_init( void )
00226 {
00227    _math_init_transformation();
00228    _math_init_translate();
00229    _math_init_eval();
00230 }

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