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 / natFastTrianglesDBD.E < prev    next >
Encoding:
Text File  |  1999-09-04  |  4.2 KB  |  135 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 natDSmoothRGBAZTriangleDB(GLcontext * ctx, GLuint v0, GLuint v1,
  31.                        GLuint v2, GLuint pv)
  32. {
  33.   amigamesaContext amesa;
  34.   GLubyte *db;
  35.  
  36.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  37.   db = dbPenGet(amesa);
  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.     GLubyte *img = dbPen(db, LEFT, Y);                               \
  46.     for (i = 0; i < len; i++, img++, zRow++) {                            \
  47.       GLdepth z = FixedToDepth(ffz);                                \
  48.       if (z < *zRow) {                                        \
  49.         *img = PLD_RGBA(amesa, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb), 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 natDFlatRGBAZTriangleDB(GLcontext * ctx, GLuint v0, GLuint v1,
  62.                      GLuint v2, GLuint pv)
  63. {
  64.   GLubyte *db;
  65.  
  66.   db = dbPenGet(((amigaMesaContext) ctx->DriverCtx));
  67.  
  68. #define INTERP_Z    1
  69. #define INNER_LOOP(LEFT, RIGHT, Y) {                        \
  70.     GLshort i, len = RIGHT - LEFT;                        \
  71.     GLubyte *img = dbPen(db, LEFT, Y);                       \
  72.     for (i = 0; i < len; i++, img++, zRow++) {                    \
  73.       GLdepth z = FixedToDepth(ffz);                        \
  74.       if (z < *zRow) {                                \
  75.         *img = PLD_RGBA(((amigaMesaContext) ctx->DriverCtx),            \
  76.                         VB->ColorPtr->data[pv][0],            \
  77.                         VB->ColorPtr->data[pv][1],            \
  78.                         VB->ColorPtr->data[pv][2], i + LEFT, Y);    \
  79.         *zRow = z;                                \
  80.       }                                        \
  81.       ffz += fdzdx;                                \
  82.     }                                        \
  83.   }
  84.  
  85. #include "../../tritemp.h"
  86. }
  87.  
  88. /* Smooth-shaded, z-less triangle, RGBA color. */
  89. void natDSmoothRGBATriangleDB(GLcontext * ctx, GLuint v0, GLuint v1,
  90.                        GLuint v2, GLuint pv)
  91. {
  92.   amigaMesaContext amesa;
  93.   GLubyte *db;
  94.  
  95.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  96.   db = dbPenGet(amesa);
  97.  
  98.   (void)pv;
  99. #define INTERP_RGB    1
  100. #undef    INTERP_ALPHA    /* alpha-channel is useless for amiga (currently) */
  101. #define INNER_LOOP(LEFT, RIGHT, Y) {                                \
  102.     GLshort len = RIGHT - LEFT, i = 0;                                \
  103.     GLubyte *img = dbPen(db, LEFT, Y);                               \
  104.     while (--len >= 0) {                                    \
  105.       *img++ = PLD_RGBA(amesa, FixedToInt(ffr), FixedToInt(ffg), FixedToInt(ffb), i + LEFT, Y);    \
  106.       ffr += fdrdx;  ffg += fdgdx;  ffb += fdbdx; /* ffa += fdadx; */ i++;            \
  107.     }                                                \
  108.   }
  109.  
  110. #include "../../tritemp.h"
  111. }
  112.  
  113. /* Flat-shaded, z-less triangle, RGBA color. */
  114. void natDFlatRGBATriangleDB(GLcontext * ctx, GLuint v0, GLuint v1,
  115.                      GLuint v2, GLuint pv)
  116. {
  117.   GLubyte *db;
  118.  
  119.   db = dbPenGet(((amigaMesaContext) ctx->DriverCtx));
  120.  
  121. #define INNER_LOOP(LEFT, RIGHT, Y) {                        \
  122.     GLshort len = RIGHT - LEFT;                            \
  123.     GLubyte *img = dbPen(db, RIGHT, Y);                      \
  124.     while (--len >= 0) {                            \
  125.       *--img = PLD_RGBA(((amigaMesaContext) ctx->DriverCtx),            \
  126.                         VB->ColorPtr->data[pv][0],            \
  127.                         VB->ColorPtr->data[pv][1],            \
  128.                         VB->ColorPtr->data[pv][2], len + LEFT, Y);    \
  129.       i++;                                    \
  130.     }                                        \
  131.   }
  132.  
  133. #include "../../tritemp.h"
  134. }
  135.