mesa/main: Make FEATURE_dlist follow feature conventions.
[mesa.git] / src / mesa / main / colortab.c
index 610acba3068aeaa42aed4eb61de551342b9be193..5ede76c1fb1a90048ef05233358e0f268424a790 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.1
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
 #include "image.h"
 #include "macros.h"
 #include "state.h"
+#include "teximage.h"
+#include "texstate.h"
+#include "glapi/dispatch.h"
+
+
+#if FEATURE_colortable
 
 
 /**
@@ -178,26 +184,12 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table,
                         GLfloat bScale, GLfloat bBias,
                         GLfloat aScale, GLfloat aBias)
 {
-   if (ctx->Unpack.BufferObj->Name) {
-      /* Get/unpack the color table data from a PBO */
-      GLubyte *buf;
-      if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1,
-                                     format, type, data)) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glColor[Sub]Table(bad PBO access)");
-         return;
-      }
-      buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
-                                              GL_READ_ONLY_ARB,
-                                              ctx->Unpack.BufferObj);
-      if (!buf) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glColor[Sub]Table(PBO mapped)");
-         return;
-      }
-      data = ADD_POINTERS(buf, data);
-   }
-
+   data = _mesa_map_validate_pbo_source(ctx, 
+                                        1, &ctx->Unpack, count, 1, 1,
+                                        format, type, data,
+                                        "glColor[Sub]Table");
+   if (!data)
+      return;
 
    {
       /* convert user-provided data to GLfloat values */
@@ -278,10 +270,7 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table,
       }
    }
 
-   if (ctx->Unpack.BufferObj->Name) {
-      ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
-                              ctx->Unpack.BufferObj);
-   }
+   _mesa_unmap_pbo_source(ctx, &ctx->Unpack);
 }
 
 
@@ -294,7 +283,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
    static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 };
    static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 };
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_texture_object *texObj = NULL;
    struct gl_color_table *table = NULL;
    GLboolean proxy = GL_FALSE;
@@ -305,49 +294,6 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */
 
    switch (target) {
-      case GL_TEXTURE_1D:
-         texObj = texUnit->Current1D;
-         table = &texObj->Palette;
-         break;
-      case GL_TEXTURE_2D:
-         texObj = texUnit->Current2D;
-         table = &texObj->Palette;
-         break;
-      case GL_TEXTURE_3D:
-         texObj = texUnit->Current3D;
-         table = &texObj->Palette;
-         break;
-      case GL_TEXTURE_CUBE_MAP_ARB:
-         if (!ctx->Extensions.ARB_texture_cube_map) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
-            return;
-         }
-         texObj = texUnit->CurrentCubeMap;
-         table = &texObj->Palette;
-         break;
-      case GL_PROXY_TEXTURE_1D:
-         texObj = ctx->Texture.Proxy1D;
-         table = &texObj->Palette;
-         proxy = GL_TRUE;
-         break;
-      case GL_PROXY_TEXTURE_2D:
-         texObj = ctx->Texture.Proxy2D;
-         table = &texObj->Palette;
-         proxy = GL_TRUE;
-         break;
-      case GL_PROXY_TEXTURE_3D:
-         texObj = ctx->Texture.Proxy3D;
-         table = &texObj->Palette;
-         proxy = GL_TRUE;
-         break;
-      case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
-         if (!ctx->Extensions.ARB_texture_cube_map) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
-            return;
-         }
-         texObj = ctx->Texture.ProxyCubeMap;
-         table = &texObj->Palette;
-         break;
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
@@ -396,8 +342,19 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
          proxy = GL_TRUE;
          break;
       default:
-         _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
-         return;
+         /* try texture targets */
+         {
+            struct gl_texture_object *texobj
+               = _mesa_select_tex_object(ctx, texUnit, target);
+            if (texobj) {
+               table = &texobj->Palette;
+               proxy = _mesa_is_proxy_texture(target);
+            }
+            else {
+               _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
+               return;
+            }
+         }
    }
 
    assert(table);
@@ -414,7 +371,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
       return;
    }
 
-   if (width < 0 || (width != 0 && _mesa_bitcount(width) != 1)) {
+   if (width < 0 || (width != 0 && !_mesa_is_pow_two(width))) {
       /* error */
       if (proxy) {
          table->Size = 0;
@@ -491,7 +448,7 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
    static const GLfloat one[4] = { 1.0, 1.0, 1.0, 1.0 };
    static const GLfloat zero[4] = { 0.0, 0.0, 0.0, 0.0 };
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_texture_object *texObj = NULL;
    struct gl_color_table *table = NULL;
    const GLfloat *scale = one, *bias = zero;
@@ -499,26 +456,6 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
    switch (target) {
-      case GL_TEXTURE_1D:
-         texObj = texUnit->Current1D;
-         table = &texObj->Palette;
-         break;
-      case GL_TEXTURE_2D:
-         texObj = texUnit->Current2D;
-         table = &texObj->Palette;
-         break;
-      case GL_TEXTURE_3D:
-         texObj = texUnit->Current3D;
-         table = &texObj->Palette;
-         break;
-      case GL_TEXTURE_CUBE_MAP_ARB:
-         if (!ctx->Extensions.ARB_texture_cube_map) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
-            return;
-         }
-         texObj = texUnit->CurrentCubeMap;
-         table = &texObj->Palette;
-         break;
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
@@ -547,8 +484,15 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
          bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
          break;
       default:
-         _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
-         return;
+         /* try texture targets */
+         texObj = _mesa_select_tex_object(ctx, texUnit, target);
+         if (texObj && !_mesa_is_proxy_texture(target)) {
+            table = &texObj->Palette;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
+            return;
+         }
    }
 
    assert(table);
@@ -596,37 +540,44 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
 
 
 
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_CopyColorTable(GLenum target, GLenum internalformat,
                      GLint x, GLint y, GLsizei width)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
-   /* Select buffer to read from */
+   if (!ctx->ReadBuffer->_ColorReadBuffer) {
+      return;      /* no readbuffer - OK */
+   }
+
    ctx->Driver.CopyColorTable( ctx, target, internalformat, x, y, width );
 }
 
 
 
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_CopyColorSubTable(GLenum target, GLsizei start,
                         GLint x, GLint y, GLsizei width)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
+   if (!ctx->ReadBuffer->_ColorReadBuffer) {
+      return;      /* no readbuffer - OK */
+   }
+
    ctx->Driver.CopyColorSubTable( ctx, target, start, x, y, width );
 }
 
 
 
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_GetColorTable( GLenum target, GLenum format,
                      GLenum type, GLvoid *data )
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_color_table *table = NULL;
    GLfloat rgba[MAX_COLOR_TABLE_SIZE][4];
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -636,22 +587,6 @@ _mesa_GetColorTable( GLenum target, GLenum format,
    }
 
    switch (target) {
-      case GL_TEXTURE_1D:
-         table = &texUnit->Current1D->Palette;
-         break;
-      case GL_TEXTURE_2D:
-         table = &texUnit->Current2D->Palette;
-         break;
-      case GL_TEXTURE_3D:
-         table = &texUnit->Current3D->Palette;
-         break;
-      case GL_TEXTURE_CUBE_MAP_ARB:
-         if (!ctx->Extensions.ARB_texture_cube_map) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
-            return;
-         }
-         table = &texUnit->CurrentCubeMap->Palette;
-         break;
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
@@ -672,8 +607,18 @@ _mesa_GetColorTable( GLenum target, GLenum format,
          table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX];
          break;
       default:
-         _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
-         return;
+         /* try texture targets */
+         {
+            struct gl_texture_object *texobj
+               = _mesa_select_tex_object(ctx, texUnit, target);
+            if (texobj && !_mesa_is_proxy_texture(target)) {
+               table = &texobj->Palette;
+            }
+            else {
+               _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
+               return;
+            }
+         }
    }
 
    ASSERT(table);
@@ -746,100 +691,59 @@ _mesa_GetColorTable( GLenum target, GLenum format,
       return;
    }
 
-   if (ctx->Pack.BufferObj->Name) {
-      /* pack color table into PBO */
-      GLubyte *buf;
-      if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1,
-                                     format, type, data)) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glGetColorTable(invalid PBO access)");
-         return;
-      }
-      buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
-                                              GL_WRITE_ONLY_ARB,
-                                              ctx->Pack.BufferObj);
-      if (!buf) {
-         /* buffer is already mapped - that's an error */
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glGetColorTable(PBO is mapped)");
-         return;
-      }
-      data = ADD_POINTERS(buf, data);
-   }
+   data = _mesa_map_validate_pbo_dest(ctx, 
+                                      1, &ctx->Pack, table->Size, 1, 1,
+                                      format, type, data,
+                                      "glGetColorTable");
+   if (!data)
+      return;
 
    _mesa_pack_rgba_span_float(ctx, table->Size, rgba,
                               format, type, data, &ctx->Pack, 0x0);
 
-   if (ctx->Pack.BufferObj->Name) {
-      ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
-                              ctx->Pack.BufferObj);
-   }
+   _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
 }
 
 
 
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 {
+   GLfloat *scale, *bias;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
    switch (target) {
-      case GL_COLOR_TABLE_SGI:
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION], params);
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION], params);
-         }
-         else {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
-            return;
-         }
-         break;
-      case GL_TEXTURE_COLOR_TABLE_SGI:
-         if (!ctx->Extensions.SGI_texture_color_table) {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
-            return;
-         }
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            COPY_4V(ctx->Pixel.TextureColorTableScale, params);
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            COPY_4V(ctx->Pixel.TextureColorTableBias, params);
-         }
-         else {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
-            return;
-         }
-         break;
-      case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION], params);
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION], params);
-         }
-         else {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
-            return;
-         }
-         break;
-      case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
-         if (pname == GL_COLOR_TABLE_SCALE_SGI) {
-            COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX], params);
-         }
-         else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
-            COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX], params);
-         }
-         else {
-            _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
-            return;
-         }
-         break;
-      default:
-         _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
-         return;
+   case GL_COLOR_TABLE_SGI:
+      scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION];
+      bias  = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION];
+      break;
+   case GL_TEXTURE_COLOR_TABLE_SGI:
+      scale = ctx->Pixel.TextureColorTableScale;
+      bias  = ctx->Pixel.TextureColorTableBias;
+      break;
+   case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+      scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION];
+      bias  = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION];
+      break;
+   case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+      scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX];
+      bias  = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX];
+      break;
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
+      return;
+   }
+
+   if (pname == GL_COLOR_TABLE_SCALE_SGI) {
+      COPY_4V(scale, params);
+   }
+   else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
+      COPY_4V(bias, params);
+   }
+   else {
+      _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
+      return;
    }
 
    ctx->NewState |= _NEW_PIXEL;
@@ -847,7 +751,7 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
 
 
 
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
 {
    GLfloat fparams[4];
@@ -870,49 +774,15 @@ _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
 
 
 
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_color_table *table = NULL;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    switch (target) {
-      case GL_TEXTURE_1D:
-         table = &texUnit->Current1D->Palette;
-         break;
-      case GL_TEXTURE_2D:
-         table = &texUnit->Current2D->Palette;
-         break;
-      case GL_TEXTURE_3D:
-         table = &texUnit->Current3D->Palette;
-         break;
-      case GL_TEXTURE_CUBE_MAP_ARB:
-         if (!ctx->Extensions.ARB_texture_cube_map) {
-            _mesa_error(ctx, GL_INVALID_ENUM,
-                        "glGetColorTableParameterfv(target)");
-            return;
-         }
-         table = &texUnit->CurrentCubeMap->Palette;
-         break;
-      case GL_PROXY_TEXTURE_1D:
-         table = &ctx->Texture.Proxy1D->Palette;
-         break;
-      case GL_PROXY_TEXTURE_2D:
-         table = &ctx->Texture.Proxy2D->Palette;
-         break;
-      case GL_PROXY_TEXTURE_3D:
-         table = &ctx->Texture.Proxy3D->Palette;
-         break;
-      case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
-         if (!ctx->Extensions.ARB_texture_cube_map) {
-            _mesa_error(ctx, GL_INVALID_ENUM,
-                        "glGetColorTableParameterfv(target)");
-            return;
-         }
-         table = &ctx->Texture.ProxyCubeMap->Palette;
-         break;
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
@@ -981,8 +851,19 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
          table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
          break;
       default:
-         _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)");
-         return;
+         /* try texture targets */
+         {
+            struct gl_texture_object *texobj
+               = _mesa_select_tex_object(ctx, texUnit, target);
+            if (texobj) {
+               table = &texobj->Palette;
+            }
+            else {
+               _mesa_error(ctx, GL_INVALID_ENUM,
+                           "glGetColorTableParameterfv(target)");
+               return;
+            }
+         }
    }
 
    assert(table);
@@ -1020,49 +901,15 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
 
 
 
-void GLAPIENTRY
+static void GLAPIENTRY
 _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
    struct gl_color_table *table = NULL;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    switch (target) {
-      case GL_TEXTURE_1D:
-         table = &texUnit->Current1D->Palette;
-         break;
-      case GL_TEXTURE_2D:
-         table = &texUnit->Current2D->Palette;
-         break;
-      case GL_TEXTURE_3D:
-         table = &texUnit->Current3D->Palette;
-         break;
-      case GL_TEXTURE_CUBE_MAP_ARB:
-         if (!ctx->Extensions.ARB_texture_cube_map) {
-            _mesa_error(ctx, GL_INVALID_ENUM,
-                        "glGetColorTableParameteriv(target)");
-            return;
-         }
-         table = &texUnit->CurrentCubeMap->Palette;
-         break;
-      case GL_PROXY_TEXTURE_1D:
-         table = &ctx->Texture.Proxy1D->Palette;
-         break;
-      case GL_PROXY_TEXTURE_2D:
-         table = &ctx->Texture.Proxy2D->Palette;
-         break;
-      case GL_PROXY_TEXTURE_3D:
-         table = &ctx->Texture.Proxy3D->Palette;
-         break;
-      case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
-         if (!ctx->Extensions.ARB_texture_cube_map) {
-            _mesa_error(ctx, GL_INVALID_ENUM,
-                        "glGetColorTableParameteriv(target)");
-            return;
-         }
-         table = &ctx->Texture.ProxyCubeMap->Palette;
-         break;
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          table = &ctx->Texture.Palette;
          break;
@@ -1161,8 +1008,19 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
          table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX];
          break;
       default:
-         _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)");
-         return;
+         /* Try texture targets */
+         {
+            struct gl_texture_object *texobj
+               = _mesa_select_tex_object(ctx, texUnit, target);
+            if (texobj) {
+               table = &texobj->Palette;
+            }
+            else {
+               _mesa_error(ctx, GL_INVALID_ENUM,
+                           "glGetColorTableParameteriv(target)");
+               return;
+            }
+         }
    }
 
    assert(table);
@@ -1198,6 +1056,25 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
    }
 }
 
+
+void
+_mesa_init_colortable_dispatch(struct _glapi_table *disp)
+{
+   SET_ColorSubTable(disp, _mesa_ColorSubTable);
+   SET_ColorTable(disp, _mesa_ColorTable);
+   SET_ColorTableParameterfv(disp, _mesa_ColorTableParameterfv);
+   SET_ColorTableParameteriv(disp, _mesa_ColorTableParameteriv);
+   SET_CopyColorSubTable(disp, _mesa_CopyColorSubTable);
+   SET_CopyColorTable(disp, _mesa_CopyColorTable);
+   SET_GetColorTable(disp, _mesa_GetColorTable);
+   SET_GetColorTableParameterfv(disp, _mesa_GetColorTableParameterfv);
+   SET_GetColorTableParameteriv(disp, _mesa_GetColorTableParameteriv);
+}
+
+
+#endif /* FEATURE_colortable */
+
+
 /**********************************************************************/
 /*****                      Initialization                        *****/
 /**********************************************************************/