Fixed bug 4882 - Fix build for iOS when disabling OpenGL
authorSam Lantinga <slouken@libsdl.org>
Tue, 03 Dec 2019 22:07:58 -0800
changeset 13312dde034962e3a
parent 13311 81ca537d1287
child 13313 3b03741c0095
Fixed bug 4882 - Fix build for iOS when disabling OpenGL

Aaron Barany

Since OpenGL is deprecated on iOS, it is advantageous to be able to remove all OpenGL related code when building SDL for iOS. This patch adds the necessary #if checks to compile in this case.
src/video/uikit/SDL_uikitevents.m
src/video/uikit/SDL_uikitopengles.h
src/video/uikit/SDL_uikitopengles.m
src/video/uikit/SDL_uikitopenglview.h
src/video/uikit/SDL_uikitopenglview.m
src/video/uikit/SDL_uikitvideo.m
src/video/uikit/SDL_uikitviewcontroller.m
src/video/uikit/SDL_uikitwindow.m
     1.1 --- a/src/video/uikit/SDL_uikitevents.m	Mon Dec 02 15:41:25 2019 +0000
     1.2 +++ b/src/video/uikit/SDL_uikitevents.m	Tue Dec 03 22:07:58 2019 -0800
     1.3 @@ -65,7 +65,9 @@
     1.4      } while(result == kCFRunLoopRunHandledSource);
     1.5  
     1.6      /* See the comment in the function definition. */
     1.7 +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     1.8      UIKit_GL_RestoreCurrentContext();
     1.9 +#endif
    1.10  }
    1.11  
    1.12  #endif /* SDL_VIDEO_DRIVER_UIKIT */
     2.1 --- a/src/video/uikit/SDL_uikitopengles.h	Mon Dec 02 15:41:25 2019 +0000
     2.2 +++ b/src/video/uikit/SDL_uikitopengles.h	Tue Dec 03 22:07:58 2019 -0800
     2.3 @@ -21,6 +21,8 @@
     2.4  #ifndef SDL_uikitopengles_
     2.5  #define SDL_uikitopengles_
     2.6  
     2.7 +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     2.8 +
     2.9  #include "../SDL_sysvideo.h"
    2.10  
    2.11  extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window,
    2.12 @@ -35,6 +37,8 @@
    2.13  
    2.14  extern void UIKit_GL_RestoreCurrentContext(void);
    2.15  
    2.16 +#endif // SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
    2.17 +
    2.18  #endif /* SDL_uikitopengles_ */
    2.19  
    2.20  /* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/video/uikit/SDL_uikitopengles.m	Mon Dec 02 15:41:25 2019 +0000
     3.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Tue Dec 03 22:07:58 2019 -0800
     3.3 @@ -20,7 +20,7 @@
     3.4  */
     3.5  #include "../../SDL_internal.h"
     3.6  
     3.7 -#if SDL_VIDEO_DRIVER_UIKIT
     3.8 +#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2)
     3.9  
    3.10  #include "SDL_uikitopengles.h"
    3.11  #import "SDL_uikitopenglview.h"
     4.1 --- a/src/video/uikit/SDL_uikitopenglview.h	Mon Dec 02 15:41:25 2019 +0000
     4.2 +++ b/src/video/uikit/SDL_uikitopenglview.h	Tue Dec 03 22:07:58 2019 -0800
     4.3 @@ -19,6 +19,8 @@
     4.4    3. This notice may not be removed or altered from any source distribution.
     4.5  */
     4.6  
     4.7 +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     4.8 +
     4.9  #import <UIKit/UIKit.h>
    4.10  #import <OpenGLES/EAGL.h>
    4.11  #import <OpenGLES/ES3/gl.h>
    4.12 @@ -57,4 +59,6 @@
    4.13  
    4.14  @end
    4.15  
    4.16 +#endif // SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
    4.17 +
    4.18  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/uikit/SDL_uikitopenglview.m	Mon Dec 02 15:41:25 2019 +0000
     5.2 +++ b/src/video/uikit/SDL_uikitopenglview.m	Tue Dec 03 22:07:58 2019 -0800
     5.3 @@ -20,7 +20,7 @@
     5.4  */
     5.5  #include "../../SDL_internal.h"
     5.6  
     5.7 -#if SDL_VIDEO_DRIVER_UIKIT
     5.8 +#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2)
     5.9  
    5.10  #include <OpenGLES/EAGLDrawable.h>
    5.11  #include <OpenGLES/ES2/glext.h>
     6.1 --- a/src/video/uikit/SDL_uikitvideo.m	Mon Dec 02 15:41:25 2019 +0000
     6.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Tue Dec 03 22:07:58 2019 -0800
     6.3 @@ -116,6 +116,7 @@
     6.4          device->HasClipboardText = UIKit_HasClipboardText;
     6.5  
     6.6          /* OpenGL (ES) functions */
     6.7 +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     6.8          device->GL_MakeCurrent      = UIKit_GL_MakeCurrent;
     6.9          device->GL_GetDrawableSize  = UIKit_GL_GetDrawableSize;
    6.10          device->GL_SwapWindow       = UIKit_GL_SwapWindow;
    6.11 @@ -123,6 +124,7 @@
    6.12          device->GL_DeleteContext    = UIKit_GL_DeleteContext;
    6.13          device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
    6.14          device->GL_LoadLibrary      = UIKit_GL_LoadLibrary;
    6.15 +#endif
    6.16          device->free = UIKit_DeleteDevice;
    6.17  
    6.18  #if SDL_VIDEO_VULKAN
     7.1 --- a/src/video/uikit/SDL_uikitviewcontroller.m	Mon Dec 02 15:41:25 2019 +0000
     7.2 +++ b/src/video/uikit/SDL_uikitviewcontroller.m	Tue Dec 03 22:07:58 2019 -0800
     7.3 @@ -180,7 +180,9 @@
     7.4      /* Don't run the game loop while a messagebox is up */
     7.5      if (!UIKit_ShowingMessageBox()) {
     7.6          /* See the comment in the function definition. */
     7.7 +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     7.8          UIKit_GL_RestoreCurrentContext();
     7.9 +#endif
    7.10  
    7.11          animationCallback(animationCallbackParam);
    7.12      }
     8.1 --- a/src/video/uikit/SDL_uikitwindow.m	Mon Dec 02 15:41:25 2019 +0000
     8.2 +++ b/src/video/uikit/SDL_uikitwindow.m	Tue Dec 03 22:07:58 2019 -0800
     8.3 @@ -364,12 +364,16 @@
     8.4  
     8.5              /* These struct members were added in SDL 2.0.4. */
     8.6              if (versionnum >= SDL_VERSIONNUM(2,0,4)) {
     8.7 +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     8.8                  if ([data.viewcontroller.view isKindOfClass:[SDL_uikitopenglview class]]) {
     8.9                      SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.viewcontroller.view;
    8.10                      info->info.uikit.framebuffer = glview.drawableFramebuffer;
    8.11                      info->info.uikit.colorbuffer = glview.drawableRenderbuffer;
    8.12                      info->info.uikit.resolveFramebuffer = glview.msaaResolveFramebuffer;
    8.13                  } else {
    8.14 +#else
    8.15 +                {
    8.16 +#endif
    8.17                      info->info.uikit.framebuffer = 0;
    8.18                      info->info.uikit.colorbuffer = 0;
    8.19                      info->info.uikit.resolveFramebuffer = 0;