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 / natFastPoints.c < prev    next >
Encoding:
Text File  |  1999-09-23  |  3.6 KB  |  132 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. /*****            Accelerated point, line, polygon rendering      *****/
  27. /**********************************************************************/
  28.  
  29. void natFastPointsFunction(GLcontext * ctx, GLuint first, GLuint last)
  30. {
  31.   amigaMesaContext amesa;
  32.   struct vertex_buffer *VB;
  33.   struct RastPort *rp;
  34.   GLubyte *mask;
  35.   GLshort i;
  36.  
  37.   amesa = (amigaMesaContext) ctx->DriverCtx;
  38.   VB = ctx->VB;
  39.   rp = amesa->rp;
  40.  
  41.   DEBUGOUT(1, "natFastPointsFunction: ");
  42.  
  43.   mask = VB->ClipMask;
  44.   if (!(amesa->visual->flags & VISUAL_RGBMODE)) {
  45.     GLuint *ItoP = amesa->ItoP;
  46.  
  47.     DEBUGOUT(1, "VB.IndexColor\n");
  48.     for (i = first; i <= last; i++) {
  49.       if (!*mask++) {
  50.     int x, y;
  51.  
  52.     x = FIXx((GLint) (VB->Win.data[i][0]));
  53.     y = FIXy((GLint) (VB->Win.data[i][1]));
  54.  
  55.     SetAPen(rp, GetRGBPLocal(VB->IndexPtr->data[i]));
  56.     DEBUGOUT(9, "  WritePixel(%d, %d)\n", x, y);
  57.     WritePixel(rp, x, y);
  58.       }
  59.     }
  60.   }
  61.   else if (IS_SHIFT(amesa->trueColor)) {
  62.     DEBUGOUT(1, "VB.RGBColor 332shift\n");
  63.     for (i = first; i <= last; i++) {
  64.       if (!*mask++) {
  65.     int x, y;
  66.  
  67.     x = FIXx((GLint) (VB->Win.data[i][0]));
  68.     y = FIXy((GLint) (VB->Win.data[i][1]));
  69.  
  70.     SetAPen(rp, PL8_RGBA(amesa, VB->ColorPtr->data[i][0], VB->ColorPtr->data[i][1], VB->ColorPtr->data[i][2]));
  71.     DEBUGOUT(9, "  WritePixel(%d, %d)\n", x, y);
  72.     WritePixel(rp, x, y);
  73.       }
  74.     }
  75.   }
  76.   else if (IS_MATCH(amesa->trueColor)) {
  77.     DEBUGOUT(1, "VB.RGBColor GetPen\n");
  78.     for (i = first; i <= last; i++) {
  79.       if (!*mask++) {
  80.     int x, y;
  81.  
  82.     x = FIXx((GLint) (VB->Win.data[i][0]));
  83.     y = FIXy((GLint) (VB->Win.data[i][1]));
  84.  
  85.     SetAPen(rp, PLG_RGBA(amesa, VB->ColorPtr->data[i][0], VB->ColorPtr->data[i][1], VB->ColorPtr->data[i][2]));
  86.     DEBUGOUT(9, "  WritePixel(%d, %d)\n", x, y);
  87.     WritePixel(rp, x, y);
  88.       }
  89.     }
  90.   }
  91.   else {
  92.     DEBUGOUT(1, "VB.RGBColor 332shift\n");
  93.     for (i = first; i <= last; i++) {
  94.       if (!*mask++) {
  95.     int x, y;
  96.  
  97.     x = FIXx((GLint) (VB->Win.data[i][0]));
  98.     y = FIXy((GLint) (VB->Win.data[i][1]));
  99.  
  100.     SetAPen(rp, PLD_RGBA(amesa, VB->ColorPtr->data[i][0], VB->ColorPtr->data[i][1], VB->ColorPtr->data[i][2], x, y));
  101.     DEBUGOUT(9, "  WritePixel(%d, %d)\n", x, y);
  102.     WritePixel(rp, x, y);
  103.       }
  104.     }
  105.   }
  106. }
  107.  
  108. points_func natChoosePointsFunction(GLcontext * ctx)
  109. {
  110.   /*
  111.    * Examine the current rendering state and return a pointer to a 
  112.    * fast point-rendering function if possible. 
  113.    */
  114.  
  115.   DEBUGOUT(1, "natChoosePointsFunction()\n");
  116.  
  117.   if ((ctx->Point.Size == 1.0) &&
  118.       (!ctx->Point.SmoothFlag) &&
  119.       (ctx->RasterMask == 0) &&                            /* what means rastermask really? */
  120.       (!ctx->Texture.Enabled))
  121.     return natFastPointsFunction;
  122.  
  123.   return NULL;
  124. }
  125.  
  126. points_func natChoosePointsFunctionDB(GLcontext * ctx)
  127. {
  128.   DEBUGOUT(1, "natChoosePointsFunctionDB()\n");
  129.  
  130.   return NULL;
  131. }
  132.