17117f1b4Smrg 27117f1b4Smrg/* 37117f1b4Smrg * Mesa 3-D graphics library 47117f1b4Smrg * 57117f1b4Smrg * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. 67117f1b4Smrg * 77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 87117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 97117f1b4Smrg * to deal in the Software without restriction, including without limitation 107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 127117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 137117f1b4Smrg * 147117f1b4Smrg * The above copyright notice and this permission notice shall be included 157117f1b4Smrg * in all copies or substantial portions of the Software. 167117f1b4Smrg * 177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 247117f1b4Smrg */ 257117f1b4Smrg 267117f1b4Smrg/* 277117f1b4Smrg * New (3.1) transformation code written by Keith Whitwell. 287117f1b4Smrg */ 297117f1b4Smrg 307117f1b4Smrg 317117f1b4Smrg/* Note - respects the stride of the output vector. 327117f1b4Smrg */ 337117f1b4Smrgstatic void TAG(dotprod_vec2)( GLfloat *out, 347117f1b4Smrg GLuint outstride, 357117f1b4Smrg const GLvector4f *coord_vec, 367117f1b4Smrg const GLfloat plane[4] ) 377117f1b4Smrg{ 387117f1b4Smrg GLuint stride = coord_vec->stride; 397117f1b4Smrg GLfloat *coord = coord_vec->start; 407117f1b4Smrg GLuint count = coord_vec->count; 417117f1b4Smrg 427117f1b4Smrg GLuint i; 437117f1b4Smrg 447117f1b4Smrg const GLfloat plane0 = plane[0], plane1 = plane[1], plane3 = plane[3]; 457117f1b4Smrg 467117f1b4Smrg for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) { 477117f1b4Smrg *out = (coord[0] * plane0 + 487117f1b4Smrg coord[1] * plane1 + 497117f1b4Smrg plane3); 507117f1b4Smrg } 517117f1b4Smrg} 527117f1b4Smrg 537117f1b4Smrgstatic void TAG(dotprod_vec3)( GLfloat *out, 547117f1b4Smrg GLuint outstride, 557117f1b4Smrg const GLvector4f *coord_vec, 567117f1b4Smrg const GLfloat plane[4] ) 577117f1b4Smrg{ 587117f1b4Smrg GLuint stride = coord_vec->stride; 597117f1b4Smrg GLfloat *coord = coord_vec->start; 607117f1b4Smrg GLuint count = coord_vec->count; 617117f1b4Smrg 627117f1b4Smrg GLuint i; 637117f1b4Smrg 647117f1b4Smrg const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2]; 657117f1b4Smrg const GLfloat plane3 = plane[3]; 667117f1b4Smrg 677117f1b4Smrg for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) { 687117f1b4Smrg *out = (coord[0] * plane0 + 697117f1b4Smrg coord[1] * plane1 + 707117f1b4Smrg coord[2] * plane2 + 717117f1b4Smrg plane3); 727117f1b4Smrg } 737117f1b4Smrg} 747117f1b4Smrg 757117f1b4Smrgstatic void TAG(dotprod_vec4)( GLfloat *out, 767117f1b4Smrg GLuint outstride, 777117f1b4Smrg const GLvector4f *coord_vec, 787117f1b4Smrg const GLfloat plane[4] ) 797117f1b4Smrg{ 807117f1b4Smrg GLuint stride = coord_vec->stride; 817117f1b4Smrg GLfloat *coord = coord_vec->start; 827117f1b4Smrg GLuint count = coord_vec->count; 837117f1b4Smrg GLuint i; 847117f1b4Smrg 857117f1b4Smrg const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2]; 867117f1b4Smrg const GLfloat plane3 = plane[3]; 877117f1b4Smrg 887117f1b4Smrg for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) { 897117f1b4Smrg *out = (coord[0] * plane0 + 907117f1b4Smrg coord[1] * plane1 + 917117f1b4Smrg coord[2] * plane2 + 927117f1b4Smrg coord[3] * plane3); 937117f1b4Smrg } 947117f1b4Smrg} 957117f1b4Smrg 967117f1b4Smrg 977117f1b4Smrgstatic void TAG(init_dotprod)( void ) 987117f1b4Smrg{ 997117f1b4Smrg _mesa_dotprod_tab[2] = TAG(dotprod_vec2); 1007117f1b4Smrg _mesa_dotprod_tab[3] = TAG(dotprod_vec3); 1017117f1b4Smrg _mesa_dotprod_tab[4] = TAG(dotprod_vec4); 1027117f1b4Smrg} 103