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 / cybDisplay / cybPixel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-30  |  6.0 KB  |  199 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. #include "cybPixel8.c"
  26. #include "cybPixelD.c"
  27. #include "cybPixelG.c"
  28.  
  29. /**********************************************************************/
  30. /*****        write arrays of RGBA pixels                         *****/
  31. /**********************************************************************/
  32.  
  33. void cybWriteRGBAPixel(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  34.             CONST GLubyte rgba[][4], const GLubyte mask[])
  35. {
  36.   amigaMesaContext amesa;
  37.   struct RastPort *rp;
  38.  
  39.   amesa = (amigaMesaContext) ctx->DriverCtx;
  40.   rp = amesa->rp;
  41.  
  42.   DEBUGOUT(1, "cybWriteRGBAPixel(%d)\n", n);
  43.  
  44.   RGBAb--;                                    /* hacky RGBA to RGB */
  45.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, Xx++, Yy++) {
  46.     if (*mask++) {
  47.       /* write pixel x[i], y[i] using red[i],green[i],blue[i],alpha[i] */
  48.       WriteRGBPixel(rp, FIXx(*Xx), FIXy(*Yy), *RGBAi);
  49.       DEBUGOUT(9, "  WriteRGBPixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  50.     }
  51.   }
  52. }
  53.  
  54. void cybWriteCI32Pixel(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  55.             const GLuint index[], const GLubyte mask[])
  56. {
  57.   amigaMesaContext amesa;
  58.   GLuint *ItoP;
  59.   struct RastPort *rp;
  60.  
  61.   amesa = (amigaMesaContext) ctx->DriverCtx;
  62.   rp = amesa->rp;
  63.   ItoP = amesa->ItoP;
  64.  
  65.   DEBUGOUT(1, "cybWriteCI32Pixel(%d)\n", n);
  66.  
  67.   I2Pb--;                                    /* hacky RGBA to RGB */
  68.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, INDEXi++, Xx++, Yy++) {
  69.     if (*mask++) {
  70.       WriteRGBPixel(rp, FIXx(*Xx), FIXy(*Yy), GetRGBPLocal(*INDEXi));
  71.       DEBUGOUT(9, "  WriteRGBPixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  72.     }
  73.   }
  74. }
  75.  
  76. void cybWriteMonoCIPixel(const GLcontext * ctx, GLuint n,
  77.               const GLint x[], const GLint y[],
  78.               const GLubyte mask[])
  79. {
  80.   amigaMesaContext amesa;
  81.   struct RastPort *rp;
  82.   GLuint col;
  83.  
  84.   amesa = (amigaMesaContext) ctx->DriverCtx;
  85.   rp = amesa->rp;
  86.  
  87.   DEBUGOUT(1, "cybWriteMonoCIPixel(%d)\n", n);
  88.  
  89.   col = amesa->pixel >> 8;
  90.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, Xx++, Yy++) {
  91.     if (*mask++) {
  92.       /* write pixel x[i], y[i] using current index */
  93.       WriteRGBPixel(rp, FIXx(*Xx), FIXy(*Yy), col);
  94.       DEBUGOUT(9, "  WriteRGBPixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  95.     }
  96.   }
  97. }
  98.  
  99. /**********************************************************************/
  100. /*****        write arrays of RGBA pixels doublebuffered          *****/
  101. /**********************************************************************/
  102.  
  103. void cybWriteRGBAPixelDB(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  104.               CONST GLubyte rgba[][4], const GLubyte mask[])
  105. {
  106.   amigaMesaContext amesa;
  107.   GLuint *db;
  108.  
  109.   amesa = (amigaMesaContext) ctx->DriverCtx;
  110.   db = dbRGBAGet(amesa);
  111.  
  112.   DEBUGOUT(1, "cybWriteRGBAPixelDB(%d)\n", n);
  113.  
  114.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, Xx++, Yy++)
  115.     if (*mask++)
  116.       *(dbRGBA(db, *Xx, *Yy)) = *RGBAi;
  117. }
  118.  
  119. void cybWriteCI32PixelDB(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  120.               const GLuint index[], const GLubyte mask[])
  121. {
  122.   amigaMesaContext amesa;
  123.   GLuint *db;
  124.   GLuint *ItoP;
  125.  
  126.   amesa = (amigaMesaContext) ctx->DriverCtx;
  127.   ItoP = amesa->ItoP;
  128.   db = dbRGBAGet(amesa);
  129.  
  130.   DEBUGOUT(1, "cybWriteCI32PixelDB(%d)\n", n);
  131.  
  132.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, INDEXi++, Xx++, Yy++)
  133.     if (*mask++)
  134.       *(dbRGBA(db, *Xx, *Yy)) = GetRGBPLocal(*INDEXi);
  135. }
  136.  
  137. void cybWriteMonoCIPixelDB(const GLcontext * ctx, GLuint n,
  138.                 const GLint x[], const GLint y[],
  139.                 const GLubyte mask[])
  140. {
  141.   amigaMesaContext amesa;
  142.   GLuint *db;
  143.   GLuint col;
  144.  
  145.   amesa = (amigaMesaContext) ctx->DriverCtx;
  146.   db = dbRGBAGet(amesa);
  147.  
  148.   DEBUGOUT(1, "cybWriteMonoCIPixelDB(%d)\n", n);
  149.  
  150.   col = amesa->pixel;
  151.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, Xx++, Yy++)
  152.     if (*mask++)
  153.       *(dbRGBA(db, *Xx, *Yy)) = col;
  154. }
  155.  
  156. /**********************************************************************/
  157. /*****        read arrays of RGBA pixels                          *****/
  158. /**********************************************************************/
  159. /* Read an array of color index pixels. */
  160.  
  161. void cybReadRGBAPixel(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  162.                GLubyte rgba[][4], const GLubyte mask[])
  163. {
  164.   amigaMesaContext amesa;
  165.   struct RastPort *rp;
  166.  
  167.   amesa = (amigaMesaContext) ctx->DriverCtx;
  168.   rp = amesa->rp;
  169.  
  170.   DEBUGOUT(1, "cybReadRGBAPixel(%d)\n", n);
  171.  
  172. //RGBAb--;                                      /* hacky RGB to RGBA (write not allowed) */
  173.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, Xx++, Yy++) {
  174.     if (*mask++) {
  175.       *RGBAi = ReadRGBPixel(rp, FIXx(*Xx), FIXy(*Yy)) << 8;
  176.       DEBUGOUT(9, "  ReadRGBPixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  177.     }
  178.   }
  179. }
  180.  
  181. /**********************************************************************/
  182. /*****        read arrays of RGBA pixels doublebuffered           *****/
  183. /**********************************************************************/
  184.  
  185. void cybReadRGBAPixelDB(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  186.              GLubyte rgba[][4], const GLubyte mask[])
  187. {
  188.   amigaMesaContext amesa = (amigaMesaContext) ctx->DriverCtx;
  189.   GLuint *db;
  190.  
  191.   db = dbRGBAGet(amesa);
  192.  
  193.   DEBUGOUT(1, "cybReadRGBAPixelDB(%d)\n", n);
  194.  
  195.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, Xx++, Yy++)
  196.     if (*mask++)
  197.       *RGBAi = *(dbRGBA(db, *Xx, *Yy));
  198. }
  199.