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 / natFastLinesDB.E < prev    next >
Encoding:
Text File  |  1999-09-04  |  4.1 KB  |  138 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. #include "natFastLinesDB8.E"
  26. #include "natFastLinesDBD.E"
  27. #include "natFastLinesDBG.E"
  28.  
  29. /**********************************************************************/
  30. /*****                   Optimized line rendering                 *****/
  31. /**********************************************************************/
  32.  
  33. /* Draw a flat-shaded, RGB line into an osmesa buffer. */
  34. void natFlatCI32LineDB(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  35. {
  36.   GLubyte *db;
  37.   GLubyte pixel;
  38.  
  39.   db = dbPenGet(((amigaMesaContext) ctx->DriverCtx));
  40.   pixel = GetRGBP(((amigaMesaContext) ctx->DriverCtx), ctx->VB->IndexPtr->data[pvert]);
  41.  
  42. #define INTERP_XY    1
  43. #define CLIP_HACK    1
  44. #define PLOT(X,Y)    *dbPen(db, X, Y) = pixel
  45.  
  46. #include "../../linetemp.h"
  47. }
  48.  
  49. /* Draw a flat-shaded, Z-less, RGB line into an osmesa buffer. */
  50. void natFlatCI32ZLineDB(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  51. {
  52.   GLubyte *db;
  53.   GLubyte pixel;
  54.  
  55.   db = dbPenGet(((amigaMesaContext) ctx->DriverCtx));
  56.   pixel = GetRGBP(((amigaMesaContext) ctx->DriverCtx), ctx->VB->IndexPtr->data[pvert]);
  57.  
  58. #define INTERP_XY    1
  59. #define INTERP_Z    1
  60. #define CLIP_HACK    1
  61. #define PLOT(X,Y)        \
  62.   if (Z < *zPtr) {        \
  63.     *dbPen(db, X, Y) = pixel;    \
  64.     *zPtr = Z;            \
  65.   }
  66.  
  67. #include "../../linetemp.h"
  68. }
  69.  
  70. /*
  71.  * Analyze context state to see if we can provide a fast line drawing
  72.  * function, like those in lines.c.  Otherwise, return NULL.
  73.  */
  74. line_func test_natChooseLineFunctionDB(GLcontext * ctx)
  75. {
  76.   GLboolean RGBMode = ctx->Visual->RGBAflag;
  77.   palMode trueColor = ((amigaMesaContext)ctx->DriverCtx)->trueColor;
  78.  
  79.   if (ctx->Line.SmoothFlag)
  80.     return NULL;
  81.   if (ctx->Texture.Enabled)
  82.     return NULL;
  83.   if (ctx->Light.ShadeModel != GL_FLAT)
  84.     return NULL;
  85.   if (ctx->Line.Width != 1.0F)
  86.     return NULL;
  87.   if (ctx->Line.StippleFlag)
  88.     return NULL;
  89.  
  90.   switch (ctx->RasterMask) {
  91.     case 0:
  92.       if (RGBMode)
  93.     return IS_SHIFT(trueColor) ? nat8FlatRGBALineDB :
  94.            IS_MATCH(trueColor) ? natGFlatRGBALineDB :
  95.                      natDFlatRGBALineDB;
  96.       else
  97.     return natFlatCI32LineDB;
  98.       break;
  99.     case DEPTH_BIT:
  100.       if ((ctx->Depth.Func == GL_LESS) &&
  101.       (ctx->Depth.Mask))
  102.     if (RGBMode)
  103.       return IS_SHIFT(trueColor) ? nat8FlatRGBAZLineDB :
  104.          IS_MATCH(trueColor) ? natGFlatRGBAZLineDB :
  105.                        natDFlatRGBAZLineDB;
  106.     else
  107.       return natFlatCI32ZLineDB;
  108.       break;
  109.     case BLEND_BIT:
  110.       if ((ctx->Color.BlendSrc == GL_SRC_ALPHA) &&
  111.       (ctx->Color.BlendDst == GL_ONE_MINUS_SRC_ALPHA) &&
  112.       (ctx->Color.BlendEquation == GL_FUNC_ADD_EXT))
  113.     return IS_SHIFT(trueColor) ? nat8FlatBlendRGBALineDB :
  114.            IS_MATCH(trueColor) ? natGFlatBlendRGBALineDB :
  115.                      natDFlatBlendRGBALineDB;
  116.       break;
  117.     case DEPTH_BIT | BLEND_BIT:
  118.       if ((ctx->Depth.Func == GL_LESS) &&
  119.       (ctx->Color.BlendSrc == GL_SRC_ALPHA) &&
  120.       (ctx->Color.BlendDst == GL_ONE_MINUS_SRC_ALPHA) &&
  121.       (ctx->Color.BlendEquation == GL_FUNC_ADD_EXT)) {
  122.     if (ctx->Depth.Mask)
  123.       return IS_SHIFT(trueColor) ? nat8FlatBlendRGBAZLineWriteDB :
  124.          IS_MATCH(trueColor) ? natGFlatBlendRGBAZLineWriteDB :
  125.                        natDFlatBlendRGBAZLineWriteDB;
  126.     else
  127.       return IS_SHIFT(trueColor) ? nat8FlatBlendRGBAZLineDB :
  128.          IS_MATCH(trueColor) ? natGFlatBlendRGBAZLineDB :
  129.                        natDFlatBlendRGBAZLineDB;
  130.       }
  131.       break;
  132.     default:
  133.       break;
  134.   }
  135.  
  136.   return NULL;
  137. }
  138.