Skip to content

Commit

Permalink
iOS: Avoid generating an OpenGL error (but still fail to create the c…
Browse files Browse the repository at this point in the history
…ontext) if the specified MSAA sample count is unsupported.
  • Loading branch information
slime73 committed Jul 19, 2015
1 parent 6ea942d commit c344b73
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/video/uikit/SDL_uikitopenglview.m
Expand Up @@ -84,6 +84,18 @@ - (instancetype)initWithFrame:(CGRect)frame
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)) {
Expand Down Expand Up @@ -150,11 +162,6 @@ - (instancetype)initWithFrame:(CGRect)frame
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) {
Expand Down

0 comments on commit c344b73

Please sign in to comment.