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 / natSpansD.c < prev    next >
Encoding:
Text File  |  1999-07-16  |  7.1 KB  |  250 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 natDWriteRGBASpan(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, "natDWriteRGBASpan(%d, %d, %d): ", n, x, y);
  43.  
  44.   if (!mask) {
  45.     GLshort s, xx;
  46.  
  47.     DEBUGOUT(1, "nomask\n");
  48.     for (s = n - 1, xx = x; s >= 0; s--, xx++, RGBAi++)                /*  draw pixel (x[i],y[i]) */
  49.       *il++ = PLD_RGBA(amesa, *RGBAb0, *RGBAb1, *RGBAb2, xx, y);        /* 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, xx;
  55.  
  56.     DEBUGOUT(1, "mask\n");
  57.     for (i = 0, xx = x; i < n; i++, xx++) {                    /*  draw pixel (x[i],y[i])  */
  58.       if (*mask++) {
  59.     ant++;
  60.     *il++ = PLD_RGBA(amesa, *iRGBAb0, *iRGBAb1, *iRGBAb2, xx, y);        /* 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 natDWriteRGBSpan(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, "natDWriteRGBSpan(%d, %d, %d): ", n, x, y);
  95.  
  96.   if (!mask) {
  97.     GLshort s, xx;
  98.  
  99.     DEBUGOUT(1, "nomask\n");
  100.     for (s = n - 1, xx = x; s >= 0; s--, xx++, RGBb += 3)
  101.       *il++ = PLD_RGBA(amesa, *RGBb0, *RGBb1, *RGBb2, xx, y);            /* 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, xx;
  107.  
  108.     DEBUGOUT(1, "mask\n");
  109.     for (i = 0, xx = x; i < n; i++, xx++) {                    /*  draw pixel (x[i],y[i])  */
  110.       if (*mask++) {
  111.     ant++;
  112.     *il++ = PLD_RGBA(amesa, *iRGBb0, *iRGBb1, *iRGBb2, xx, y);        /* 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. void natDWriteMonoCISpan(const GLcontext * ctx, GLuint n, GLint x, GLint y, const GLubyte mask[])
  134. {
  135.   amigaMesaContext amesa;
  136.   struct RastPort *rp;
  137.   GLshort s;
  138.   GLubyte r, g, b;
  139.  
  140.   amesa = (amigaMesaContext) ctx->DriverCtx;
  141.   rp = amesa->rp;
  142.  
  143.   y = FIXy(y);
  144.   x = FIXx(x);
  145.   DEBUGOUT(1, "natWriteMonoCISpan(%d, %d, %d): \n", n, x, y);
  146.  
  147.   s = 0;
  148.   r = amesa->pixel >> 24;
  149.   g = amesa->pixel >> 16;
  150.   b = amesa->pixel >>  8;
  151.  
  152.   while (s < n) {
  153.     while (!*mask++ && s < n) {
  154.       s++;
  155.       x++;
  156.     } mask--;
  157.  
  158.     if (s < n) {
  159.       while (*mask++ && s < n) {
  160.     SetAPen(rp, PLD_RGBA(amesa, r, g, b, x, y));
  161.     WritePixel(rp, x, y);
  162.     s++;
  163.     x++;
  164.       } mask--;
  165.       SetAPen(rp, PLD_RGBA(amesa, r, g, b, x, y));
  166.       WritePixel(rp, x, y);
  167.     }
  168.   }
  169. }
  170.  
  171. /**********************************************************************/
  172. /*****        write spans of RGBA pixels doublebuffered           *****/
  173. /**********************************************************************/
  174.  
  175. void natDWriteRGBASpanDB(const GLcontext * ctx, GLuint n, GLint x, GLint y,
  176.              CONST GLubyte rgba[][4], const GLubyte mask[])
  177. {
  178.   amigaMesaContext amesa;
  179.   GLubyte *db;
  180.  
  181.   amesa = (amigaMesaContext) ctx->DriverCtx;
  182.   db = dbPen(dbPenGet(amesa), x, y);
  183.  
  184.   DEBUGOUT(1, "natDWriteRGBASpanDB(%d, %d, %d)\n", n, FIXx(x), FIXy(y));
  185.  
  186.   /* Slower */
  187.   if (!mask) {
  188.     /*  draw pixel (x[i],y[i]) */
  189.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, x++, RGBAi++)
  190.       *db++ = PLD_RGBA(amesa, *RGBAb0, *RGBAb1, *RGBAb2, x, y);            /* clear rgb? */
  191.   }
  192.   else
  193.     /* draw pixel (x[i],y[i]) using index[i] */
  194.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, x++, RGBAi++, db++)
  195.       if (*mask++)
  196.     *db = PLD_RGBA(amesa, *RGBAb0, *RGBAb1, *RGBAb2, x, y);            /* clear rgb? */
  197. }
  198.  
  199. void natDWriteRGBSpanDB(const GLcontext * ctx, GLuint n, GLint x, GLint y,
  200.             CONST GLubyte rgb[][3], const GLubyte mask[])
  201. {
  202.   amigaMesaContext amesa;
  203.   GLubyte *db;
  204.  
  205.   amesa = (amigaMesaContext) ctx->DriverCtx;
  206.   db = dbPen(dbPenGet(amesa), x, y);
  207.  
  208.   DEBUGOUT(1, "natDWriteRGBSpanDB(%d, %d, %d)\n", n, FIXx(x), FIXy(y));
  209.  
  210.   /* Slower */
  211.   if (!mask) {
  212.     /*  draw pixel (x[i],y[i]) */
  213.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, x++, RGBb += 3)
  214.       *db++ = PLD_RGBA(amesa, *RGBb0, *RGBb1, *RGBb2, x, y);                /* clear rgb? */
  215.   }
  216.   else
  217.     /* draw pixel (x[i],y[i]) using index[i] */
  218.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, x++, RGBb += 3, db++)
  219.       if (*mask++)
  220.     *db = PLD_RGBA(amesa, *RGBb0, *RGBb1, *RGBb2, x, y);                /* clear rgb? */
  221. }
  222.  
  223. void natDWriteMonoCISpanDB(const GLcontext * ctx, GLuint n, GLint x, GLint y,
  224.               const GLubyte mask[])
  225. {
  226.   amigaMesaContext amesa;
  227.   GLubyte *db;
  228.   GLubyte r, g, b;
  229.  
  230.   amesa = (amigaMesaContext) ctx->DriverCtx;
  231.   db = dbPen(dbPenGet(amesa), x, y);
  232.  
  233.   DEBUGOUT(1, "natWriteMonoCISpanDB(%d, %d, %d)\n", n, FIXx(x), FIXy(y));
  234.  
  235.   r = amesa->pixel >> 24;
  236.   g = amesa->pixel >> 16;
  237.   b = amesa->pixel >>  8;
  238.  
  239.   if (!mask) {
  240.     /* draw pixel (x[i],y[i]) using index[i] */
  241.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, x++)                        /* Slower */
  242.       *db++ = PLD_RGBA(amesa, r, g, b, x, y);
  243.   }
  244.   else
  245.     /* draw pixel (x[i],y[i]) using index[i] */
  246.     for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, x++, db++)
  247.       if (*mask++)
  248.     *db = PLD_RGBA(amesa, r, g, b, x, y);
  249. }
  250.