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