home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 2000 April & May / AMIGA_2000_04.iso / patches / mesa3.1 / mesa-3_1.lha / src / AOS / natDisplay / natFastTrianglesDBnG.E < prev    next >
Encoding:
Text File  |  1999-09-04  |  4.0 KB  |  129 lines

  1. /*
  2.  * $Id: $
  3.  */
  4.  
  5. /*
  6.  * Mesa 3-D graphics library
  7.  * Version:  3.1
  8.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  9.  *
  10.  * This library is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU Library General Public
  12.  * License as published by the Free Software Foundation; either
  13.  * version 2 of the License, or (at your option) any later version.
  14.  *
  15.  * This library is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * Library General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU Library General Public
  21.  * License along with this library; if not, write to the Free
  22.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25. /**********************************************************************/
  26. /*****                 Optimized triangle rendering               *****/
  27. /**********************************************************************/
  28.  
  29. /* Smooth-shaded, z-less triangle, RGBA color. */
  30. void natGSmoothRGBAZTriangle(GLcontext * ctx, GLuint v0, GLuint v1,
  31.                        GLuint v2, GLuint pv)
  32. {
  33.   amigaMesaContext amesa;
  34.   struct RastPort *rp;
  35.  
  36.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  37.   rp = amesa->rp;
  38.  
  39.   (void)pv;
  40. #define INTERP_Z    1
  41. #define INTERP_RGB    1
  42. #undef    INTERP_ALPHA    /* alpha-channel is useless for amiga (currently) */
  43. #define INNER_LOOP(LEFT, RIGHT, Y) {                            \
  44.     GLshort i, len = RIGHT - LEFT;                            \
  45.     for (i = 0; i < len; i++, zRow++) {                            \
  46.       GLdepth z = FixedToDepth(ffz);                            \
  47.       if (z < *zRow) {                                    \
  48.         SetAPen(rp, PLG_RGBA(amesa, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb)));\
  49.         WritePixel(rp, i + LEFT, Y);                            \
  50.         *zRow = z;                                    \
  51.       }                                            \
  52.       ffr += fdrdx;  ffg += fdgdx;  ffb += fdbdx; /* ffa += fdadx; */            \
  53.       ffz += fdzdx;                                    \
  54.     }                                            \
  55.   }
  56.  
  57. #include "../../tritemp.h"
  58. }
  59.  
  60. /* Flat-shaded, z-less triangle, RGBA color. */
  61. void natGFlatRGBAZTriangle(GLcontext * ctx, GLuint v0, GLuint v1,
  62.                      GLuint v2, GLuint pv)
  63. {
  64.   struct RastPort *rp;
  65.  
  66.   rp = ((amigaMesaContext) ctx->DriverCtx)->rp;
  67.  
  68. #define INTERP_Z    1
  69. #define SETUP_CODE    SetAPen(rp, PLG_RGBA(((amigaMesaContext) ctx->DriverCtx), ctx->VB->ColorPtr->data[pvert][0], ctx->VB->ColorPtr->data[pvert][1], ctx->VB->ColorPtr->data[pvert][2]));
  70.  
  71. #define INNER_LOOP(LEFT, RIGHT, Y) {    \
  72.     GLshort i, len = RIGHT - LEFT;    \
  73.     for (i = 0; i < len; i++, zRow++) {    \
  74.       GLdepth z = FixedToDepth(ffz);    \
  75.       if (z < *zRow) {            \
  76.     WritePixel(rp, i + LEFT, Y);    \
  77.         *zRow = z;            \
  78.       }                    \
  79.       ffz += fdzdx;            \
  80.     }                    \
  81.   }
  82.  
  83. #include "../../tritemp.h"
  84. }
  85.  
  86. /* Smooth-shaded, z-less triangle, RGBA color. */
  87. void natGSmoothRGBATriangle(GLcontext * ctx, GLuint v0, GLuint v1,
  88.                        GLuint v2, GLuint pv)
  89. {
  90.   amigaMesaContext amesa;
  91.   struct RastPort *rp;
  92.  
  93.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  94.   rp = amesa->rp;
  95.  
  96.   (void)pv;
  97. #define INTERP_RGB    1
  98. #undef    INTERP_ALPHA    /* alpha-channel is useless for amiga (currently) */
  99. #define INNER_LOOP(LEFT, RIGHT, Y) {                            \
  100.     GLshort i, len = RIGHT - LEFT;                            \
  101.     for (i = 0; i < len; i++) {                                \
  102.       SetAPen(rp, PLG_RGBA(amesa, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb)));    \
  103.       WritePixel(rp, i + LEFT, Y);                            \
  104.       ffr += fdrdx;  ffg += fdgdx;  ffb += fdbdx; /* ffa += fdadx; */            \
  105.     }                                            \
  106.   }
  107.  
  108. #include "../../tritemp.h"
  109. }
  110.  
  111. /* Flat-shaded, z-less triangle, RGBA color. */
  112. void natGFlatRGBATriangle(GLcontext * ctx, GLuint v0, GLuint v1,
  113.                      GLuint v2, GLuint pv)
  114. {
  115.   struct RastPort *rp;
  116.  
  117.   rp = ((amigaMesaContext) ctx->DriverCtx)->rp;
  118.  
  119. #define SETUP_CODE    SetAPen(rp, PLG_RGBA(((amigaMesaContext) ctx->DriverCtx), ctx->VB->ColorPtr->data[pvert][0], ctx->VB->ColorPtr->data[pvert][1], ctx->VB->ColorPtr->data[pvert][2]));
  120.  
  121. #define INNER_LOOP(LEFT, RIGHT, Y) {    \
  122.     GLshort len = RIGHT - LEFT;        \
  123.     while (--len >= 0)            \
  124.       WritePixel(rp, len + LEFT, Y);    \
  125.   }
  126.  
  127. #include "../../tritemp.h"
  128. }
  129.