texFormat was a random value in _mesa_store_teximage3d(), fix by undoing last changes
[mesa.git] / src / mesa / main / colortab.c
index c3ba3c50c9d6dd795a6b6ff7fe474b66e89c533c..5a50ae50e66cf456988d6f8f1770ff700f2c992c 100644 (file)
@@ -1,21 +1,21 @@
-/* $Id: colortab.c,v 1.36 2001/03/07 05:06:11 brianp Exp $ */
+/* $Id: colortab.c,v 1.38 2001/03/19 02:25:35 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
  * Version:  3.5
- * 
+ *
  * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included
  * in all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -184,7 +184,7 @@ set_component_sizes( struct gl_color_table *table )
 
 
 
-void 
+void
 _mesa_ColorTable( GLenum target, GLenum internalFormat,
                   GLsizei width, GLenum format, GLenum type,
                   const GLvoid *data )
@@ -424,7 +424,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
          (*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
       }
    }
-   
+
    ctx->NewState |= _NEW_PIXEL;
 }
 
@@ -598,7 +598,7 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
          (*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
       }
    }
-   
+
    ctx->NewState |= _NEW_PIXEL;
 }
 
@@ -609,28 +609,11 @@ void
 _mesa_CopyColorTable(GLenum target, GLenum internalformat,
                      GLint x, GLint y, GLsizei width)
 {
-   GLchan data[MAX_WIDTH][4];
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
    /* Select buffer to read from */
-   (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
-                                 ctx->Pixel.DriverReadBuffer );
-
-   if (width > MAX_WIDTH)
-      width = MAX_WIDTH;
-
-   /* read the data from framebuffer */
-   RENDER_START(ctx);
-   _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
-   RENDER_FINISH(ctx);
-
-   /* Restore reading from draw buffer (the default) */
-   (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
-                                 ctx->Color.DriverDrawBuffer );
-
-   _mesa_ColorTable(target, internalformat, width,
-                    GL_RGBA, GL_UNSIGNED_BYTE, data);
+   ctx->Driver.CopyColorTable( ctx, target, internalformat, x, y, width );
 }
 
 
@@ -640,27 +623,10 @@ void
 _mesa_CopyColorSubTable(GLenum target, GLsizei start,
                         GLint x, GLint y, GLsizei width)
 {
-   GLchan data[MAX_WIDTH][4];
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
-   /* Select buffer to read from */
-   (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
-                                 ctx->Pixel.DriverReadBuffer );
-
-   if (width > MAX_WIDTH)
-      width = MAX_WIDTH;
-
-   /* read the data from framebuffer */
-   RENDER_START(ctx);
-   _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
-   RENDER_FINISH(ctx);
-
-   /* Restore reading from draw buffer (the default) */
-   (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
-                                 ctx->Color.DriverDrawBuffer );
-
-   _mesa_ColorSubTable(target, start, width, GL_RGBA, GL_UNSIGNED_BYTE, data);
+   ctx->Driver.CopyColorSubTable( ctx, target, start, x, y, width );
 }