mesa: rename gl_vertex_attrib_array::VertexBinding
[mesa.git] / src / mesa / main / clear.c
index 3bfcc5c0e396aaba45edfe18c67b250770d9e026..a1bb36efe241e0508b6fd09dd917f43501713082 100644 (file)
@@ -267,6 +267,14 @@ make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer)
          mask |= BUFFER_BIT_FRONT_RIGHT;
       break;
    case GL_BACK:
+      /* For GLES contexts with a single buffered configuration, we actually
+       * only have a front renderbuffer, so any clear calls to GL_BACK should
+       * affect that buffer. See draw_buffer_enum_to_bitmask for details.
+       */
+      if (_mesa_is_gles(ctx))
+         if (!ctx->DrawBuffer->Visual.doubleBufferMode)
+            if (att[BUFFER_FRONT_LEFT].Renderbuffer)
+               mask |= BUFFER_BIT_FRONT_LEFT;
       if (att[BUFFER_BACK_LEFT].Renderbuffer)
          mask |= BUFFER_BIT_BACK_LEFT;
       if (att[BUFFER_BACK_RIGHT].Renderbuffer)
@@ -325,18 +333,6 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
       _mesa_update_state( ctx );
    }
 
-   /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
-    * of the OpenGL 4.5 spec states:
-    *
-    *    "An INVALID_ENUM error is generated by ClearBufferiv and
-    *     ClearNamedFramebufferiv if buffer is not COLOR or STENCIL."
-    */
-   if (buffer == GL_DEPTH || buffer == GL_DEPTH_STENCIL) {
-      _mesa_error(ctx, GL_INVALID_ENUM,
-                  "glClearBufferiv(buffer=GL_DEPTH || GL_DEPTH_STENCIL)");
-      return;
-   }
-
    switch (buffer) {
    case GL_STENCIL:
       /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
@@ -386,26 +382,13 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
          }
       }
       break;
-   case GL_DEPTH:
-      /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
-       *
-       *     "The result of ClearBuffer is undefined if no conversion between
-       *     the type of the specified value and the type of the buffer being
-       *     cleared is defined (for example, if ClearBufferiv is called for a
-       *     fixed- or floating-point buffer, or if ClearBufferfv is called
-       *     for a signed or unsigned integer buffer). This is not an error."
+   default:
+      /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
+       * of the OpenGL 4.5 spec states:
        *
-       * In this case we take "undefined" and "not an error" to mean "ignore."
-       * Note that we still need to generate an error for the invalid
-       * drawbuffer case (see the GL_STENCIL case above).
+       *    "An INVALID_ENUM error is generated by ClearBufferiv and
+       *     ClearNamedFramebufferiv if buffer is not COLOR or STENCIL."
        */
-      if (drawbuffer != 0) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferiv(drawbuffer=%d)",
-                     drawbuffer);
-         return;
-      }
-      return;
-   default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferiv(buffer=%s)",
                   _mesa_enum_to_string(buffer));
       return;
@@ -470,32 +453,13 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
          }
       }
       break;
-   case GL_DEPTH:
-   case GL_STENCIL:
-      /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
-       *
-       *     "The result of ClearBuffer is undefined if no conversion between
-       *     the type of the specified value and the type of the buffer being
-       *     cleared is defined (for example, if ClearBufferiv is called for a
-       *     fixed- or floating-point buffer, or if ClearBufferfv is called
-       *     for a signed or unsigned integer buffer). This is not an error."
-       *
-       * In this case we take "undefined" and "not an error" to mean "ignore."
-       * Even though we could do something sensible for GL_STENCIL, page 263
-       * (page 279 of the PDF) says:
-       *
-       *     "Only ClearBufferiv should be used to clear stencil buffers."
+   default:
+      /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
+       * of the OpenGL 4.5 spec states:
        *
-       * Note that we still need to generate an error for the invalid
-       * drawbuffer case (see the GL_STENCIL case in _mesa_ClearBufferiv).
+       *    "An INVALID_ENUM error is generated by ClearBufferuiv and
+       *     ClearNamedFramebufferuiv if buffer is not COLOR."
        */
-      if (drawbuffer != 0) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferuiv(drawbuffer=%d)",
-                     drawbuffer);
-         return;
-      }
-      return;
-   default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferuiv(buffer=%s)",
                   _mesa_enum_to_string(buffer));
       return;
@@ -587,26 +551,13 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
          }
       }
       break;
-   case GL_STENCIL:
-      /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
-       *
-       *     "The result of ClearBuffer is undefined if no conversion between
-       *     the type of the specified value and the type of the buffer being
-       *     cleared is defined (for example, if ClearBufferiv is called for a
-       *     fixed- or floating-point buffer, or if ClearBufferfv is called
-       *     for a signed or unsigned integer buffer). This is not an error."
+   default:
+      /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
+       * of the OpenGL 4.5 spec states:
        *
-       * In this case we take "undefined" and "not an error" to mean "ignore."
-       * Note that we still need to generate an error for the invalid
-       * drawbuffer case (see the GL_DEPTH case above).
+       *    "An INVALID_ENUM error is generated by ClearBufferfv and
+       *     ClearNamedFramebufferfv if buffer is not COLOR or DEPTH."
        */
-      if (drawbuffer != 0) {
-         _mesa_error(ctx, GL_INVALID_VALUE, "glClearBufferfv(drawbuffer=%d)",
-                     drawbuffer);
-         return;
-      }
-      return;
-   default:
       _mesa_error(ctx, GL_INVALID_ENUM, "glClearBufferfv(buffer=%s)",
                   _mesa_enum_to_string(buffer));
       return;
@@ -703,12 +654,12 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
  */
 void GLAPIENTRY
 _mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
-                              GLfloat depth, GLint stencil)
+                              GLint drawbuffer, GLfloat depth, GLint stencil)
 {
    GLint oldfb;
 
    _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
    _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
-   _mesa_ClearBufferfi(buffer, 0, depth, stencil);
+   _mesa_ClearBufferfi(buffer, drawbuffer, depth, stencil);
    _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
 }