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

📄 t_vertex_generic.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright 2003 Tungsten Graphics, inc. * 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 * on the rights to use, copy, modify, merge, publish, distribute, sub * license, 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 (including the next * paragraph) 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 NON-INFRINGEMENT.  IN NO EVENT SHALL * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS 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. * * Authors: *    Keith Whitwell <keithw@tungstengraphics.com> */#include "glheader.h"#include "context.h"#include "colormac.h"#include "t_context.h"#include "t_vertex.h"#include "simple_list.h"/* * These functions take the NDC coordinates pointed to by 'in', apply the * NDC->Viewport mapping and store the results at 'v'. */static INLINE void insert_4f_viewport_4( const struct tnl_clipspace_attr *a, GLubyte *v,                      const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[5] * in[1] + vp[13];   out[2] = vp[10] * in[2] + vp[14];   out[3] = in[3];}static INLINE void insert_4f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v,				const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[5] * in[1] + vp[13];   out[2] = vp[10] * in[2] + vp[14];   out[3] = 1;}static INLINE void insert_4f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,				const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[5] * in[1] + vp[13];   out[2] = vp[14];   out[3] = 1;}static INLINE void insert_4f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,				const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[13];   out[2] = vp[14];   out[3] = 1;}static INLINE void insert_3f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v,				const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[5] * in[1] + vp[13];   out[2] = vp[10] * in[2] + vp[14];}static INLINE void insert_3f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,				const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[5] * in[1] + vp[13];   out[2] = vp[10] * in[2] + vp[14];}static INLINE void insert_3f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,				const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[13];   out[2] = vp[14];}static INLINE void insert_2f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,				const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[5] * in[1] + vp[13];}static INLINE void insert_2f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,				const GLfloat *in ){   GLfloat *out = (GLfloat *)v;   const GLfloat * const vp = a->vp;      out[0] = vp[0] * in[0] + vp[12];   out[1] = vp[13];}/* * These functions do the same as above, except for the viewport mapping. */static INLINE void insert_4f_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = in[1];   out[2] = in[2];   out[3] = in[3];}static INLINE void insert_4f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = in[1];   out[2] = in[2];   out[3] = 1;}static INLINE void insert_4f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = in[1];   out[2] = 0;   out[3] = 1;}static INLINE void insert_4f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = 0;   out[2] = 0;   out[3] = 1;}static INLINE void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = in[1];   out[2] = in[3];}static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   (void) a; (void) v; (void) in;   _mesa_exit(1);}static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = in[1];   out[2] = in[2];}static INLINE void insert_3f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = in[1];   out[2] = 0;}static INLINE void insert_3f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = 0;   out[2] = 0;}static INLINE void insert_2f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = in[1];}static INLINE void insert_2f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;      out[0] = in[0];   out[1] = 0;}static INLINE void insert_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   GLfloat *out = (GLfloat *)(v);   (void) a;   out[0] = in[0];}static INLINE void insert_null( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in ){   (void) a; (void) v; (void) in;}static INLINE void insert_4chan_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v, 				  const GLfloat *in ){   GLchan *c = (GLchan *)v;   (void) a;   UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);    UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);    UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]);    UNCLAMPED_FLOAT_TO_CHAN(c[3], in[3]);}static INLINE void insert_4chan_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v, 				  const GLfloat *in ){   GLchan *c = (GLchan *)v;   (void) a;   UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);    UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);    UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]);    c[3] = CHAN_MAX;}static INLINE void insert_4chan_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v, 				  const GLfloat *in ){   GLchan *c = (GLchan *)v;   (void) a;   UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);    UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);    c[2] = 0;   c[3] = CHAN_MAX;}static INLINE void insert_4chan_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v, 				  const GLfloat *in ){   GLchan *c = (GLchan *)v;   (void) a;   UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);    c[1] = 0;   c[2] = 0;   c[3] = CHAN_MAX;}static INLINE void insert_4ub_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);}static INLINE void insert_4ub_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);   v[3] = 0xff;}static INLINE void insert_4ub_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   v[2] = 0;   v[3] = 0xff;}static INLINE void insert_4ub_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);   v[1] = 0;   v[2] = 0;   v[3] = 0xff;}static INLINE void insert_4ub_4f_bgra_4( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);}static INLINE void insert_4ub_4f_bgra_3( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);   v[3] = 0xff;}static INLINE void insert_4ub_4f_bgra_2( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   v[0] = 0;   v[3] = 0xff;}static INLINE void insert_4ub_4f_bgra_1( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);   v[1] = 0;   v[0] = 0;   v[3] = 0xff;}static INLINE void insert_4ub_4f_argb_4( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);}static INLINE void insert_4ub_4f_argb_3( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);   v[0] = 0xff;}static INLINE void insert_4ub_4f_argb_2( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);   v[3] = 0x00;   v[0] = 0xff;}static INLINE void insert_4ub_4f_argb_1( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);   v[2] = 0x00;   v[3] = 0x00;   v[0] = 0xff;}static INLINE void insert_4ub_4f_abgr_4( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);}static INLINE void insert_4ub_4f_abgr_3( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);   v[0] = 0xff;}static INLINE void insert_4ub_4f_abgr_2( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);   v[1] = 0x00;   v[0] = 0xff;}static INLINE void insert_4ub_4f_abgr_1( const struct tnl_clipspace_attr *a, GLubyte *v, 				const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);   v[2] = 0x00;   v[1] = 0x00;   v[0] = 0xff;}static INLINE void insert_3ub_3f_rgb_3( const struct tnl_clipspace_attr *a, GLubyte *v, 			       const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);}static INLINE void insert_3ub_3f_rgb_2( const struct tnl_clipspace_attr *a, GLubyte *v, 			       const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   v[2] = 0;}static INLINE void insert_3ub_3f_rgb_1( const struct tnl_clipspace_attr *a, GLubyte *v, 			       const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);   v[1] = 0;   v[2] = 0;}static INLINE void insert_3ub_3f_bgr_3( const struct tnl_clipspace_attr *a, GLubyte *v, 				 const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);}static INLINE void insert_3ub_3f_bgr_2( const struct tnl_clipspace_attr *a, GLubyte *v, 				 const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);   UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);   v[0] = 0;}static INLINE void insert_3ub_3f_bgr_1( const struct tnl_clipspace_attr *a, GLubyte *v, 				 const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);   v[1] = 0;   v[0] = 0;}static INLINE void insert_1ub_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, 			   const GLfloat *in ){   (void) a;   UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);}/*********************************************************************** * Functions to perform the reverse operations to the above, for * swrast translation and clip-interpolation. *  * Currently always extracts a full 4 floats. */static void extract_4f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out, 				 const GLubyte *v ){   const GLfloat *in = (const GLfloat *)v;   const GLfloat * const vp = a->vp;      /* Although included for completeness, the position coordinate is    * usually handled differently during clipping.    */   out[0] = (in[0] - vp[12]) / vp[0];   out[1] = (in[1] - vp[13]) / vp[5];   out[2] = (in[2] - vp[14]) / vp[10];   out[3] = in[3];}static void extract_3f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out, 

⌨️ 快捷键说明

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