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 / natPixel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-05  |  6.3 KB  |  208 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 "natPixel8.c"
  26. #include "natPixelD.c"
  27. #include "natPixelG.c"
  28.  
  29. /**********************************************************************/
  30. /*****        write arrays of RGBA pixels                         *****/
  31. /**********************************************************************/
  32.  
  33. void natWriteCI32Pixel(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  34.             const GLuint index[], const GLubyte mask[])
  35. {
  36.   amigaMesaContext amesa;
  37.   GLuint *ItoP;
  38.   struct RastPort *rp;
  39.  
  40.   amesa = (amigaMesaContext) ctx->DriverCtx;
  41.   ItoP = amesa->ItoP;
  42.   rp = amesa->rp;
  43.  
  44.   DEBUGOUT(1, "natWriteCI32Pixel(%d)\n", n);
  45.  
  46.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, INDEXi++, Xx++, Yy++) {
  47.     if (*mask++) {
  48.       SetAPen(rp, GetRGBPLocal(*INDEXi));
  49.       DEBUGOUT(9, "  WritePixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  50.       WritePixel(rp, FIXx(*Xx), FIXy(*Yy));
  51.     }
  52.   }
  53. }
  54.  
  55. void natWriteMonoCIPixel(const GLcontext * ctx, GLuint n,
  56.              const GLint x[], const GLint y[],
  57.              const GLubyte mask[])
  58. {
  59.   amigaMesaContext amesa;
  60.   struct RastPort *rp;
  61.  
  62.   amesa = (amigaMesaContext) ctx->DriverCtx;
  63.   rp = amesa->rp;
  64.  
  65.   DEBUGOUT(1, "natWriteMonoCIPixel(0x%08x, %d)\n", mask, n);
  66.  
  67.   SetAPen(rp, amesa->pixel);
  68.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, Xx++, Yy++) {
  69.     DEBUGOUT(9, " mask 0x%08x/%d, x %d, y %d\n", mask, *mask, FIXx(*Xx), FIXy(*Yy));
  70.     if (*mask++) {
  71.       /* write pixel x[i], y[i] using current index */
  72.       DEBUGOUT(9, "  WritePixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  73.       WritePixel(rp, FIXx(*Xx), FIXy(*Yy));
  74.     }
  75.   }
  76. }
  77.  
  78. /**********************************************************************/
  79. /*****        write arrays of RGBA pixels doublebuffered          *****/
  80. /**********************************************************************/
  81.  
  82. void natWriteCI32PixelDB(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  83.               const GLuint index[], const GLubyte mask[])
  84. {
  85.   amigaMesaContext amesa;
  86.   GLuint *ItoP;
  87.   GLubyte *db;
  88.  
  89.   amesa = (amigaMesaContext) ctx->DriverCtx;
  90.   ItoP = amesa->ItoP;
  91.   db = dbPenGet(amesa);
  92.  
  93.   DEBUGOUT(1, "natWriteCI32PixelDB(%d)\n", n);
  94.  
  95.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, INDEXi++, Xx++, Yy++)
  96.     if (*mask++)
  97.       *(dbPen(db, *Xx, *Yy)) = GetRGBPLocal(*INDEXi);
  98. }
  99.  
  100. void natWriteMonoCIPixelDB(const GLcontext * ctx, GLuint n,
  101.                 const GLint x[], const GLint y[],
  102.                 const GLubyte mask[])
  103. {
  104.   amigaMesaContext amesa;
  105.   GLubyte *db;
  106.   GLubyte col;
  107.  
  108.   amesa = (amigaMesaContext) ctx->DriverCtx;
  109.   db = dbPenGet(amesa);
  110.  
  111.   DEBUGOUT(1, "natWriteMonoCIPixelDB(%d)\n", n);
  112.  
  113.   col = amesa->pixel;
  114.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, Xx++, Yy++)
  115.     if (*mask++)
  116.       *(dbPen(db, *Xx, *Yy)) = col;
  117. }
  118.  
  119. /**********************************************************************/
  120. /*****                       Read arrays of pixels                          *****/
  121. /**********************************************************************/
  122. /* Read an array of color index pixels. */
  123.  
  124. void natReadRGBAPixel(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  125.                GLubyte rgba[][4], const GLubyte mask[])
  126. {
  127.   amigaMesaContext amesa;
  128.   struct RastPort *rp;
  129.   GLuint *PtoI;
  130.  
  131.   amesa = (amigaMesaContext) ctx->DriverCtx;
  132.   rp = amesa->rp;
  133.   PtoI = amesa->PtoI;
  134.  
  135.   DEBUGOUT(1, "natReadRGBAPixel(%d)\n", n);
  136.  
  137.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, Xx++, Yy++) {
  138.     if (*mask++) {
  139.       DEBUGOUT(9, "  ReadPixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  140.       *RGBAi = GetIndexLocal(ReadPixel(rp, FIXx(*Xx), FIXy(*Yy))) & 0xFFFFFF00;    /* clear alpha? */
  141.     }
  142.   }
  143. }
  144.  
  145. void natReadCI32Pixel(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  146.                GLuint index[], const GLubyte mask[])
  147. {
  148.   amigaMesaContext amesa;
  149.   struct RastPort *rp;
  150.   GLuint *PtoI;
  151.  
  152.   amesa = (amigaMesaContext) ctx->DriverCtx;
  153.   rp = amesa->rp;
  154.   PtoI = amesa->PtoI;
  155.  
  156.   DEBUGOUT(1, "natReadCI32Pixel(%d)\n", n);
  157.  
  158.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, INDEXi++, Xx++, Yy++) {
  159.     if (*mask++) {
  160.       /* index[i] = read_pixel x[i], y[i] */
  161.       DEBUGOUT(9, "  ReadPixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  162.       *INDEXi = GetIndexLocal(ReadPixel(rp, FIXx(*Xx), FIXy(*Yy))) & 0xFF;    /* clear rgb! */
  163.     }
  164.   }
  165. }
  166.  
  167. /**********************************************************************/
  168. /***** Read arrays of pixels doublebuffered                       *****/
  169. /**********************************************************************/
  170. /* Read an array of color index pixels. */
  171.  
  172. void natReadRGBAPixelDB(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  173.              GLubyte rgba[][4], const GLubyte mask[])
  174. {
  175.   amigaMesaContext amesa;
  176.   GLubyte *db;
  177.   GLuint *PtoI;
  178.  
  179.   amesa = (amigaMesaContext) ctx->DriverCtx;
  180.   db = dbPenGet(amesa);
  181.   PtoI = amesa->PtoI;
  182.  
  183.   DEBUGOUT(1, "natReadRGBAPixelDB(%d)\n", n);
  184.  
  185.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, Xx++, Yy++)
  186.     if (*mask++)
  187.       *RGBAi = GetIndexLocal(*(dbPen(db, *Xx, *Yy))) & 0xFFFFFF00;        /* clear alpha? */
  188. }
  189.  
  190. void natReadCI32PixelDB(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  191.              GLuint index[], const GLubyte mask[])
  192. {
  193.   amigaMesaContext amesa;
  194.   GLubyte *db;
  195.   GLuint *PtoI;
  196.  
  197.   amesa = (amigaMesaContext) ctx->DriverCtx;
  198.   db = dbPenGet(amesa);
  199.   PtoI = amesa->PtoI;
  200.  
  201.   DEBUGOUT(1, "natReadCI32PixelDB(%d)\n", n);
  202.  
  203.   /* index[i] = read_pixel x[i], y[i] */
  204.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, INDEXi++, Xx++, Yy++)
  205.     if (*mask++)
  206.       *INDEXi = GetIndexLocal(*(dbPen(db, *Xx, *Yy))) & 0xFF;            /* clear rgb! */
  207. }
  208.