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 / natPixelD.c < prev    next >
Encoding:
Text File  |  1999-07-16  |  3.8 KB  |  119 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 arrays of RGBA pixels                         *****/
  27. /**********************************************************************/
  28.  
  29. void natDWriteRGBAPixel(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  30.             CONST GLubyte rgba[][4], const GLubyte mask[])
  31. {
  32.   amigaMesaContext amesa;
  33.   struct RastPort *rp;
  34.  
  35.   amesa = (amigaMesaContext) ctx->DriverCtx;
  36.   rp = amesa->rp;
  37.  
  38.   DEBUGOUT(1, "natDWriteRGBAPixel(%d)\n", n);
  39.  
  40.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, Xx++, Yy++) {
  41.     if (*mask++) {
  42.       /* write pixel x[i], y[i] using rgba[i][0],rgba[i][1],rgba[i][2],rgba[i][3] */
  43.       SetAPen(rp, PLD_RGBA(amesa, *RGBAb0, *RGBAb1, *RGBAb2, FIXx(*Xx), FIXy(*Yy)));
  44.       DEBUGOUT(9, "  WritePixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  45.       WritePixel(rp, FIXx(*Xx), FIXy(*Yy));
  46.     }
  47.   }
  48. }
  49.  
  50. void natDWriteMonoCIPixel(const GLcontext * ctx, GLuint n,
  51.              const GLint x[], const GLint y[],
  52.              const GLubyte mask[])
  53. {
  54.   amigaMesaContext amesa;
  55.   struct RastPort *rp;
  56.   GLubyte r, g, b;
  57.  
  58.   amesa = (amigaMesaContext) ctx->DriverCtx;
  59.   rp = amesa->rp;
  60.  
  61.   DEBUGOUT(1, "natWriteMonoCIPixel(0x%08x, %d)\n", mask, n);
  62.  
  63.   r = amesa->pixel >> 24;
  64.   g = amesa->pixel >> 16;
  65.   b = amesa->pixel >>  8;
  66.  
  67.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, Xx++, Yy++) {
  68.     DEBUGOUT(9, " mask 0x%08x/%d, x %d, y %d\n", mask, *mask, FIXx(*Xx), FIXy(*Yy));
  69.     if (*mask++) {
  70.       /* write pixel x[i], y[i] using current index */
  71.       SetAPen(rp, PLD_RGBA(amesa, r, g, b, FIXx(*Xx), FIXy(*Yy)));
  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 natDWriteRGBAPixelDB(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  83.               CONST GLubyte rgba[][4], const GLubyte mask[])
  84. {
  85.   amigaMesaContext amesa;
  86.   GLubyte *db;
  87.  
  88.   amesa = (amigaMesaContext) ctx->DriverCtx;
  89.   db = dbPenGet(amesa);
  90.  
  91.   DEBUGOUT(1, "natDWriteRGBAPixelDB(%d)\n", n);
  92.  
  93.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, RGBAi++, Xx++, Yy++)
  94.     if (*mask++)
  95.       *(dbPen(db, *Xx, *Yy)) = PLD_RGBA(amesa, *RGBAb0, *RGBAb1, *RGBAb2, FIXx(*Xx), FIXy(*Yy));
  96. }
  97.  
  98. void natDWriteMonoCIPixelDB(const GLcontext * ctx, GLuint n,
  99.                 const GLint x[], const GLint y[],
  100.                 const GLubyte mask[])
  101. {
  102.   amigaMesaContext amesa;
  103.   GLubyte *db;
  104.   GLubyte r, g, b;
  105.  
  106.   amesa = (amigaMesaContext) ctx->DriverCtx;
  107.   db = dbPenGet(amesa);
  108.  
  109.   DEBUGOUT(1, "natWriteMonoCIPixelDB(%d)\n", n);
  110.  
  111.   r = amesa->pixel >> 24;
  112.   g = amesa->pixel >> 16;
  113.   b = amesa->pixel >>  8;
  114.  
  115.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, Xx++, Yy++)
  116.     if (*mask++)
  117.       *(dbPen(db, *Xx, *Yy)) = PLD_RGBA(amesa, r, g, b, FIXx(*Xx), FIXy(*Yy));
  118. }
  119.