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 / cybPixel8.c < prev    next >
Encoding:
Text File  |  1999-06-30  |  2.9 KB  |  93 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. /*****        read arrays of RGBA pixels                          *****/
  27. /**********************************************************************/
  28.  
  29. void cyb8ReadCI32Pixel(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  30.             GLuint index[], const GLubyte mask[])
  31. {
  32.   amigaMesaContext amesa;
  33.   struct RastPort *rp;
  34.   GLuint *PtoI;
  35.   GLuint col;
  36.  
  37.   amesa = (amigaMesaContext) ctx->DriverCtx;
  38.   rp = amesa->rp;
  39.   PtoI = amesa->PtoI;
  40.  
  41.   DEBUGOUT(1, "cybReadCI32Pixel(%d)\n", n);
  42.  
  43.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, INDEXi++, Xx++, Yy++) {
  44.     if (*mask++) {
  45.       /* index[i] = read_pixel x[i], y[i] */
  46.       col = ReadRGBPixel(rp, FIXx(*Xx), FIXy(*Yy));
  47.       DEBUGOUT(9, "  ReadRGBPixel(%d, %d)\n", FIXx(*Xx), FIXy(*Yy));
  48.  
  49.       /* this means:
  50.        *  -make a quick match and get a pen (color-quantization!)
  51.        *  -convert the pen to index
  52.        */
  53.       *INDEXi = GetIndexLocal(PL8_RGBA(amesa, (GLubyte) (col >> 24),
  54.                           (GLubyte) (col >> 16),
  55.                           (GLubyte) (col >> 8))) & 0xFF;
  56.     }
  57.   }
  58. }
  59.  
  60. /**********************************************************************/
  61. /*****        read arrays of RGBA pixels doublebuffered           *****/
  62. /**********************************************************************/
  63.  
  64. void cyb8ReadCI32PixelDB(const GLcontext * ctx, GLuint n, const GLint x[], const GLint y[],
  65.               GLuint index[], const GLubyte mask[])
  66. {
  67.   amigaMesaContext amesa;
  68.   GLuint *db;
  69.   GLuint *PtoI;
  70.   GLuint col;
  71.  
  72.   amesa = (amigaMesaContext) ctx->DriverCtx;
  73.   db = dbRGBAGet(amesa);
  74.   PtoI = amesa->PtoI;
  75.  
  76.   DEBUGOUT(1, "cybReadCI32PixelDB(%d)\n", n);
  77.  
  78.   for (--(GLshort)n; (GLshort)n >= 0; (GLshort)n--, INDEXi++, Xx++, Yy++) {
  79.     if (*mask++) {
  80.       /* index[i] = read_pixel x[i], y[i] */
  81.       col = *(dbRGBA(db, *Xx, *Yy));
  82.  
  83.       /* this means:
  84.        *  -make a quick match and get a pen (color-quantization!)
  85.        *  -convert the pen to index
  86.        */
  87.       *INDEXi = GetIndexLocal(PL8_RGBA(amesa, (GLubyte) (col >> 24),
  88.                           (GLubyte) (col >> 16),
  89.                           (GLubyte) (col >> 8))) & 0xFF;
  90.     }
  91.   }
  92. }
  93.