OSDN Git Service

Check for GL_FRAMEBUFFER_UNSUPPORTED error from glCheckFramebufferStatus
authorThomas ten Cate <ttencate@gmail.com>
Mon, 3 Jun 2013 19:41:00 +0000 (20:41 +0100)
committerThomas ten Cate <ttencate@gmail.com>
Mon, 3 Jun 2013 19:46:12 +0000 (20:46 +0100)
According to the OpenGL ES 2.0 spec
(http://www.khronos.org/registry/gles/specs/2.0/es_cm_spec_2.0.24.pdf),
CheckFramebufferStatus can return FRAMEBUFFER_UNSUPPORTED if e.g. the
texture isn't a color-renderable format. We should throw in that case,
not silently fail to work. Also throw for any other cases that aren't
FRAMEBUFFER_COMPLETE; according to the spec there shouldn't be any.

Also add some documentation about officially supported formats. In
particular, RGB888 and RGBA8888 do work on many devices, but aren't
listed in the spec as color-renderable formats.

gdx/src/com/badlogic/gdx/graphics/glutils/FrameBuffer.java

index 00b0044..b0aa15d 100644 (file)
@@ -84,11 +84,12 @@ public class FrameBuffer implements Disposable {
 \r
        /** Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached.\r
         * \r
-        * @param format the format of the color buffer\r
+        * @param format the format of the color buffer; according to the OpenGL ES 2.0 spec, only\r
+   * RGB565, RGBA4444 and RGB5_A1 are color-renderable\r
         * @param width the width of the framebuffer in pixels\r
         * @param height the height of the framebuffer in pixels\r
         * @param hasDepth whether to attach a depth buffer\r
-        * @throws GdxRuntimeException in case the FraeBuffer could not be created */\r
+        * @throws GdxRuntimeException in case the FrameBuffer could not be created */\r
        public FrameBuffer (Pixmap.Format format, int width, int height, boolean hasDepth) {\r
                this.width = width;\r
                this.height = height;\r
@@ -179,6 +180,9 @@ public class FrameBuffer implements Disposable {
                                throw new IllegalStateException("frame buffer couldn't be constructed: incomplete dimensions");\r
                        if (result == GL20.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT)\r
                                throw new IllegalStateException("frame buffer couldn't be constructed: missing attachment");\r
+                       if (result == GL20.GL_FRAMEBUFFER_UNSUPPORTED)\r
+                               throw new IllegalStateException("frame buffer couldn't be constructed: unsupported combination of formats");\r
+      throw new IllegalStateException(String.format("frame buffer couldn't be constructed: unknown error 0x%04x", result));\r
                }\r
        }\r
 \r