home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / System / Mesa-3.1 / src / render_tmp.h < prev    next >
C/C++ Source or Header  |  2000-01-07  |  6KB  |  295 lines

  1. /* $Id: render_tmp.h,v 1.6.2.1 1999/12/01 12:18:47 keithw Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  3.1
  6.  * 
  7.  * Copyright (C) 1999  Brian Paul   All Rights Reserved.
  8.  * 
  9.  * Permission is hereby granted, free of charge, to any person obtaining a
  10.  * copy of this software and associated documentation files (the "Software"),
  11.  * to deal in the Software without restriction, including without limitation
  12.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13.  * and/or sell copies of the Software, and to permit persons to whom the
  14.  * Software is furnished to do so, subject to the following conditions:
  15.  * 
  16.  * The above copyright notice and this permission notice shall be included
  17.  * in all copies or substantial portions of the Software.
  18.  * 
  19.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  22.  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  23.  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24.  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  */
  26.  
  27. /*
  28.  * New (3.1) transformation code written by Keith Whitwell.
  29.  */
  30.  
  31. #ifndef POSTFIX
  32. #define POSTFIX
  33. #endif
  34.  
  35. #ifndef INIT
  36. #define INIT(x)  
  37. #endif
  38.  
  39. #ifndef NEED_EDGEFLAG_SETUP
  40. #define NEED_EDGEFLAG_SETUP 0
  41. #define EDGEFLAG_TRI(a,b,c,d,e)
  42. #define EDGEFLAG_QUAD(a,b,c,d,e)
  43. #endif
  44.  
  45. #ifndef RESET_STIPPLE
  46. #define RESET_STIPPLE
  47. #endif
  48.  
  49.  
  50. static void TAG(render_vb_points)( struct vertex_buffer *VB,
  51.                    GLuint start,
  52.                    GLuint count,
  53.                    GLuint parity )
  54. {
  55.    LOCAL_VARS;
  56.    (void) parity;
  57.    INIT(GL_POINTS);
  58.    RENDER_POINTS( start, count );
  59.    POSTFIX;
  60. }
  61.  
  62. static void TAG(render_vb_lines)( struct vertex_buffer *VB,
  63.                   GLuint start,
  64.                   GLuint count,
  65.                   GLuint parity )
  66. {
  67.    GLuint j;
  68.    LOCAL_VARS;
  69.    (void) parity;
  70.  
  71.    INIT(GL_LINES);
  72.    for (j=start+1; j<count; j+=2 ) {
  73.       RENDER_LINE( j-1, j );
  74.       RESET_STIPPLE;
  75.    }
  76.    POSTFIX;
  77. }
  78.  
  79.  
  80. static void TAG(render_vb_line_strip)( struct vertex_buffer *VB,
  81.                        GLuint start,
  82.                        GLuint count,
  83.                        GLuint parity )
  84. {
  85.    GLuint j;
  86.    LOCAL_VARS;
  87.    (void) parity;
  88.  
  89.    INIT(GL_LINES);
  90.    for (j=start+1; j<count; j++ ) {
  91.       RENDER_LINE( j-1, j );
  92.    }   
  93.    RESET_STIPPLE;
  94.    POSTFIX;
  95. }
  96.  
  97.  
  98. static void TAG(render_vb_line_loop)( struct vertex_buffer *VB,
  99.                       GLuint start,
  100.                       GLuint count,
  101.                       GLuint parity )
  102. {
  103.    GLuint i = start < VB->Start ? VB->Start : start + 1;     
  104.    LOCAL_VARS;
  105.    (void) parity;
  106.  
  107.    INIT(GL_LINES);
  108.    for ( ; i < count ; i++) {
  109.       RENDER_LINE( i-1, i );
  110.    }
  111.  
  112.    if (VB->Flag[count] & VERT_END) {
  113.       RENDER_LINE( i-1, start );
  114.    }   
  115.  
  116.    RESET_STIPPLE;
  117.    POSTFIX;
  118. }
  119.  
  120.  
  121. static void TAG(render_vb_triangles)( struct vertex_buffer *VB,
  122.                       GLuint start,
  123.                       GLuint count,
  124.                       GLuint parity )
  125. {
  126.    GLuint j;
  127.    LOCAL_VARS;
  128.    (void) parity;
  129.  
  130.    INIT(GL_POLYGON);
  131.    for (j=start+2; j<count; j+=3) {
  132.       RENDER_TRI( j-2, j-1, j, j, 0 );
  133.       RESET_STIPPLE;
  134.    }
  135.    POSTFIX;
  136. }
  137.  
  138.  
  139.  
  140. static void TAG(render_vb_tri_strip)( struct vertex_buffer *VB,
  141.                       GLuint start,
  142.                       GLuint count,
  143.                       GLuint parity )
  144. {
  145.    GLuint j;
  146.    LOCAL_VARS;
  147.    (void) parity;
  148.    INIT(GL_POLYGON);
  149.    if (NEED_EDGEFLAG_SETUP) {
  150.       for (j=start+2;j<count;j++,parity^=1) {
  151.      EDGEFLAG_TRI( j-2, j-1, j, j, parity );
  152.      RENDER_TRI( j-2, j-1, j, j, parity );
  153.      RESET_STIPPLE;
  154.       }
  155.    } else {
  156.    for (j=start+2;j<count;j++,parity^=1) {
  157.       RENDER_TRI( j-2, j-1, j, j, parity );
  158.    }
  159.    }
  160.    POSTFIX;
  161. }
  162.  
  163.  
  164. static void TAG(render_vb_tri_fan)( struct vertex_buffer *VB,
  165.                     GLuint start,
  166.                     GLuint count,
  167.                     GLuint parity )
  168. {
  169.    GLuint j;
  170.    LOCAL_VARS;
  171.    (void) parity;
  172.    INIT(GL_POLYGON);
  173.    if (NEED_EDGEFLAG_SETUP) {
  174.    for (j=start+2;j<count;j++) {
  175.      EDGEFLAG_TRI( start, j-1, j, j, 0 );
  176.      RENDER_TRI( start, j-1, j, j, 0 );
  177.      RESET_STIPPLE;
  178.       }
  179.    } else {
  180.       for (j=start+2;j<count;j++) {
  181.      RENDER_TRI( start, j-1, j, j, 0 );
  182.       }
  183.    }
  184.  
  185.    POSTFIX;
  186. }
  187.  
  188.  
  189. static void TAG(render_vb_poly)( struct vertex_buffer *VB,
  190.                  GLuint start,
  191.                  GLuint count,
  192.                  GLuint parity )
  193. {
  194.    GLuint j;
  195.    LOCAL_VARS;
  196.    (void) parity;
  197.    INIT(GL_POLYGON);
  198.    for (j=start+2;j<count;j++) {
  199.       RENDER_TRI( start, j-1, j, start, 0 );
  200.    }
  201.    RESET_STIPPLE;
  202.    POSTFIX;
  203. }
  204.  
  205.  
  206. static void TAG(render_vb_quads)( struct vertex_buffer *VB,
  207.                   GLuint start,
  208.                   GLuint count,
  209.                   GLuint parity )
  210. {
  211.    GLuint j;
  212.    LOCAL_VARS;
  213.    (void) parity;
  214.    INIT(GL_POLYGON);
  215.    for (j=start+3; j<count; j+=4) {
  216.       RENDER_QUAD( j-3, j-2, j-1, j, j );
  217.       RESET_STIPPLE;
  218.    }
  219.    POSTFIX;
  220. }
  221.  
  222. static void TAG(render_vb_quad_strip)( struct vertex_buffer *VB,
  223.                        GLuint start,
  224.                        GLuint count,
  225.                        GLuint parity )
  226. {
  227.    GLuint j;
  228.    LOCAL_VARS;
  229.    (void) parity;
  230.    INIT(GL_POLYGON);
  231.    if (NEED_EDGEFLAG_SETUP) {
  232.       for (j=start+3;j<count;j+=2) {
  233.      EDGEFLAG_QUAD( j-3, j-2, j, j-1, j );
  234.      RENDER_QUAD( j-3, j-2, j, j-1, j );
  235.      RESET_STIPPLE;
  236.       }
  237.    } else {
  238.    for (j=start+3;j<count;j+=2) {
  239.       RENDER_QUAD( j-3, j-2, j, j-1, j );
  240.    }
  241.    }
  242.    POSTFIX;
  243. }
  244.  
  245. static void TAG(render_vb_noop)( struct vertex_buffer *VB,
  246.                  GLuint start,
  247.                  GLuint count,
  248.                  GLuint parity )
  249. {
  250.    (void) VB;
  251.    (void) start;
  252.    (void) count;
  253.    (void) parity;
  254. }
  255.  
  256.  
  257.  
  258. static render_func TAG(render_tab)[GL_POLYGON+2] = {
  259.    TAG(render_vb_points),
  260.    TAG(render_vb_lines),
  261.    TAG(render_vb_line_loop),
  262.    TAG(render_vb_line_strip),
  263.    TAG(render_vb_triangles),
  264.    TAG(render_vb_tri_strip),
  265.    TAG(render_vb_tri_fan),
  266.    TAG(render_vb_quads),
  267.    TAG(render_vb_quad_strip),
  268.    TAG(render_vb_poly),
  269.    TAG(render_vb_noop)
  270. };
  271.  
  272. static void TAG(render_init)( void )
  273. {
  274. }
  275.  
  276.  
  277. #ifndef PRESERVE_VB_DEFS
  278. #undef RENDER_TRI
  279. #undef RENDER_QUAD
  280. #undef RENDER_LINE
  281. #undef RENDER_POINTS
  282. #undef LOCAL_VARS
  283. #undef INIT
  284. #undef POSTFIX
  285. #undef RESET_STIPPLE
  286. #endif
  287.  
  288. #ifndef PRESERVE_TAG
  289. #undef TAG
  290. #endif
  291.  
  292. #undef PRESERVE_VB_DEFS
  293. #undef PRESERVE_TAG
  294.  
  295.