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 / natFastLines.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-23  |  2.8 KB  |  99 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. #ifdef    TRYTEST
  26. #include "natFastLinesDBn.c"
  27. #include "natFastLinesDB.c"
  28. #endif
  29.  
  30. /**********************************************************************/
  31. /*****            Accelerated point, line, polygon rendering      *****/
  32. /**********************************************************************/
  33.  
  34. void natFastLineFunction(GLcontext * ctx, GLuint v0, GLuint v1, GLuint pv)
  35. {
  36.   amigaMesaContext amesa;
  37.   struct RastPort *rp;
  38.   struct vertex_buffer *VB;
  39.   int x, y;
  40.  
  41.   amesa = (amigaMesaContext) ctx->DriverCtx;
  42.   VB = ctx->VB;
  43.   rp = amesa->rp;
  44.  
  45.   DEBUGOUT(1, "natFastLineFunction\n");
  46.  
  47.   if (!(amesa->visual->flags & VISUAL_RGBMODE))
  48.     SetAPen(rp, GetRGBP(amesa, VB->IndexPtr->data[pv]));
  49.   else
  50.     SetAPen(rp, PL_RGBA(amesa, VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2], 0, 0));
  51.  
  52.   x = FIXx((int)(VB->Win.data[v0][0]));
  53.   y = FIXy((int)(VB->Win.data[v0][1]));
  54.   DEBUGOUT(8, " Move(%d, %d)\n", x, y);
  55.   Move(rp, x, y);
  56.  
  57.   x = FIXx((int)(VB->Win.data[v1][0]));
  58.   y = FIXy((int)(VB->Win.data[v1][1]));
  59.   DEBUGOUT(8, " Draw(%d, %d)\n", x, y);
  60.   Draw(rp, x, y);
  61. }
  62.  
  63. line_func natChooseLineFunction(GLcontext * ctx)
  64. {
  65.   /*
  66.    * Examine the current rendering state and return a pointer to a 
  67.    * fast line-rendering function if possible. 
  68.    */
  69.  
  70.   DEBUGOUT(1, "natChooseLineFunction()\n");
  71.  
  72.   if (!IS_DITHER((amigaMesaContext) ctx->DriverCtx) &&
  73.       (ctx->Line.Width == 1.0) &&
  74.       (!ctx->Line.SmoothFlag) &&
  75.       (!ctx->Line.StippleFlag) &&
  76.       (ctx->Light.ShadeModel == GL_FLAT) &&
  77.       (ctx->RasterMask == 0) &&                            /* what means rastermask really? */
  78.       (!ctx->Texture.Enabled))
  79.     return natFastLineFunction;
  80. #ifdef    TRYTEST
  81.   else if (preset.tryTest)
  82.     return test_natChooseLineFunction(ctx);
  83. #endif
  84.  
  85.   return NULL;
  86. }
  87.  
  88. line_func natChooseLineFunctionDB(GLcontext * ctx)
  89. {
  90.   DEBUGOUT(1, "natChooseLineFunctionDB()\n");
  91.  
  92. #ifdef    TRYTEST
  93.   if (preset.tryTest)
  94.     return test_natChooseLineFunctionDB(ctx);
  95. #endif
  96.  
  97.   return NULL;
  98. }
  99.