added GL_SGIX/SGIS_pixel_texture
[mesa.git] / src / mesa / main / drawpix.c
index 49321a94593755137b880c3be5f95a6dd92aec9a..23479bf321f2b4d7ecd5a2fc186801212dfe26ac 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.14 2000/03/03 17:54:56 brianp Exp $ */
+/* $Id: drawpix.c,v 1.17 2000/04/07 16:27:26 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
 #include "mem.h"
 #include "mmath.h"
 #include "pixel.h"
+#include "pixeltex.h"
 #include "span.h"
 #include "state.h"
 #include "stencil.h"
+#include "texture.h"
 #include "types.h"
 #include "zoom.h"
 #endif
@@ -125,6 +127,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
        && ctx->Pixel.AlphaBias==0.0 && ctx->Pixel.AlphaScale==1.0
        && ctx->Pixel.IndexShift==0 && ctx->Pixel.IndexOffset==0
        && ctx->Pixel.MapColorFlag==0
+       && ctx->Texture.ReallyEnabled == 0
        && unpack->Alignment==1
        && !unpack->SwapBytes
        && !unpack->LsbFirst) {
@@ -425,7 +428,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
     */
    for (row = 0; row < height; row++, y++) {
       GLuint indexes[MAX_WIDTH];
-      const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack,
+      const GLvoid *source = _mesa_image_address(&ctx->Unpack,
                     pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
       _mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT, indexes,
                               type, source, &ctx->Unpack, GL_TRUE);
@@ -471,7 +474,7 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
       GLstencil values[MAX_WIDTH];
       GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte))
                       ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
-      const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack,
+      const GLvoid *source = _mesa_image_address(&ctx->Unpack,
                     pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
       _mesa_unpack_index_span(ctx, drawWidth, destType, values,
                               type, source, &ctx->Unpack, GL_TRUE);
@@ -541,7 +544,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
       GLint row;
       for (row = 0; row < height; row++, y++) {
          GLdepth zspan[MAX_WIDTH];
-         const GLushort *zptr = gl_pixel_addr_in_image(&ctx->Unpack,
+         const GLushort *zptr = _mesa_image_address(&ctx->Unpack,
                 pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
          GLint i;
          for (i = 0; i < width; i++)
@@ -554,7 +557,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
       /* Special case: directly write 32-bit depth values */
       GLint row;
       for (row = 0; row < height; row++, y++) {
-         const GLuint *zptr = gl_pixel_addr_in_image(&ctx->Unpack,
+         const GLuint *zptr = _mesa_image_address(&ctx->Unpack,
                 pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
          gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP );
       }
@@ -564,7 +567,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
       GLint row;
       for (row = 0; row < height; row++, y++) {
          GLdepth zspan[MAX_WIDTH];
-         const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack,
+         const GLvoid *src = _mesa_image_address(&ctx->Unpack,
                 pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
          _mesa_unpack_depth_span( ctx, drawWidth, zspan, type, src,
                                   &ctx->Unpack, GL_TRUE );
@@ -640,11 +643,22 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
       if (width > MAX_WIDTH)
          width = MAX_WIDTH;
       for (row = 0; row < height; row++, y++) {
-         const GLvoid *source = gl_pixel_addr_in_image(unpack,
+         const GLvoid *source = _mesa_image_address(unpack,
                   pixels, width, height, format, type, 0, row, 0);
          _mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba,
                    format, type, source, unpack, GL_TRUE);
 
+         if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
+            GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
+            GLuint unit;
+            /* XXX not sure how multitexture is supposed to work here */
+            for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
+               _mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba,
+                                 s, t, r, q);
+               gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba);
+            }
+         }
+
          if (quickDraw) {
             (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y,
                                           (CONST GLubyte (*)[]) rgba, NULL);
@@ -681,6 +695,8 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
       x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
       y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
 
+      ctx->OcclusionResult = GL_TRUE;
+
       /* see if device driver can do the drawpix */
       if (ctx->Driver.DrawPixels
           && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type,