src/video/cocoa/SDL_cocoaopengl.m
changeset 11723 bc7ca7cfa6ca
parent 10737 3406a0f8b041
child 11811 5d94cb6b24d3
     1.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Mon Dec 04 20:26:09 2017 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Mon Dec 04 20:35:01 2017 -0800
     1.3 @@ -25,6 +25,7 @@
     1.4  #if SDL_VIDEO_OPENGL_CGL
     1.5  #include "SDL_cocoavideo.h"
     1.6  #include "SDL_cocoaopengl.h"
     1.7 +#include "SDL_cocoaopengles.h"
     1.8  
     1.9  #include <OpenGL/CGLTypes.h>
    1.10  #include <OpenGL/OpenGL.h>
    1.11 @@ -165,8 +166,27 @@
    1.12      int glversion_minor;
    1.13  
    1.14      if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
    1.15 -        SDL_SetError ("OpenGL ES is not supported on this platform");
    1.16 +#if SDL_VIDEO_OPENGL_EGL
    1.17 +        /* Switch to EGL based functions */
    1.18 +        Cocoa_GL_UnloadLibrary(_this);
    1.19 +        _this->GL_LoadLibrary = Cocoa_GLES_LoadLibrary;
    1.20 +        _this->GL_GetProcAddress = Cocoa_GLES_GetProcAddress;
    1.21 +        _this->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary;
    1.22 +        _this->GL_CreateContext = Cocoa_GLES_CreateContext;
    1.23 +        _this->GL_MakeCurrent = Cocoa_GLES_MakeCurrent;
    1.24 +        _this->GL_SetSwapInterval = Cocoa_GLES_SetSwapInterval;
    1.25 +        _this->GL_GetSwapInterval = Cocoa_GLES_GetSwapInterval;
    1.26 +        _this->GL_SwapWindow = Cocoa_GLES_SwapWindow;
    1.27 +        _this->GL_DeleteContext = Cocoa_GLES_DeleteContext;
    1.28 +        
    1.29 +        if (Cocoa_GLES_LoadLibrary(_this, NULL) != 0) {
    1.30 +            return NULL;
    1.31 +        }
    1.32 +        return Cocoa_GLES_CreateContext(_this, window);
    1.33 +#else
    1.34 +        SDL_SetError("SDL not configured with EGL support");
    1.35          return NULL;
    1.36 +#endif
    1.37      }
    1.38      if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && !lion_or_later) {
    1.39          SDL_SetError ("OpenGL Core Profile is not supported on this platform version");