mesa/es: Fix GL_RGB565 support in FBO.
authorChia-I Wu <olvaffe@gmail.com>
Tue, 24 Nov 2009 04:11:26 +0000 (12:11 +0800)
committerBrian Paul <brianp@vmware.com>
Mon, 4 Jan 2010 21:15:16 +0000 (14:15 -0700)
In GL_OES_framebuffer_object and OpenGL ES 2.0, GL_RGB565 is a valid
internal format.  Since it is not supported by the core, map it to
GL_RGB5 as a workaround.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/mesa/es/main/APIspec.xml
src/mesa/es/main/es_fbo.c

index a7dbdc424990a88e868f4cb0826e2c516bc25006..f6f33130b159540ae3cd47e34137260a85a1781f 100644 (file)
        <function name="BindRenderbufferOES" template="BindRenderbuffer"/>
        <function name="DeleteRenderbuffersOES" template="DeleteRenderbuffers"/>
        <function name="GenRenderbuffersOES" template="GenRenderbuffers"/>
-       <function name="RenderbufferStorageOES" template="RenderbufferStorage"/>
+       <function name="RenderbufferStorageOES" external="true" template="RenderbufferStorage"/>
        <function name="FramebufferRenderbufferOES" template="FramebufferRenderbuffer"/>
        <function name="FramebufferTexture2DOES" template="FramebufferTexture2D"/>
        <function name="CheckFramebufferStatusOES" template="CheckFramebufferStatus"/>
index db53a1449f35b0c31ebb25c441cc2fd5e260cf65..18036378304ba52fccbca4d7f6e841241c2c1baa 100644 (file)
 #include "GLES2/gl2ext.h"
 
 
+#ifndef GL_RGB5
+#define GL_RGB5                                        0x8050
+#endif
+
+
 extern void GL_APIENTRY _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
 
 extern void GL_APIENTRY _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
@@ -20,18 +25,13 @@ _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
                            GLsizei width, GLsizei height)
 {
    switch (internalFormat) {
-   case GL_RGBA4:
-   case GL_RGB5_A1:
    case GL_RGB565:
-      internalFormat = GL_RGBA;
-      break;
-   case GL_STENCIL_INDEX1_OES:
-   case GL_STENCIL_INDEX4_OES:
-   case GL_STENCIL_INDEX8:
-      internalFormat = GL_STENCIL_INDEX;
+      /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */
+      /* choose a closest format */
+      internalFormat = GL_RGB5;
       break;
    default:
-      ; /* no op */
+      break;
    }
    _mesa_RenderbufferStorageEXT(target, internalFormat, width, height);
 }