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 / natSpans8.c < prev    next >
Encoding:
Text File  |  1999-06-30  |  5.5 KB  |  184 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. /*****        write spans of RGBA pixels                          *****/
  27. /**********************************************************************/
  28.  
  29. void nat8WriteRGBASpan(const GLcontext * ctx, GLuint n, GLint x, GLint y,
  30.                CONST GLubyte rgba[][4], const GLubyte mask[])
  31. {
  32.   amigaMesaContext amesa;
  33.   GLubyte *il;
  34.   struct RastPort *rp;
  35.  
  36.   amesa = (amigaMesaContext) ctx->DriverCtx;
  37.   rp = amesa->rp;
  38.   il = amesa->imageline;                            /*  if imageline allocated then use fastversion  */
  39.  
  40.   y = FIXy(y);
  41.   x = FIXx(x);
  42.   DEBUGOUT(1, "nat8WriteRGBASpan(%d, %d, %d): ", n, x, y);
  43.  
  44.   if (!mask) {
  45.     GLshort s;
  46.  
  47.     DEBUGOUT(1, "nomask\n");
  48.     for (s = n - 1; s >= 0; s--, RGBAi++)                    /*  draw pixel (x[i],y[i]) */
  49.       *il++ = PL8_RGBA(amesa, *RGBAb0, *RGBAb1, *RGBAb2);            /* clear rgb? */
  50.     DEBUGOUT(8, "  MyWritePixelLine8(%d, %d, %d)\n", n, x, y);
  51.     MyWritePixelLine8(rp, x, y, n, il = amesa->imageline, amesa->temprp);
  52.   }
  53.   else {
  54.     GLshort i, ant = 0;
  55.  
  56.     DEBUGOUT(1, "mask\n");
  57.     for (i = 0; i < n; i++) {                            /*  draw pixel (x[i],y[i])  */
  58.       if (*mask++) {
  59.     ant++;
  60.     *il++ = PL8_RGBA(amesa, *iRGBAb0, *iRGBAb1, *iRGBAb2);            /* clear rgb? */
  61.       }
  62.       else {
  63.     if (ant) {
  64.       DEBUGOUT(9, "  MyWritePixelLine8(%d, %d, %d)\n", ant, x, y);
  65.       MyWritePixelLine8(rp, x, y, ant, il = amesa->imageline, amesa->temprp);
  66.       x += ant;
  67.       ant = 0;
  68.     }
  69.     else
  70.       x++;
  71.       }
  72.     }
  73.  
  74.     if (ant) {
  75.       DEBUGOUT(9, "  MyWritePixelLine8(%d, %d, %d)\n", ant, x, y);
  76.       MyWritePixelLine8(rp, x, y, ant, amesa->imageline, amesa->temprp);
  77.     }
  78.   }
  79. }
  80.  
  81. void nat8WriteRGBSpan(const GLcontext * ctx, GLuint n, GLint x, GLint y,
  82.               CONST GLubyte rgb[][3], const GLubyte mask[])
  83. {
  84.   amigaMesaContext amesa;
  85.   GLubyte *il;
  86.   struct RastPort *rp;
  87.  
  88.   amesa = (amigaMesaContext) ctx->DriverCtx;
  89.   rp = amesa->rp;
  90.   il = amesa->imageline;                            /*  if imageline allocated then use fastversion  */
  91.  
  92.   y = FIXy(y);
  93.   x = FIXx(x);
  94.   DEBUGOUT(1, "nat8WriteRGBSpan(%d, %d, %d): ", n, x, y);
  95.  
  96.   if (!mask) {
  97.     GLshort s;
  98.  
  99.     DEBUGOUT(1, "nomask\n");
  100.     for (s = n - 1; s >= 0; s--, RGBb += 3)
  101.       *il++ = PL8_RGBA(amesa, *RGBb0, *RGBb1, *RGBb2);                /* clear rgb? */
  102.     DEBUGOUT(8, "  MyWritePixelLine8(%d, %d, %d)\n", n, x, y);
  103.     MyWritePixelLine8(rp, x, y, n, il = amesa->imageline, amesa->temprp);
  104.   }
  105.   else {
  106.     GLshort i, ant = 0;
  107.  
  108.     DEBUGOUT(1, "mask\n");
  109.     for (i = 0; i < n; i++) {                            /*  draw pixel (x[i],y[i])  */
  110.       if (*mask++) {
  111.     ant++;
  112.     *il++ = PL8_RGBA(amesa, *iRGBb0, *iRGBb1, *iRGBb2);            /* clear rgb? */
  113.       }
  114.       else {
  115.     if (ant) {
  116.       DEBUGOUT(9, "  MyWritePixelLine8(%d, %d, %d)\n", ant, x, y);
  117.       MyWritePixelLine8(rp, x, y, ant, il = amesa->imageline, amesa->temprp);
  118.       x += ant;
  119.       ant = 0;
  120.     }
  121.     else
  122.       x++;
  123.       }
  124.     }
  125.  
  126.     if (ant) {
  127.       DEBUGOUT(9, "  MyWritePixelLine8(%d, %d, %d)\n", ant, x, y);
  128.       MyWritePixelLine8(rp, x, y, ant, amesa->imageline, amesa->temprp);
  129.     }
  130.   }
  131. }
  132.  
  133. /**********************************************************************/
  134. /*****        write spans of RGBA pixels doublebuffered           *****/
  135. /**********************************************************************/
  136.  
  137. void nat8WriteRGBASpanDB(const GLcontext * ctx, GLuint n, GLint x, GLint y,
  138.              CONST GLubyte rgba[][4], const GLubyte mask[])
  139. {
  140.   amigaMesaContext amesa;
  141.   GLubyte *db;
  142.  
  143.   amesa = (amigaMesaContext) ctx->DriverCtx;
  144.   db = dbPen(dbPenGet(amesa), x, y);
  145.  
  146.   DEBUGOUT(1, "nat8WriteRGBASpanDB(%d, %d, %d)\n", n, FIXx(x), FIXy(y));
  147.  
  148.   /* Slower */
  149.   if (!mask) {
  150.     /*  draw pixel (x[i],y[i]) */
  151.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++)
  152.       *db++ = PL8_RGBA(amesa, *RGBAb0, *RGBAb1, *RGBAb2);            /* clear rgb? */
  153.   }
  154.   else
  155.     /* draw pixel (x[i],y[i]) using index[i] */
  156.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, db++)
  157.       if (*mask++)
  158.     *db = PL8_RGBA(amesa, *RGBAb0, *RGBAb1, *RGBAb2);            /* clear rgb? */
  159. }
  160.  
  161. void nat8WriteRGBSpanDB(const GLcontext * ctx, GLuint n, GLint x, GLint y,
  162.             CONST GLubyte rgb[][3], const GLubyte mask[])
  163. {
  164.   amigaMesaContext amesa;
  165.   GLubyte *db;
  166.  
  167.   amesa = (amigaMesaContext) ctx->DriverCtx;
  168.   db = dbPen(dbPenGet(amesa), x, y);
  169.  
  170.   DEBUGOUT(1, "nat8WriteRGBSpanDB(%d, %d, %d)\n", n, FIXx(x), FIXy(y));
  171.  
  172.   /* Slower */
  173.   if (!mask) {
  174.     /*  draw pixel (x[i],y[i]) */
  175.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBb += 3)
  176.       *db++ = PL8_RGBA(amesa, *RGBb0, *RGBb1, *RGBb2);                /* clear rgb? */
  177.   }
  178.   else
  179.     /* draw pixel (x[i],y[i]) using index[i] */
  180.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBb += 3, db++)
  181.       if (*mask++)
  182.     *db = PL8_RGBA(amesa, *RGBb0, *RGBb1, *RGBb2);                /* clear rgb? */
  183. }
  184.