added GL_SGIX/SGIS_pixel_texture
[mesa.git] / src / mesa / main / colortab.c
index ccec6564610a4c8242389835c899184ee5e5674f..b94dbde8fd747bc0249f9d474050b73001f70a8f 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: colortab.c,v 1.5 1999/11/11 17:50:04 brianp Exp $ */
+/* $Id: colortab.c,v 1.10 2000/03/21 01:03:40 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
  * Version:  3.3
  * 
- * Copyright (C) 1999  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2000  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"),
@@ -112,17 +112,17 @@ decode_internal_format( GLint format )
 
 
 void 
-_mesa_ColorTableEXT( GLenum target, GLenum internalFormat,
-                     GLsizei width, GLenum format, GLenum type,
-                     const GLvoid *table )
+_mesa_ColorTable( GLenum target, GLenum internalFormat,
+                  GLsizei width, GLenum format, GLenum type,
+                  const GLvoid *table )
 {
    GET_CURRENT_CONTEXT(ctx);
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
    struct gl_texture_object *texObj;
-   struct gl_palette *palette;
+   struct gl_color_table *palette;
    GLboolean proxy = GL_FALSE;
 
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTableEXT");
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTable");
 
    switch (target) {
       case GL_TEXTURE_1D:
@@ -157,24 +157,24 @@ _mesa_ColorTableEXT( GLenum target, GLenum internalFormat,
          palette = &ctx->Texture.Palette;
          break;
       default:
-         gl_error(ctx, GL_INVALID_ENUM, "glColorTableEXT(target)");
+         gl_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
          return;
    }
 
    assert(palette);
 
-   if (!gl_is_legal_format_and_type(format, type)) {
-      gl_error(ctx, GL_INVALID_ENUM, "glColorTableEXT(format or type)");
+   if (!_mesa_is_legal_format_and_type(format, type)) {
+      gl_error(ctx, GL_INVALID_ENUM, "glColorTable(format or type)");
       return;
    }
 
    if (decode_internal_format(internalFormat) < 0) {
-      gl_error( ctx, GL_INVALID_ENUM, "glColorTableEXT(internalFormat)" );
+      gl_error( ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)" );
       return;
    }
 
    if (width < 1 || width > MAX_TEXTURE_PALETTE_SIZE || !power_of_two(width)) {
-      gl_error(ctx, GL_INVALID_VALUE, "glColorTableEXT(width)");
+      gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)");
       if (proxy) {
          palette->Size = 0;
          palette->IntFormat = (GLenum) 0;
@@ -209,14 +209,14 @@ _mesa_ColorTableEXT( GLenum target, GLenum internalFormat,
 
 
 void
-_mesa_ColorSubTableEXT( GLenum target, GLsizei start,
-                        GLsizei count, GLenum format, GLenum type,
-                        const GLvoid *table )
+_mesa_ColorSubTable( GLenum target, GLsizei start,
+                     GLsizei count, GLenum format, GLenum type,
+                     const GLvoid *table )
 {
    GET_CURRENT_CONTEXT(ctx);
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
    struct gl_texture_object *texObj;
-   struct gl_palette *palette;
+   struct gl_color_table *palette;
    GLint comps;
    GLubyte *dest;
 
@@ -240,27 +240,27 @@ _mesa_ColorSubTableEXT( GLenum target, GLsizei start,
          palette = &ctx->Texture.Palette;
          break;
       default:
-         gl_error(ctx, GL_INVALID_ENUM, "glColorSubTableEXT(target)");
+         gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
          return;
    }
 
    assert(palette);
 
-   if (!gl_is_legal_format_and_type(format, type)) {
-      gl_error(ctx, GL_INVALID_ENUM, "glColorSubTableEXT(format or type)");
+   if (!_mesa_is_legal_format_and_type(format, type)) {
+      gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(format or type)");
       return;
    }
 
    if (count < 1) {
-      gl_error(ctx, GL_INVALID_VALUE, "glColorSubTableEXT(count)");
+      gl_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)");
       return;
    }
 
-   comps = gl_components_in_format(format);
+   comps = _mesa_components_in_format(format);
    assert(comps > 0);  /* error should be caught sooner */
 
    if (start + count > palette->Size) {
-      gl_error(ctx, GL_INVALID_VALUE, "glColorSubTableEXT(count)");
+      gl_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)");
       return;
    }
    dest = palette->Table + start * comps * sizeof(GLubyte);
@@ -285,16 +285,16 @@ _mesa_ColorSubTableEXT( GLenum target, GLsizei start,
 
 
 void
-_mesa_GetColorTableEXT( GLenum target, GLenum format,
-                        GLenum type, GLvoid *table )
+_mesa_GetColorTable( GLenum target, GLenum format,
+                     GLenum type, GLvoid *table )
 {
    GET_CURRENT_CONTEXT(ctx);
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-   struct gl_palette *palette;
+   struct gl_color_table *palette;
    GLubyte rgba[MAX_TEXTURE_PALETTE_SIZE][4];
    GLint i;
 
-   ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableEXT");
+   ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTable");
 
    switch (target) {
       case GL_TEXTURE_1D:
@@ -310,7 +310,7 @@ _mesa_GetColorTableEXT( GLenum target, GLenum format,
          palette = &ctx->Texture.Palette;
          break;
       default:
-         gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableEXT(target)");
+         gl_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
          return;
    }
 
@@ -366,12 +366,12 @@ _mesa_GetColorTableEXT( GLenum target, GLenum format,
          }
          break;
       default:
-         gl_problem(ctx, "bad palette format in glGetColorTableEXT");
+         gl_problem(ctx, "bad palette format in glGetColorTable");
          return;
    }
 
-   gl_pack_rgba_span(ctx, palette->Size, (const GLubyte (*)[]) rgba,
-                     format, type, table, &ctx->Pack, GL_FALSE);
+   _mesa_pack_rgba_span(ctx, palette->Size, (const GLubyte (*)[]) rgba,
+                        format, type, table, &ctx->Pack, GL_FALSE);
 
    (void) format;
    (void) type;
@@ -381,23 +381,23 @@ _mesa_GetColorTableEXT( GLenum target, GLenum format,
 
 
 void
-_mesa_GetColorTableParameterfvEXT( GLenum target, GLenum pname, GLfloat *params )
+_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
 {
    GLint iparams[10];
-   _mesa_GetColorTableParameterivEXT( target, pname, iparams );
+   _mesa_GetColorTableParameteriv( target, pname, iparams );
    *params = (GLfloat) iparams[0];
 }
 
 
 
 void
-_mesa_GetColorTableParameterivEXT( GLenum target, GLenum pname, GLint *params )
+_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_palette *palette;
+   struct gl_color_table *palette;
 
-   ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameterEXT");
+   ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameter");
 
    switch (target) {
       case GL_TEXTURE_1D:
@@ -409,11 +409,20 @@ _mesa_GetColorTableParameterivEXT( GLenum target, GLenum pname, GLint *params )
       case GL_TEXTURE_3D:
          palette = &texUnit->CurrentD[3]->Palette;
          break;
+      case GL_PROXY_TEXTURE_1D:
+         palette = &ctx->Texture.Proxy1D->Palette;
+         break;
+      case GL_PROXY_TEXTURE_2D:
+         palette = &ctx->Texture.Proxy2D->Palette;
+         break;
+      case GL_PROXY_TEXTURE_3D:
+         palette = &ctx->Texture.Proxy3D->Palette;
+         break;
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          palette = &ctx->Texture.Palette;
          break;
       default:
-         gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterEXT(target)");
+         gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
          return;
    }
 
@@ -443,7 +452,7 @@ _mesa_GetColorTableParameterivEXT( GLenum target, GLenum pname, GLint *params )
          *params = 8;
          break;
       default:
-         gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterEXT" );
+         gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter" );
          return;
    }
 }