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