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/bitmap.c

    r2938 r3598  
    1 /* $Id: bitmap.c,v 1.1 2000-02-29 00:49:59 sandervl Exp $ */
     1/* $Id: bitmap.c,v 1.2 2000-05-23 20:40:24 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.
     
    2626
    2727
    28 
    29 
    30 
    3128#ifdef PC_HEADER
    3229#include "all.h"
    3330#else
    34 #ifndef XFree86Server
    35 #include <assert.h>
    36 #include <stdlib.h>
    37 #include <stdio.h>
    38 #include <string.h>
    39 #else
    40 #include "GL/xf86glx.h"
    41 #endif
     31#include "glheader.h"
    4232#include "bitmap.h"
     33#include "state.h"
    4334#include "context.h"
    4435#include "feedback.h"
     
    5445
    5546/*
    56  * Render bitmap data.
     47 * Render a bitmap.
    5748 */
    58 static void render_bitmap( GLcontext *ctx, GLint px, GLint py,
    59                            GLsizei width, GLsizei height,
    60                            const struct gl_pixelstore_attrib *unpack,
    61                            const GLubyte *bitmap )
     49static void
     50render_bitmap( GLcontext *ctx, GLint px, GLint py,
     51               GLsizei width, GLsizei height,
     52               const struct gl_pixelstore_attrib *unpack,
     53               const GLubyte *bitmap )
    6254{
    6355   struct pixel_buffer *PB = ctx->PB;
    6456   GLint row, col;
    65    GLint pz;
     57   GLdepth fragZ;
    6658
    6759   ASSERT(ctx->RenderMode == GL_RENDER);
     
    6961   if (!bitmap) {
    7062      return;  /* NULL bitmap is legal, a no-op */
    71    }
    72 
    73    if (ctx->NewState) {
    74       gl_update_state(ctx);
    75       gl_reduced_prim_change( ctx, GL_BITMAP );
    7663   }
    7764
     
    8976   }
    9077
    91    pz = (GLint) ( ctx->Current.RasterPos[2] * DEPTH_SCALE );
     78   fragZ = (GLdepth) ( ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
    9279
    9380   for (row=0; row<height; row++) {
    94       const GLubyte *src = (const GLubyte *) gl_pixel_addr_in_image( unpack,
     81      const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack,
    9582                 bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
    9683
    9784      if (unpack->LsbFirst) {
    9885         /* Lsb first */
    99          GLubyte bitmask = 1;
     86         GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
    10087         for (col=0; col<width; col++) {
    101             if (*src & bitmask) {
    102                PB_WRITE_PIXEL( PB, px+col, py+row, pz );
    103             }
    104             bitmask = bitmask << 1;
    105             if (bitmask == 0U) {
     88            if (*src & mask) {
     89               PB_WRITE_PIXEL( PB, px+col, py+row, fragZ );
     90            }
     91            if (mask == 128U) {
    10692               src++;
    107                bitmask = 1U;
     93               mask = 1U;
     94            }
     95            else {
     96               mask = mask << 1;
    10897            }
    10998         }
     
    112101
    113102         /* get ready for next row */
    114          if (bitmask != 1)
     103         if (mask != 1)
    115104            src++;
    116105      }
    117106      else {
    118107         /* Msb first */
    119          GLubyte bitmask = 128;
     108         GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
    120109         for (col=0; col<width; col++) {
    121             if (*src & bitmask) {
    122                PB_WRITE_PIXEL( PB, px+col, py+row, pz );
    123             }
    124             bitmask = bitmask >> 1;
    125             if (bitmask == 0U) {
     110            if (*src & mask) {
     111               PB_WRITE_PIXEL( PB, px+col, py+row, fragZ );
     112            }
     113            if (mask == 1U) {
    126114               src++;
    127                bitmask = 128U;
     115               mask = 128U;
     116            }
     117            else {
     118               mask = mask >> 1;
    128119            }
    129120         }
     
    132123
    133124         /* get ready for next row */
    134          if (bitmask!=128)
     125         if (mask != 128)
    135126            src++;
    136127      }
     
    145136 * Execute a glBitmap command.
    146137 */
    147 void gl_Bitmap( GLcontext *ctx,
    148                 GLsizei width, GLsizei height,
    149                 GLfloat xorig, GLfloat yorig,
    150                 GLfloat xmove, GLfloat ymove,
    151                 const GLubyte *bitmap,
    152                 const struct gl_pixelstore_attrib *packing )
     138void
     139_mesa_Bitmap( GLsizei width, GLsizei height,
     140              GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove,
     141              const GLubyte *bitmap )
    153142{
     143   GET_CURRENT_CONTEXT(ctx);
    154144   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBitmap");
    155145
     
    165155
    166156   if (ctx->RenderMode==GL_RENDER) {
    167       GLint x = (GLint) ( (ctx->Current.RasterPos[0] - xorig) + 0.0F );
    168       GLint y = (GLint) ( (ctx->Current.RasterPos[1] - yorig) + 0.0F );
    169       GLboolean completed = GL_FALSE;
    170       if (ctx->Driver.Bitmap) {
    171          /* let device driver try to render the bitmap */
    172          completed = (*ctx->Driver.Bitmap)( ctx, x, y, width, height,
    173                                             packing, bitmap );
    174       }
    175       if (!completed) {
    176          /* use generic function */
    177          render_bitmap( ctx, x, y, width, height, packing, bitmap );
     157      if (bitmap) {
     158         GLint x = (GLint) ( (ctx->Current.RasterPos[0] - xorig) + 0.0F );
     159         GLint y = (GLint) ( (ctx->Current.RasterPos[1] - yorig) + 0.0F );
     160         GLboolean completed = GL_FALSE;
     161
     162         if (ctx->NewState) {
     163            gl_update_state(ctx);
     164            gl_reduced_prim_change( ctx, GL_BITMAP );
     165         }
     166
     167         if (ctx->PB->primitive!=GL_BITMAP) {   /* A.W. 1.1.2000 */
     168            gl_reduced_prim_change( ctx, GL_BITMAP );
     169         }
     170
     171         if (ctx->Driver.Bitmap) {
     172            /* let device driver try to render the bitmap */
     173            completed = (*ctx->Driver.Bitmap)( ctx, x, y, width, height,
     174                                               &ctx->Unpack, bitmap );
     175         }
     176         if (!completed) {
     177            /* use generic function */
     178            render_bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap );
     179         }
    178180      }
    179181   }
     
    195197      gl_feedback_vertex( ctx,
    196198                          ctx->Current.RasterPos,
    197                           color, ctx->Current.RasterIndex, texcoord );
     199                          color, ctx->Current.RasterIndex, texcoord );
    198200   }
    199201   else if (ctx->RenderMode==GL_SELECT) {
Note: See TracChangeset for help on using the changeset viewer.