Ignore:
Timestamp:
May 23, 2000, 10:41:28 PM (25 years ago)
Author:
jeroen
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/opengl/mesa/pb.c

    r2938 r3598  
    1 /* $Id: pb.c,v 1.1 2000-02-29 00:50:07 sandervl Exp $ */
     1/* $Id: pb.c,v 1.2 2000-05-23 20:40:42 jeroen Exp $ */
    22
    33/*
    44 * Mesa 3-D graphics library
    5  * Version:  3.1
     5 * Version:  3.3
    66 *
    77 * Copyright (C) 1999  Brian Paul   All Rights Reserved.
     
    3939 * the number of function calls.
    4040 */
    41 /* $XFree86: xc/lib/GL/mesa/src/pb.c,v 1.3 1999/04/04 00:20:28 dawes Exp $ */
    4241
    4342
     
    4544#include "all.h"
    4645#else
    47 #ifndef XFree86Server
    48 #include <stdlib.h>
    49 #include <string.h>
    50 #else
    51 #include "GL/xf86glx.h"
    52 #endif
     46#include "glheader.h"
    5347#include "alpha.h"
    5448#include "alphabuf.h"
     
    6458#include "texture.h"
    6559#include "types.h"
     60#include "mem.h"
    6661#endif
    6762
     
    7469{
    7570   struct pixel_buffer *pb;
    76    pb = (struct pixel_buffer *) calloc(sizeof(struct pixel_buffer), 1);
     71   pb = CALLOC_STRUCT(pixel_buffer);
    7772   if (pb) {
    7873      int i, j;
     
    114109
    115110         if (bufferBit == FRONT_LEFT_BIT)
    116             (*ctx->Driver.SetBuffer)( ctx, GL_FRONT_LEFT);
     111            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
    117112         else if (bufferBit == FRONT_RIGHT_BIT)
    118             (*ctx->Driver.SetBuffer)( ctx, GL_FRONT_RIGHT);
     113            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
    119114         else if (bufferBit == BACK_LEFT_BIT)
    120             (*ctx->Driver.SetBuffer)( ctx, GL_BACK_LEFT);
     115            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
    121116         else
    122             (*ctx->Driver.SetBuffer)( ctx, GL_BACK_RIGHT);
     117            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
    123118
    124119         /* make copy of incoming indexes */
     
    135130
    136131   /* restore default dest buffer */
    137    (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer);
     132   (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer);
    138133}
    139134
     
    160155
    161156         if (bufferBit == FRONT_LEFT_BIT) {
    162             (*ctx->Driver.SetBuffer)( ctx, GL_FRONT_LEFT);
    163             ctx->Buffer->Alpha = ctx->Buffer->FrontLeftAlpha;
     157            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
     158            ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontLeftAlpha;
    164159         }
    165160         else if (bufferBit == FRONT_RIGHT_BIT) {
    166             (*ctx->Driver.SetBuffer)( ctx, GL_FRONT_RIGHT);
    167             ctx->Buffer->Alpha = ctx->Buffer->FrontRightAlpha;
     161            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
     162            ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontRightAlpha;
    168163         }
    169164         else if (bufferBit == BACK_LEFT_BIT) {
    170             (*ctx->Driver.SetBuffer)( ctx, GL_BACK_LEFT);
    171             ctx->Buffer->Alpha = ctx->Buffer->BackLeftAlpha;
     165            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
     166            ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackLeftAlpha;
    172167         }
    173168         else {
    174             (*ctx->Driver.SetBuffer)( ctx, GL_BACK_RIGHT);
    175             ctx->Buffer->Alpha = ctx->Buffer->BackRightAlpha;
     169            (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
     170            ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackRightAlpha;
    176171         }
    177172
     
    183178         }
    184179         else if (ctx->Color.BlendEnabled) {
    185             gl_blend_pixels( ctx, n, x, y, rgbaTmp, mask );
     180            _mesa_blend_pixels( ctx, n, x, y, rgbaTmp, mask );
    186181         }
    187182         if (ctx->Color.SWmasking) {
     
    190185
    191186         (*ctx->Driver.WriteRGBAPixels)( ctx, n, x, y,
    192                                         (const GLubyte (*)[4])rgbaTmp, mask );
     187                                        (const GLubyte (*)[4])rgbaTmp, mask );
    193188         if (ctx->RasterMask & ALPHABUF_BIT) {
    194189            gl_write_alpha_pixels( ctx, n, x, y,
    195                                    (const GLubyte (*)[4])rgbaTmp, mask );
     190                                   (const GLubyte (*)[4])rgbaTmp, mask );
    196191         }
    197192      }
     
    199194
    200195   /* restore default dest buffer */
    201    (void) (*ctx->Driver.SetBuffer)( ctx, ctx->Color.DriverDrawBuffer);
     196   (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer);
    202197}
    203198
     
    239234   /* initialize mask array and clip pixels simultaneously */
    240235   {
    241       GLint xmin = ctx->Buffer->Xmin;
    242       GLint xmax = ctx->Buffer->Xmax;
    243       GLint ymin = ctx->Buffer->Ymin;
    244       GLint ymax = ctx->Buffer->Ymax;
     236      GLint xmin = ctx->DrawBuffer->Xmin;
     237      GLint xmax = ctx->DrawBuffer->Xmax;
     238      GLint ymin = ctx->DrawBuffer->Ymin;
     239      GLint ymax = ctx->DrawBuffer->Ymax;
    245240      GLint *x = PB->x;
    246241      GLint *y = PB->y;
     
    256251       */
    257252      if (PB->mono && ctx->MutablePixels) {
    258         /* Copy mono color to all pixels */
     253        /* Copy mono color to all pixels */
    259254         GLuint i;
    260255         for (i=0; i<PB->count; i++) {
     
    269264      if (ctx->MutablePixels || !PB->mono) {
    270265
    271         if (ctx->Texture.ReallyEnabled) {
     266        if (ctx->Texture.ReallyEnabled) {
    272267            int texUnit;
    273268            for (texUnit=0;texUnit<MAX_TEXTURE_UNITS;texUnit++) {
    274                 gl_texture_pixels( ctx, texUnit,
     269                gl_texture_pixels( ctx, texUnit,
    275270                                   PB->count, PB->s[texUnit], PB->t[texUnit],
    276271                                   PB->u[texUnit], PB->lambda[texUnit],
    277272                                   PB->rgba);
    278273            }
    279         }
     274        }
    280275
    281276         if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR
     
    285280         }
    286281
    287          if (ctx->Fog.Enabled
    288              && (ctx->FogMode == FOG_FRAGMENT || PB->primitive==GL_BITMAP)) {
    289             gl_fog_rgba_pixels( ctx, PB->count, PB->z, PB->rgba );
    290          }
     282         if (ctx->Fog.Enabled
     283             && (ctx->Hint.Fog==GL_NICEST || PB->primitive==GL_BITMAP
     284                 || ctx->Texture.ReallyEnabled)) {
     285            _mesa_fog_rgba_pixels( ctx, PB->count, PB->z, PB->rgba );
     286         }
    291287
    292288         /* Scissoring already done above */
    293289
    294          if (ctx->Color.AlphaEnabled) {
    295             if (gl_alpha_test( ctx, PB->count,
    296                                (const GLubyte (*)[4])PB->rgba, mask )==0) {
    297                goto CleanUp;
    298             }
    299          }
    300 
    301          if (ctx->Stencil.Enabled) {
    302             /* first stencil test */
    303             if (gl_stencil_pixels( ctx, PB->count, PB->x, PB->y, mask )==0) {
    304                goto CleanUp;
    305             }
    306             /* depth buffering w/ stencil */
    307             gl_depth_stencil_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask );
    308          }
    309          else if (ctx->Depth.Test) {
    310             /* regular depth testing */
    311             (*ctx->Driver.DepthTestPixels)( ctx, PB->count, PB->x, PB->y,
    312                                             PB->z, mask );
    313          }
     290         if (ctx->Color.AlphaEnabled) {
     291            if (_mesa_alpha_test( ctx, PB->count,
     292                                  (const GLubyte (*)[4]) PB->rgba, mask )==0) {
     293               goto CleanUp;
     294            }
     295         }
     296
     297         if (ctx->Stencil.Enabled) {
     298            /* first stencil test */
     299            if (gl_stencil_and_depth_test_pixels(ctx, PB->count,
     300                                       PB->x, PB->y, PB->z, mask) == 0) {
     301               goto CleanUp;
     302            }
     303         }
     304         else if (ctx->Depth.Test) {
     305            /* regular depth testing */
     306            _mesa_depth_test_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask );
     307         }
    314308
    315309
     
    326320            }
    327321            else if (ctx->Color.BlendEnabled) {
    328                gl_blend_pixels( ctx, PB->count, PB->x, PB->y, PB->rgba, mask);
     322               _mesa_blend_pixels( ctx, PB->count, PB->x, PB->y, PB->rgba, mask);
    329323            }
    330324            if (ctx->Color.SWmasking) {
     
    334328            (*ctx->Driver.WriteRGBAPixels)( ctx, PB->count, PB->x, PB->y,
    335329                                            (const GLubyte (*)[4]) PB->rgba,
    336                                             mask );
     330                                            mask );
    337331            if (ctx->RasterMask & ALPHABUF_BIT) {
    338332               gl_write_alpha_pixels( ctx, PB->count, PB->x, PB->y,
    339                                       (const GLubyte (*)[4]) PB->rgba, mask );
     333                                      (const GLubyte (*)[4]) PB->rgba, mask );
    340334            }
    341335         }
    342336      }
    343337      else {
    344         /* Same color for all pixels */
     338        /* Same color for all pixels */
    345339
    346340         /* Scissoring already done above */
    347341
    348          if (ctx->Color.AlphaEnabled) {
    349             if (gl_alpha_test( ctx, PB->count,
    350                                (const GLubyte (*)[4]) PB->rgba, mask )==0) {
    351                goto CleanUp;
    352             }
    353          }
    354 
    355          if (ctx->Stencil.Enabled) {
    356             /* first stencil test */
    357             if (gl_stencil_pixels( ctx, PB->count, PB->x, PB->y, mask )==0) {
    358                goto CleanUp;
    359             }
    360             /* depth buffering w/ stencil */
    361             gl_depth_stencil_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask );
    362          }
    363          else if (ctx->Depth.Test) {
    364             /* regular depth testing */
    365             (*ctx->Driver.DepthTestPixels)( ctx, PB->count, PB->x, PB->y, PB->z, mask );
    366          }
     342         if (ctx->Color.AlphaEnabled) {
     343            if (_mesa_alpha_test( ctx, PB->count,
     344                                  (const GLubyte (*)[4]) PB->rgba, mask )==0) {
     345               goto CleanUp;
     346            }
     347         }
     348
     349         if (ctx->Stencil.Enabled) {
     350            /* first stencil test */
     351            if (gl_stencil_and_depth_test_pixels(ctx, PB->count,
     352                                       PB->x, PB->y, PB->z, mask) == 0) {
     353               goto CleanUp;
     354            }
     355         }
     356         else if (ctx->Depth.Test) {
     357            /* regular depth testing */
     358            _mesa_depth_test_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask );
     359         }
    367360
    368361         if (ctx->Color.DrawBuffer == GL_NONE) {
     
    390383            blue  = PB->color[BCOMP];
    391384            alpha = PB->color[ACOMP];
    392             (*ctx->Driver.Color)( ctx, red, green, blue, alpha );
     385            (*ctx->Driver.Color)( ctx, red, green, blue, alpha );
    393386
    394387            (*ctx->Driver.WriteMonoRGBAPixels)( ctx, PB->count, PB->x, PB->y, mask );
     
    408401      /* If we may be writting pixels with different indexes... */
    409402      if (PB->mono && ctx->MutablePixels) {
    410         /* copy index to all pixels */
     403        /* copy index to all pixels */
    411404         GLuint n = PB->count, indx = PB->index;
    412405         GLuint *pbindex = PB->i;
    413406         do {
    414             *pbindex++ = indx;
     407            *pbindex++ = indx;
    415408            n--;
    416         } while (n);
     409        } while (n);
    417410      }
    418411
    419412      if (ctx->MutablePixels || !PB->mono) {
    420413
    421         if (ctx->Fog.Enabled
    422              && (ctx->FogMode==FOG_FRAGMENT || PB->primitive==GL_BITMAP)) {
    423             gl_fog_ci_pixels( ctx, PB->count, PB->z, PB->i );
    424         }
     414        if (ctx->Fog.Enabled
     415             && (ctx->Hint.Fog==GL_NICEST || PB->primitive==GL_BITMAP)) {
     416            _mesa_fog_ci_pixels( ctx, PB->count, PB->z, PB->i );
     417        }
    425418
    426419         /* Scissoring already done above */
    427420
    428          if (ctx->Stencil.Enabled) {
    429             /* first stencil test */
    430             if (gl_stencil_pixels( ctx, PB->count, PB->x, PB->y, mask )==0) {
    431                goto CleanUp;
    432             }
    433             /* depth buffering w/ stencil */
    434             gl_depth_stencil_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask );
    435          }
    436          else if (ctx->Depth.Test) {
    437             /* regular depth testing */
    438             (*ctx->Driver.DepthTestPixels)( ctx, PB->count, PB->x, PB->y, PB->z, mask );
    439          }
     421         if (ctx->Stencil.Enabled) {
     422            /* first stencil test */
     423            if (gl_stencil_and_depth_test_pixels(ctx, PB->count,
     424                                       PB->x, PB->y, PB->z, mask) == 0) {
     425               goto CleanUp;
     426            }
     427         }
     428         else if (ctx->Depth.Test) {
     429            /* regular depth testing */
     430            _mesa_depth_test_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask );
     431         }
    440432
    441433         if (ctx->RasterMask & MULTI_DRAW_BIT) {
     
    459451      }
    460452      else {
    461         /* Same color index for all pixels */
     453        /* Same color index for all pixels */
    462454
    463455         /* Scissoring already done above */
    464456
    465          if (ctx->Stencil.Enabled) {
    466             /* first stencil test */
    467             if (gl_stencil_pixels( ctx, PB->count, PB->x, PB->y, mask )==0) {
    468                goto CleanUp;
    469             }
    470             /* depth buffering w/ stencil */
    471             gl_depth_stencil_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask );
    472          }
    473          else if (ctx->Depth.Test) {
    474             /* regular depth testing */
    475             (*ctx->Driver.DepthTestPixels)( ctx, PB->count, PB->x, PB->y, PB->z, mask );
    476          }
     457         if (ctx->Stencil.Enabled) {
     458            /* first stencil test */
     459            if (gl_stencil_and_depth_test_pixels(ctx, PB->count,
     460                                       PB->x, PB->y, PB->z, mask) == 0) {
     461               goto CleanUp;
     462            }
     463         }
     464         else if (ctx->Depth.Test) {
     465            /* regular depth testing */
     466            _mesa_depth_test_pixels( ctx, PB->count, PB->x, PB->y, PB->z, mask );
     467         }
    477468
    478469         if (ctx->RasterMask & MULTI_DRAW_BIT) {
Note: See TracChangeset for help on using the changeset viewer.