[Commits] SDL: iOS: Avoid generating an OpenGL error (but still fail to cr...

libsdl.org revision control commits-owner at libsdl.org
Sun Jul 19 15:56:21 PDT 2015


details:   https://hg.libsdl.org/SDL/rev/9d44e8794a9b
changeset: 9811:9d44e8794a9b
user:      Alex Szpakowski <slime73 at gmail.com>
date:      Sun Jul 19 19:56:16 2015 -0300
description:
iOS: Avoid generating an OpenGL error (but still fail to create the context) if the specified MSAA sample count is unsupported.

diffstat:

 src/video/uikit/SDL_uikitopenglview.m |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r 1e079120100e -r 9d44e8794a9b src/video/uikit/SDL_uikitopenglview.m
--- a/src/video/uikit/SDL_uikitopenglview.m	Sun Jul 19 19:44:40 2015 -0300
+++ b/src/video/uikit/SDL_uikitopenglview.m	Sun Jul 19 19:56:16 2015 -0300
@@ -84,6 +84,18 @@
             return nil;
         }
 
+        if (samples > 0) {
+            GLint maxsamples = 0;
+            glGetIntegerv(GL_MAX_SAMPLES, &maxsamples);
+
+            /* Verify that the sample count is supported before creating any
+             * multisample Renderbuffers, to avoid generating GL errors. */
+            if (samples > maxsamples) {
+                SDL_SetError("Failed creating OpenGL ES framebuffer: Unsupported MSAA sample count");
+                return nil;
+            }
+        }
+
         if (sRGB) {
             /* sRGB EAGL drawable support was added in iOS 7. */
             if (UIKit_IsSystemVersionAtLeast(7.0)) {
@@ -150,11 +162,6 @@
             glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, colorBufferFormat, backingWidth, backingHeight);
 
             glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaRenderbuffer);
-
-            if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
-                SDL_SetError("Failed creating OpenGL ES framebuffer: Unsupported MSAA sample count");
-                return nil;
-            }
         }
 
         if (useDepthBuffer || useStencilBuffer) {


More information about the commits mailing list