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

📄 t_dd_dmatmp2.h

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 H
📖 第 1 页 / 共 2 页
字号:
static void TAG(render_quads_verts)( GLcontext *ctx,				     GLuint start,				     GLuint count,				     GLuint flags ){   LOCAL_VARS;   if (0) fprintf(stderr, "%s\n", __FUNCTION__);   count -= (count-start)%4;   if (start+3 >= count)       return;   if (HAVE_QUADS) {      EMIT_PRIM( ctx, GL_QUADS, HW_QUADS, start, count );   }    else {      /* Hardware doesn't have a quad primitive type -- simulate it       * using indexed vertices and the triangle primitive:        */      LOCAL_VARS;      int dmasz = GET_MAX_HW_ELTS();      GLuint j, nr;      ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );      /* Adjust for rendering as triangles:       */      dmasz = (dmasz/6)*4;      for (j = start; j < count; j += nr ) {	 ELT_TYPE *dest;	 GLint quads, i;	 nr = MIN2( dmasz, count - j );	 quads = nr/4;	 dest = ALLOC_ELTS( quads*6 );	 for ( i = j ; i < j+quads*4 ; i+=4 ) {	    EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) );	    EMIT_TWO_ELTS( dest, 2, (i+3), (i+1) );	    EMIT_TWO_ELTS( dest, 4, (i+2), (i+3) );	    dest += 6;	 }	 CLOSE_ELTS();      }   }}static void TAG(render_noop)( GLcontext *ctx,			      GLuint start,			      GLuint count,			      GLuint flags ){}static tnl_render_func TAG(render_tab_verts)[GL_POLYGON+2] ={   TAG(render_points_verts),   TAG(render_lines_verts),   TAG(render_line_loop_verts),   TAG(render_line_strip_verts),   TAG(render_triangles_verts),   TAG(render_tri_strip_verts),   TAG(render_tri_fan_verts),   TAG(render_quads_verts),   TAG(render_quad_strip_verts),   TAG(render_poly_verts),   TAG(render_noop),};/**************************************************************************** *                 Render elts using hardware indexed verts                 * ****************************************************************************/static void TAG(render_points_elts)( GLcontext *ctx,				     GLuint start,				     GLuint count,				     GLuint flags ){   LOCAL_VARS;   int dmasz = GET_MAX_HW_ELTS();   GLuint *elts = GET_MESA_ELTS();   GLuint j, nr;   ELT_TYPE *dest;   ELT_INIT( GL_POINTS, HW_POINTS );   for (j = start; j < count; j += nr ) {      nr = MIN2( dmasz, count - j );      dest = ALLOC_ELTS( nr );      dest = TAG(emit_elts)( ctx, dest, elts+j, nr );      CLOSE_ELTS();   }}static void TAG(render_lines_elts)( GLcontext *ctx,				    GLuint start,				    GLuint count,				    GLuint flags ){   LOCAL_VARS;   int dmasz = GET_MAX_HW_ELTS();   GLuint *elts = GET_MESA_ELTS();   GLuint j, nr;   ELT_TYPE *dest;   if (start+1 >= count)      return;   if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) {      RESET_STIPPLE();      AUTO_STIPPLE( GL_TRUE );   }   ELT_INIT( GL_LINES, HW_LINES );   /* Emit whole number of lines in total and in each buffer:    */   count -= (count-start) & 1;   dmasz -= dmasz & 1;   for (j = start; j < count; j += nr ) {      nr = MIN2( dmasz, count - j );      dest = ALLOC_ELTS( nr );      dest = TAG(emit_elts)( ctx, dest, elts+j, nr );      CLOSE_ELTS();   }   if ((flags & PRIM_END) && ctx->Line.StippleFlag)      AUTO_STIPPLE( GL_FALSE );}static void TAG(render_line_strip_elts)( GLcontext *ctx,					 GLuint start,					 GLuint count,					 GLuint flags ){   LOCAL_VARS;   int dmasz = GET_MAX_HW_ELTS();   GLuint *elts = GET_MESA_ELTS();   GLuint j, nr;   ELT_TYPE *dest;   if (start+1 >= count)      return;   ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP );   if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag)      RESET_STIPPLE();   for (j = start; j + 1 < count; j += nr - 1 ) {      nr = MIN2( dmasz, count - j );      dest = ALLOC_ELTS( nr );      dest = TAG(emit_elts)( ctx, dest, elts+j, nr );      CLOSE_ELTS();   }}static void TAG(render_line_loop_elts)( GLcontext *ctx,					GLuint start,					GLuint count,					GLuint flags ){   LOCAL_VARS;   int dmasz = GET_MAX_HW_ELTS();   GLuint *elts = GET_MESA_ELTS();   GLuint j, nr;   ELT_TYPE *dest;   if (0) fprintf(stderr, "%s\n", __FUNCTION__);   if (flags & PRIM_BEGIN)      j = start;   else      j = start + 1;      if (flags & PRIM_END) {      if (start+1 >= count)	 return;   }    else {      if (j+1 >= count)	 return;   }   ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP );   if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag)      RESET_STIPPLE();      /* Ensure last vertex doesn't wrap:    */   dmasz--;   for ( ; j + 1 < count; ) {      nr = MIN2( dmasz, count - j );      dest = ALLOC_ELTS( nr+1 );	/* Reserve possible space for last elt */      dest = TAG(emit_elts)( ctx, dest, elts+j, nr );      j += nr - 1;      if (j + 1 >= count && (flags & PRIM_END)) {	 dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );      }      CLOSE_ELTS();   }}static void TAG(render_triangles_elts)( GLcontext *ctx,					GLuint start,					GLuint count,					GLuint flags ){   LOCAL_VARS;   GLuint *elts = GET_MESA_ELTS();   int dmasz = GET_MAX_HW_ELTS()/3*3;   GLuint j, nr;   ELT_TYPE *dest;   if (start+2 >= count)      return;   ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );   /* Emit whole number of tris in total.  dmasz is already a multiple    * of 3.    */   count -= (count-start)%3;   for (j = start; j < count; j += nr) {      nr = MIN2( dmasz, count - j );      dest = ALLOC_ELTS( nr );      dest = TAG(emit_elts)( ctx, dest, elts+j, nr );      CLOSE_ELTS();   }}static void TAG(render_tri_strip_elts)( GLcontext *ctx,					GLuint start,					GLuint count,					GLuint flags ){   LOCAL_VARS;   GLuint j, nr;   GLuint *elts = GET_MESA_ELTS();   int dmasz = GET_MAX_HW_ELTS();   ELT_TYPE *dest;   if (start+2 >= count)      return;   ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 );   /* Keep the same winding over multiple buffers:    */   dmasz -= (dmasz & 1);   for (j = start ; j + 2 < count; j += nr - 2 ) {      nr = MIN2( dmasz, count - j );      dest = ALLOC_ELTS( nr );      dest = TAG(emit_elts)( ctx, dest, elts+j, nr );      CLOSE_ELTS();   }}static void TAG(render_tri_fan_elts)( GLcontext *ctx,				      GLuint start,				      GLuint count,				      GLuint flags ){   LOCAL_VARS;   GLuint *elts = GET_MESA_ELTS();   GLuint j, nr;   int dmasz = GET_MAX_HW_ELTS();   ELT_TYPE *dest;   if (start+2 >= count)      return;   ELT_INIT( GL_TRIANGLE_FAN, HW_TRIANGLE_FAN );   for (j = start + 1 ; j + 1 < count; j += nr - 1 ) {      nr = MIN2( dmasz, count - j + 1 );      dest = ALLOC_ELTS( nr );      dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );      dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );      CLOSE_ELTS();   }}static void TAG(render_poly_elts)( GLcontext *ctx,				   GLuint start,				   GLuint count,				   GLuint flags ){   LOCAL_VARS;   GLuint *elts = GET_MESA_ELTS();   GLuint j, nr;   int dmasz = GET_MAX_HW_ELTS();   ELT_TYPE *dest;   if (start+2 >= count)      return;   ELT_INIT( GL_POLYGON, HW_POLYGON );   for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) {      nr = MIN2( dmasz, count - j + 1 );      dest = ALLOC_ELTS( nr );      dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );      dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );      CLOSE_ELTS();   }}static void TAG(render_quad_strip_elts)( GLcontext *ctx,					 GLuint start,					 GLuint count,					 GLuint flags ){   if (start+3 >= count)      return;   if (HAVE_QUAD_STRIPS && 0) {   }   else {      LOCAL_VARS;      GLuint *elts = GET_MESA_ELTS();      int dmasz = GET_MAX_HW_ELTS();      GLuint j, nr;      ELT_TYPE *dest;      /* Emit whole number of quads in total, and in each buffer.       */      dmasz -= dmasz & 1;      count -= (count-start) & 1;      if (ctx->Light.ShadeModel == GL_FLAT) {	 ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );	 dmasz = dmasz/6*2;	 for (j = start; j + 3 < count; j += nr - 2 ) {	    nr = MIN2( dmasz, count - j );	    if (nr >= 4)	    {	       GLint quads = (nr/2)-1;	       ELT_TYPE *dest = ALLOC_ELTS( quads*6 );	       GLint i;	       for ( i = j-start ; i < j-start+quads ; i++, elts += 2 ) {		  EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] );		  EMIT_TWO_ELTS( dest, 2, elts[2], elts[1] );		  EMIT_TWO_ELTS( dest, 4, elts[3], elts[2] );		  dest += 6;	       }	       CLOSE_ELTS();	    }	 }      }      else {	 ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 );	 for (j = start; j + 3 < count; j += nr - 2 ) {	    nr = MIN2( dmasz, count - j );	    dest = ALLOC_ELTS( nr );	    dest = TAG(emit_elts)( ctx, dest, elts+j, nr );	    CLOSE_ELTS();	 }      }   }}static void TAG(render_quads_elts)( GLcontext *ctx,				    GLuint start,				    GLuint count,				    GLuint flags ){   if (start+3 >= count)      return;   if (HAVE_QUADS && 0) {   } else {      LOCAL_VARS;      GLuint *elts = GET_MESA_ELTS();      int dmasz = GET_MAX_HW_ELTS();      GLuint j, nr;      ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );      /* Emit whole number of quads in total, and in each buffer.       */      dmasz -= dmasz & 3;      count -= (count-start) & 3;      /* Adjust for rendering as triangles:       */      dmasz = dmasz/6*4;      for (j = start; j + 3 < count; j += nr ) {	 nr = MIN2( dmasz, count - j );	 {	    GLint quads = nr/4;	    ELT_TYPE *dest = ALLOC_ELTS( quads * 6 );	    GLint i;	    for ( i = j-start ; i < j-start+quads ; i++, elts += 4 ) {	       EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] );	       EMIT_TWO_ELTS( dest, 2, elts[3], elts[1] );	       EMIT_TWO_ELTS( dest, 4, elts[2], elts[3] );	       dest += 6;	    }	    CLOSE_ELTS();	 }      }   }}static tnl_render_func TAG(render_tab_elts)[GL_POLYGON+2] ={   TAG(render_points_elts),   TAG(render_lines_elts),   TAG(render_line_loop_elts),   TAG(render_line_strip_elts),   TAG(render_triangles_elts),   TAG(render_tri_strip_elts),   TAG(render_tri_fan_elts),   TAG(render_quads_elts),   TAG(render_quad_strip_elts),   TAG(render_poly_elts),   TAG(render_noop),};

⌨️ 快捷键说明

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