Drop GLcontext typedef and use struct gl_context instead
[mesa.git] / src / mesa / main / readpix.c
index feea1d375f66d7a173ae7af8dc7b80416aeda8fc..0043c8adc412a50007910eb719419bd16754b956 100644 (file)
@@ -40,7 +40,7 @@
  * \return GL_TRUE if error detected, GL_FALSE if no errors
  */
 GLboolean
-_mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type,
+_mesa_error_check_format_type(struct gl_context *ctx, GLenum format, GLenum type,
                               GLboolean drawing)
 {
    const char *readDraw = drawing ? "Draw" : "Read";
@@ -66,6 +66,7 @@ _mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type,
 
    /* additional checks */
    switch (format) {
+   case GL_RG:
    case GL_RED:
    case GL_GREEN:
    case GL_BLUE:
@@ -77,14 +78,7 @@ _mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type,
    case GL_RGBA:
    case GL_BGRA:
    case GL_ABGR_EXT:
-      if (drawing) {
-         if (!ctx->DrawBuffer->Visual.rgbMode) {
-            _mesa_error(ctx, GL_INVALID_OPERATION,
-                   "glDrawPixels(drawing RGB pixels into color index buffer)");
-            return GL_TRUE;
-         }
-      }
-      else {
+      if (!drawing) {
          /* reading */
          if (!_mesa_source_buffer_exists(ctx, GL_COLOR)) {
             _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -95,10 +89,9 @@ _mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type,
       break;
    case GL_COLOR_INDEX:
       if (drawing) {
-         if (ctx->DrawBuffer->Visual.rgbMode &&
-             (ctx->PixelMaps.ItoR.Size == 0 ||
-              ctx->PixelMaps.ItoG.Size == 0 ||
-              ctx->PixelMaps.ItoB.Size == 0)) {
+         if (ctx->PixelMaps.ItoR.Size == 0 ||
+            ctx->PixelMaps.ItoG.Size == 0 ||
+            ctx->PixelMaps.ItoB.Size == 0) {
             _mesa_error(ctx, GL_INVALID_OPERATION,
                    "glDrawPixels(drawing color index pixels into RGB buffer)");
             return GL_TRUE;
@@ -111,6 +104,12 @@ _mesa_error_check_format_type(GLcontext *ctx, GLenum format, GLenum type,
                         "glReadPixels(no color buffer)");
             return GL_TRUE;
          }
+         /* We no longer support CI-mode color buffers so trying to read
+          * GL_COLOR_INDEX pixels is always an error.
+          */
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glReadPixels(color buffer is RGB)");
+         return GL_TRUE;
       }
       break;
    case GL_STENCIL_INDEX: