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 / wrpDisplay / wrpFastPoints.c < prev    next >
Encoding:
Text File  |  1999-09-04  |  4.6 KB  |  163 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 wrpDrawPointFlat(GLcontext * ctx, GLuint first, GLuint last)
  30. {
  31.   struct TDdriver *TDdriver;
  32.   struct vertex_buffer *VB = ctx->VB;
  33.   W3D_Context *TDcontext;
  34.   W3D_Point po;
  35.   GLint i;
  36.  
  37.   DEBUGOUT(1, "wrpDrawPointFlat()\n");
  38.  
  39.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  40.   TDcontext = TDdriver->td_ctx;
  41.  
  42.   LockHardware(TDdriver, TDcontext);
  43.  
  44.   po.tex = TDdriver->TDtex;
  45.   po.pointsize = (W3D_Float) ctx->Point.Size;
  46.  
  47.   for (i = first; i <= last; i++) {
  48.     W3D_Color TDcol;
  49.  
  50.     TC_Color(TDcol, VB->ColorPtr->data[first][0], VB->ColorPtr->data[first][1], VB->ColorPtr->data[first][2], VB->ColorPtr->data[first][3]);
  51.     W3D_SetCurrentColor(TDcontext, &TDcol);
  52.  
  53.     TDdriver->CopyVertex(&po.v1, &TDdriver->vbuffer[i]);
  54.  
  55.     if (W3D_DrawPoint(TDcontext, &po) != W3D_SUCCESS)
  56.       ClrF(TDdriver->flags, TD_ACTIVE);
  57.   }
  58.  
  59.   SetF(TDdriver->flags, TD_DIRTY);
  60. }
  61.  
  62. void wrpDrawPointSmooth(GLcontext * ctx, GLuint first, GLuint last)
  63. {
  64.   struct TDdriver *TDdriver;
  65.   W3D_Context *TDcontext;
  66.   W3D_Point po;
  67.   GLint i;
  68.  
  69.   DEBUGOUT(1, "wrpDrawPointSmooth()\n");
  70.  
  71.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  72.   TDcontext = TDdriver->td_ctx;
  73.  
  74.   LockHardware(TDdriver, TDcontext);
  75.  
  76.   po.tex = TDdriver->TDtex;
  77.   po.pointsize = (W3D_Float) ctx->Point.Size;
  78.  
  79.   for (i = first; i <= last; i++) {
  80.     TDdriver->CopyVertex(&po.v1, &TDdriver->vbuffer[i]);
  81.  
  82.     if (W3D_DrawPoint(TDcontext, &po) != W3D_SUCCESS)
  83.       ClrF(TDdriver->flags, TD_ACTIVE);
  84.   }
  85.  
  86.   SetF(TDdriver->flags, TD_DIRTY);
  87. }
  88.  
  89. void wrpDrawPointSmoothTwo(GLcontext * ctx, GLuint first, GLuint last)
  90. {
  91.   struct TDdriver *TDdriver;
  92.   struct vertex_buffer *VB = ctx->VB;
  93.   W3D_Context *TDcontext;
  94.   W3D_Point po;
  95.   GLint i;
  96.  
  97.   DEBUGOUT(1, "wrpDrawPointSmoothTwo()\n");
  98.  
  99.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  100.   TDcontext = TDdriver->td_ctx;
  101.  
  102.   LockHardware(TDdriver, TDcontext);
  103.  
  104.   po.tex = TDdriver->TDtex;
  105.   po.pointsize = (W3D_Float) ctx->Point.Size;
  106.  
  107.   for (i = first; i <= last; i++) {
  108.     TDdriver->CopyVertex(&po.v1, &TDdriver->vbuffer[i]);
  109.  
  110.     TC_Color(po.v1.color, VB->ColorPtr->data[i][0], VB->ColorPtr->data[i][1], VB->ColorPtr->data[i][2], VB->ColorPtr->data[i][3]);
  111.  
  112.     if (W3D_DrawPoint(TDcontext, &po) != W3D_SUCCESS)
  113.       ClrF(TDdriver->flags, TD_ACTIVE);
  114.   }
  115.  
  116.   SetF(TDdriver->flags, TD_DIRTY);
  117. }
  118.  
  119. points_func wrpChoosePointsFunction(GLcontext * ctx)
  120. {
  121.   struct TDdriver *TDdriver;
  122.   W3D_Context *TDcontext;
  123.  
  124.   DEBUGOUT(1, "wrpChoosePointsFunction()\n");
  125.  
  126.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  127.   TDcontext = TDdriver->td_ctx;
  128.  
  129.   if (W3D_Query(TDcontext, W3D_Q_DRAW_POINT, NULL) != W3D_FULLY_SUPPORTED)
  130.     return NULL;
  131.  
  132.   if (ctx->Point.SmoothFlag)
  133.     if (W3D_Query(TDcontext, W3D_Q_ANTI_POINT, NULL) != W3D_FULLY_SUPPORTED)
  134.       return NULL;
  135.  
  136.   if ((ctx->Color.AlphaEnabled) || (ctx->Color.BlendEnabled) ||
  137.       (ctx->Fog.Enabled) || (ctx->Color.IndexLogicOpEnabled) ||
  138.       (ctx->Color.ColorLogicOpEnabled))
  139.     if (W3D_Query(TDcontext, W3D_Q_DRAW_POINT_FX, NULL) != W3D_FULLY_SUPPORTED)
  140.       return NULL;
  141.  
  142.   if (ctx->Texture.Enabled)
  143.     if (W3D_Query(TDcontext, W3D_Q_DRAW_POINT_TEX, NULL) != W3D_FULLY_SUPPORTED)
  144.       return NULL;
  145.  
  146.   if (!(ctx->Point.Params[0] == 1.0 && ctx->Point.Params[1] == 0.0 &&
  147.     ctx->Point.Params[2] == 0.0))
  148.     return NULL;
  149.  
  150.   if (ctx->Point.Size != 1.0f)
  151.     if (W3D_Query(TDcontext, W3D_Q_DRAW_POINT_X, NULL) != W3D_FULLY_SUPPORTED)
  152.       return NULL;
  153.  
  154.   if (ctx->Light.ShadeModel == GL_SMOOTH) {
  155.     if (ctx->Light.Model.TwoSide)
  156.       return wrpDrawPointSmoothTwo;
  157.  
  158.     return wrpDrawPointSmooth;
  159.   }
  160.  
  161.   return wrpDrawPointFlat;
  162. }
  163.