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