return mask;
}
-
-/**
- * Helper routine used by glDrawBuffer and glDrawBuffersARB.
- * Given a GLenum naming one or more color buffers (such as
- * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
- */
-static GLbitfield
-draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
+static GLenum
+back_to_front_if_single_buffered(const struct gl_context *ctx, GLenum buffer)
{
/* If the front buffer is the only buffer, GL_BACK and all other flags
* that include BACK select the front buffer for drawing. There are
}
}
+ return buffer;
+}
+
+/**
+ * Helper routine used by glDrawBuffer and glDrawBuffersARB.
+ * Given a GLenum naming one or more color buffers (such as
+ * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
+ */
+static GLbitfield
+draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
+{
+ buffer = back_to_front_if_single_buffered(ctx, buffer);
+
switch (buffer) {
case GL_NONE:
return 0;
static gl_buffer_index
read_buffer_enum_to_index(const struct gl_context *ctx, GLenum buffer)
{
+ buffer = back_to_front_if_single_buffered(ctx, buffer);
+
switch (buffer) {
case GL_FRONT:
return BUFFER_FRONT_LEFT;
case GL_BACK:
- if (_mesa_is_gles(ctx)) {
- /* In draw_buffer_enum_to_bitmask, when GLES contexts draw to
- * GL_BACK with a single-buffered configuration, we actually end
- * up drawing to the sole front buffer in our internal
- * representation. For consistency, we must read from that
- * front left buffer too.
- */
- if (!ctx->DrawBuffer->Visual.doubleBufferMode)
- return BUFFER_FRONT_LEFT;
- }
return BUFFER_BACK_LEFT;
case GL_RIGHT:
return BUFFER_FRONT_RIGHT;