⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m_xform_tmp.h

📁 winNT技术操作系统,国外开放的原代码和LIUX一样
💻 H
📖 第 1 页 / 共 2 页
字号:

/*
 * Mesa 3-D graphics library
 * Version:  3.5
 *
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/*
 * New (3.1) transformation code written by Keith Whitwell.
 */


/*----------------------------------------------------------------------
 * Begin Keith's new code
 *
 *----------------------------------------------------------------------
 */

/* KW: Fixed stride, now measured in bytes as is the OpenGL array stride.
 */

/* KW: These are now parameterized to produce two versions, one
 *     which transforms all incoming points, and a second which
 *     takes notice of a cullmask array, and only transforms
 *     unculled vertices.
 */

/* KW: 1-vectors can sneak into the texture pipeline via the array
 *     interface.  These functions are here because I want consistant
 *     treatment of the vertex sizes and a lazy strategy for
 *     cleaning unused parts of the vector, and so as not to exclude
 *     them from the vertex array interface.
 *
 *     Under our current analysis of matrices, there is no way that
 *     the product of a matrix and a 1-vector can remain a 1-vector,
 *     with the exception of the identity transform.
 */

/* KW: No longer zero-pad outgoing vectors.  Now that external
 *     vectors can get into the pipeline we cannot ever assume
 *     that there is more to a vector than indicated by its
 *     size.
 */

/* KW: Now uses clipmask and a flag to allow us to skip both/either
 *     cliped and/or culled vertices.
 */

/* GH: Not any more -- it's easier (and faster) to just process the
 *     entire vector.  Clipping and culling are handled further down
 *     the pipe, most often during or after the conversion to some
 *     driver-specific vertex format.
 */

static void _XFORMAPI
TAG(transform_points1_general)( GLvector4f *to_vec,
				const GLfloat m[16],
				const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0],  m12 = m[12];
   const GLfloat m1 = m[1],  m13 = m[13];
   const GLfloat m2 = m[2],  m14 = m[14];
   const GLfloat m3 = m[3],  m15 = m[15];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0];
      to[i][0] = m0 * ox + m12;
      to[i][1] = m1 * ox + m13;
      to[i][2] = m2 * ox + m14;
      to[i][3] = m3 * ox + m15;
   }
   to_vec->size = 4;
   to_vec->flags |= VEC_SIZE_4;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points1_identity)( GLvector4f *to_vec,
				 const GLfloat m[16],
				 const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLuint count = from_vec->count;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint i;
   (void) m;
   if (to_vec == from_vec) return;
   STRIDE_LOOP {
      to[i][0] = from[0];
   }
   to_vec->size = 1;
   to_vec->flags |= VEC_SIZE_1;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points1_2d)( GLvector4f *to_vec,
			   const GLfloat m[16],
			   const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m1 = m[1];
   const GLfloat m12 = m[12], m13 = m[13];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0];
      to[i][0] = m0 * ox + m12;
      to[i][1] = m1 * ox + m13;
   }
   to_vec->size = 2;
   to_vec->flags |= VEC_SIZE_2;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
				  const GLfloat m[16],
				  const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m12 = m[12], m13 = m[13];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0];
      to[i][0] = m0 * ox + m12;
      to[i][1] =           m13;
   }
   to_vec->size = 2;
   to_vec->flags |= VEC_SIZE_2;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points1_3d)( GLvector4f *to_vec,
			   const GLfloat m[16],
			   const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m1 = m[1], m2 = m[2];
   const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0];
      to[i][0] = m0 * ox + m12;
      to[i][1] = m1 * ox + m13;
      to[i][2] = m2 * ox + m14;
   }
   to_vec->size = 3;
   to_vec->flags |= VEC_SIZE_3;
   to_vec->count = from_vec->count;
}


static void _XFORMAPI
TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
				  const GLfloat m[16],
				  const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0];
   const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0];
      to[i][0] = m0 * ox           + m12;
      to[i][1] =                     m13;
      to[i][2] =                     m14;
   }
   to_vec->size = 3;
   to_vec->flags |= VEC_SIZE_3;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points1_perspective)( GLvector4f *to_vec,
				    const GLfloat m[16],
				    const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m14 = m[14];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0];
      to[i][0] = m0 * ox                ;
      to[i][1] =           0            ;
      to[i][2] =                     m14;
      to[i][3] = 0;
   }
   to_vec->size = 4;
   to_vec->flags |= VEC_SIZE_4;
   to_vec->count = from_vec->count;
}




/* 2-vectors, which are a lot more relevant than 1-vectors, are
 * present early in the geometry pipeline and throughout the
 * texture pipeline.
 */
static void _XFORMAPI
TAG(transform_points2_general)( GLvector4f *to_vec,
				const GLfloat m[16],
				const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0],  m4 = m[4],  m12 = m[12];
   const GLfloat m1 = m[1],  m5 = m[5],  m13 = m[13];
   const GLfloat m2 = m[2],  m6 = m[6],  m14 = m[14];
   const GLfloat m3 = m[3],  m7 = m[7],  m15 = m[15];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0], oy = from[1];
      to[i][0] = m0 * ox + m4 * oy + m12;
      to[i][1] = m1 * ox + m5 * oy + m13;
      to[i][2] = m2 * ox + m6 * oy + m14;
      to[i][3] = m3 * ox + m7 * oy + m15;
   }
   to_vec->size = 4;
   to_vec->flags |= VEC_SIZE_4;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points2_identity)( GLvector4f *to_vec,
				 const GLfloat m[16],
				 const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   GLuint i;
   (void) m;
   if (to_vec == from_vec) return;
   STRIDE_LOOP {
      to[i][0] = from[0];
      to[i][1] = from[1];
   }
   to_vec->size = 2;
   to_vec->flags |= VEC_SIZE_2;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points2_2d)( GLvector4f *to_vec,
			   const GLfloat m[16],
			   const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
   const GLfloat m12 = m[12], m13 = m[13];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0], oy = from[1];
      to[i][0] = m0 * ox + m4 * oy + m12;
      to[i][1] = m1 * ox + m5 * oy + m13;
   }
   to_vec->size = 2;
   to_vec->flags |= VEC_SIZE_2;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
				  const GLfloat m[16],
				  const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0], oy = from[1];
      to[i][0] = m0 * ox           + m12;
      to[i][1] =           m5 * oy + m13;
   }
   to_vec->size = 2;
   to_vec->flags |= VEC_SIZE_2;
   to_vec->count = from_vec->count;
}

static void _XFORMAPI
TAG(transform_points2_3d)( GLvector4f *to_vec,
			   const GLfloat m[16],
			   const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
   const GLfloat m6 = m[6], m12 = m[12], m13 = m[13], m14 = m[14];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0], oy = from[1];
      to[i][0] = m0 * ox + m4 * oy + m12;
      to[i][1] = m1 * ox + m5 * oy + m13;
      to[i][2] = m2 * ox + m6 * oy + m14;
   }
   to_vec->size = 3;
   to_vec->flags |= VEC_SIZE_3;
   to_vec->count = from_vec->count;
}


/* I would actually say this was a fairly important function, from
 * a texture transformation point of view.
 */
static void _XFORMAPI
TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
				  const GLfloat m[16],
				  const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m5 = m[5];
   const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0], oy = from[1];
      to[i][0] = m0 * ox           + m12;
      to[i][1] =           m5 * oy + m13;
      to[i][2] =                     m14;
   }
   if (m14 == 0) {
      to_vec->size = 2;
      to_vec->flags |= VEC_SIZE_2;
   } else {
      to_vec->size = 3;
      to_vec->flags |= VEC_SIZE_3;
   }
   to_vec->count = from_vec->count;
}


static void _XFORMAPI
TAG(transform_points2_perspective)( GLvector4f *to_vec,
				    const GLfloat m[16],
				    const GLvector4f *from_vec )
{
   const GLuint stride = from_vec->stride;
   GLfloat *from = from_vec->start;
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
   GLuint count = from_vec->count;
   const GLfloat m0 = m[0], m5 = m[5], m14 = m[14];
   GLuint i;
   STRIDE_LOOP {
      const GLfloat ox = from[0], oy = from[1];
      to[i][0] = m0 * ox                ;
      to[i][1] =           m5 * oy      ;
      to[i][2] =                     m14;
      to[i][3] = 0;
   }
   to_vec->size = 4;
   to_vec->flags |= VEC_SIZE_4;
   to_vec->count = from_vec->count;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -