|
@@ -26,6 +26,7 @@
|
|
|
#include "SDL_loadso.h"
|
|
|
#include "SDL_windowsvideo.h"
|
|
|
#include "SDL_windowsopengles.h"
|
|
|
+#include "SDL_hints.h"
|
|
|
|
|
|
/* WGL implementation of SDL OpenGL support */
|
|
|
|
|
@@ -131,6 +132,44 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
|
|
return SDL_SetError("Could not retrieve OpenGL functions");
|
|
|
}
|
|
|
|
|
|
+ /* XXX Too sleazy? WIN_GL_InitExtensions looks for certain OpenGL
|
|
|
+ extensions via SDL_GL_DeduceMaxSupportedESProfile. This uses
|
|
|
+ SDL_GL_ExtensionSupported which in turn calls SDL_GL_GetProcAddress.
|
|
|
+ However SDL_GL_GetProcAddress will fail if the library is not
|
|
|
+ loaded; it checks for gl_config.driver_loaded > 0. To avoid this
|
|
|
+ test failing, increment driver_loaded around the call to
|
|
|
+ WIN_GLInitExtensions.
|
|
|
+
|
|
|
+ Successful loading of the library is normally indicated by
|
|
|
+ SDL_GL_LoadLibrary incrementing driver_loaded immediately after
|
|
|
+ this function returns 0 to it.
|
|
|
+
|
|
|
+ Alternatives to this are:
|
|
|
+ - moving SDL_GL_DeduceMaxSupportedESProfile to both the WIN and
|
|
|
+ X11 platforms while adding a function equivalent to
|
|
|
+ SDL_GL_ExtensionSupported but which directly calls
|
|
|
+ glGetProcAddress(). Having 3 copies of the
|
|
|
+ SDL_GL_ExtensionSupported makes this alternative unattractive.
|
|
|
+ - moving SDL_GL_DeduceMaxSupportedESProfile to a new file shared
|
|
|
+ by the WIN and X11 platforms while adding a function equivalent
|
|
|
+ to SDL_GL_ExtensionSupported. This is unattractive due to the
|
|
|
+ number of project files that will need updating, plus there
|
|
|
+ will be 2 copies of the SDL_GL_ExtensionSupported code.
|
|
|
+ - Add a private equivalent of SDL_GL_ExtensionSupported to
|
|
|
+ SDL_video.c.
|
|
|
+ - Move the call to WIN_GL_InitExtensions back to WIN_CreateWindow
|
|
|
+ and add a flag to gl_data to avoid multiple calls to this
|
|
|
+ expensive function. This is probably the least objectionable
|
|
|
+ alternative if this increment/decrement trick is unacceptable.
|
|
|
+
|
|
|
+ Note that the driver_loaded > 0 check needs to remain in
|
|
|
+ SDL_GL_ExtensionSupported and SDL_GL_GetProcAddress as they are
|
|
|
+ public API functions.
|
|
|
+ */
|
|
|
+ ++_this->gl_config.driver_loaded;
|
|
|
+ WIN_GL_InitExtensions(_this);
|
|
|
+ --_this->gl_config.driver_loaded;
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -407,9 +446,11 @@ WIN_GL_InitExtensions(_THIS)
|
|
|
}
|
|
|
|
|
|
/* Check for WGL_EXT_create_context_es2_profile */
|
|
|
- _this->gl_data->HAS_WGL_EXT_create_context_es2_profile = SDL_FALSE;
|
|
|
if (HasExtension("WGL_EXT_create_context_es2_profile", extensions)) {
|
|
|
- _this->gl_data->HAS_WGL_EXT_create_context_es2_profile = SDL_TRUE;
|
|
|
+ SDL_GL_DeduceMaxSupportedESProfile(
|
|
|
+ &_this->gl_data->es_profile_max_supported_version.major,
|
|
|
+ &_this->gl_data->es_profile_max_supported_version.minor
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/* Check for GLX_ARB_context_flush_control */
|
|
@@ -593,14 +634,26 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window)
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
+SDL_bool
|
|
|
+WIN_GL_UseEGL(_THIS)
|
|
|
+{
|
|
|
+ SDL_assert(_this->gl_data != NULL);
|
|
|
+ SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES);
|
|
|
+
|
|
|
+ return (SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE)
|
|
|
+ || _this->gl_config.major_version == 1 /* No WGL extension for OpenGL ES 1.x profiles. */
|
|
|
+ || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major
|
|
|
+ || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major
|
|
|
+ && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor));
|
|
|
+}
|
|
|
+
|
|
|
SDL_GLContext
|
|
|
WIN_GL_CreateContext(_THIS, SDL_Window * window)
|
|
|
{
|
|
|
HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
|
|
|
HGLRC context, share_context;
|
|
|
|
|
|
- if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES &&
|
|
|
- !_this->gl_data->HAS_WGL_EXT_create_context_es2_profile) {
|
|
|
+ if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && WIN_GL_UseEGL(_this)) {
|
|
|
#if SDL_VIDEO_OPENGL_EGL
|
|
|
/* Switch to EGL based functions */
|
|
|
WIN_GL_UnloadLibrary(_this);
|