- if (HAVE_TRI_STRIPS) {
- LOCAL_VARS;
- GLuint j, nr;
- GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
- int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
- int currentsz;
-
- NEW_PRIMITIVE();
- ELT_INIT( GL_TRIANGLE_STRIP );
-
- currentsz = GET_CURRENT_VB_MAX_ELTS();
- if (currentsz < 8) {
- NEW_BUFFER();
- currentsz = dmasz;
- }
-
- /* Keep the same winding over multiple buffers:
- */
- dmasz -= (dmasz & 1);
- currentsz -= (currentsz & 1);
-
- for (j = start ; j + 2 < count; j += nr - 2 ) {
- nr = MIN2( currentsz, count - j );
- TAG(emit_elts)( ctx, elts+j, nr );
- NEW_PRIMITIVE();
- currentsz = dmasz;
- }
- } else {
- /* TODO: try to emit as indexed triangles */
- ELT_FALLBACK( ctx, start, count, flags );
- }
-}
-
-static void TAG(render_tri_fan_elts)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- if (HAVE_TRI_FANS) {
- LOCAL_VARS;
- GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
- GLuint j, nr;
- int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
- int currentsz;
-
- NEW_PRIMITIVE();
- ELT_INIT( GL_TRIANGLE_FAN );
-
- currentsz = GET_CURRENT_VB_MAX_ELTS();
- if (currentsz < 8) {
- NEW_BUFFER();
- currentsz = dmasz;
- }
-
- for (j = start + 1 ; j + 1 < count; j += nr - 1 ) {
- nr = MIN2( currentsz, count - j + 1 );
- TAG(emit_elts)( ctx, elts+start, 1 );
- TAG(emit_elts)( ctx, elts+j, nr - 1 );
- NEW_PRIMITIVE();
- currentsz = dmasz;
- }
- } else {
- /* TODO: try to emit as indexed triangles */
- ELT_FALLBACK( ctx, start, count, flags );
- }
-}
-
-
-static void TAG(render_poly_elts)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- if (HAVE_POLYGONS && 0) {
- } else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) {
- LOCAL_VARS;
- GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
- GLuint j, nr;
- int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
- int currentsz;
-
- NEW_PRIMITIVE();
- ELT_INIT( GL_TRIANGLE_FAN );
-
- currentsz = GET_CURRENT_VB_MAX_ELTS();
- if (currentsz < 8) {
- NEW_BUFFER();
- currentsz = dmasz;
- }
-
- for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) {
- nr = MIN2( currentsz, count - j + 1 );
- TAG(emit_elts)( ctx, elts+start, 1 );
- TAG(emit_elts)( ctx, elts+j, nr - 1 );
- NEW_PRIMITIVE();
- currentsz = dmasz;
- }
- } else {
- ELT_FALLBACK( ctx, start, count, flags );
- }
-}
-
-static void TAG(render_quad_strip_elts)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- if (HAVE_QUAD_STRIPS && 0) {
- }
- else if (HAVE_TRI_STRIPS) {
- LOCAL_VARS;
- GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
- int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
- int currentsz;
- GLuint j, nr;
-
- NEW_PRIMITIVE();
- currentsz = GET_CURRENT_VB_MAX_ELTS();
-
- /* Emit whole number of quads in total, and in each buffer.
- */
- dmasz -= dmasz & 1;
- count -= (count-start) & 1;
- currentsz -= currentsz & 1;
-
- if (currentsz < 12)
- currentsz = dmasz;
-
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
- ELT_INIT( GL_TRIANGLES );
-
- currentsz = currentsz/6*2;
- dmasz = dmasz/6*2;
-
- for (j = start; j + 3 < count; j += nr - 2 ) {
- nr = MIN2( currentsz, count - j );
-
- if (nr >= 4)
- {
- GLint i;
- GLint quads = (nr/2)-1;
- ELTS_VARS;
-
-
- NEW_PRIMITIVE();
- ALLOC_ELTS_NEW_PRIMITIVE( quads*6 );
-
- for ( i = j-start ; i < j-start+quads ; i++, elts += 2 ) {
- EMIT_TWO_ELTS( 0, elts[0], elts[1] );
- EMIT_TWO_ELTS( 2, elts[2], elts[1] );
- EMIT_TWO_ELTS( 4, elts[3], elts[2] );
- INCR_ELTS( 6 );
- }
-
- NEW_PRIMITIVE();
- }