Add internal function SDL_EGL_GetVersion()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index 1c704f7..19d0a09 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -446,29 +446,36 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
return 0;
}
+static void
+SDL_EGL_GetVersion(_THIS) {
+ if (_this->egl_data->eglQueryString) {
+ const char *egl_version = _this->egl_data->eglQueryString(_this->egl_data->egl_display, EGL_VERSION);
+ if (egl_version) {
+ int major = 0, minor = 0;
+ if (SDL_sscanf(egl_version, "%d.%d", &major, &minor) == 2) {
+ _this->egl_data->egl_version_major = major;
+ _this->egl_data->egl_version_minor = minor;
+ } else {
+ SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not parse EGL version string: %s", egl_version);
+ }
+ }
+ }
+}
+
int
SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_display, EGLenum platform)
{
- int egl_version_major = 0, egl_version_minor = 0;
+ int egl_version_major, egl_version_minor;
int library_load_retcode = SDL_EGL_LoadLibraryOnly(_this, egl_path);
if (library_load_retcode != 0) {
return library_load_retcode;
}
- if (_this->egl_data->eglQueryString) {
- /* EGL 1.5 allows querying for client version */
- const char *egl_version = _this->egl_data->eglQueryString(EGL_NO_DISPLAY, EGL_VERSION);
- if (egl_version != NULL) {
- if (SDL_sscanf(egl_version, "%d.%d", &egl_version_major, &egl_version_minor) != 2) {
- egl_version_major = 0;
- egl_version_minor = 0;
- SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not parse EGL version string: %s", egl_version);
- }
- }
- }
+ /* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY */
+ SDL_EGL_GetVersion(_this);
- _this->egl_data->egl_version_major = egl_version_major;
- _this->egl_data->egl_version_minor = egl_version_minor;
+ egl_version_major = _this->egl_data->egl_version_major;
+ egl_version_minor = _this->egl_data->egl_version_minor;
if (egl_version_major == 1 && egl_version_minor == 5) {
LOAD_FUNC(eglGetPlatformDisplay);
@@ -505,17 +512,8 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
}
#endif
- /* Get the EGL version */
- if (_this->egl_data->eglQueryString && _this->egl_data->egl_version_major == 0 && _this->egl_data->egl_version_major == 0) {
- const char *egl_version = _this->egl_data->eglQueryString(_this->egl_data->egl_display, EGL_VERSION);
- int major = 0, minor = 0;
- if (egl_version != NULL) {
- if (SDL_sscanf(egl_version, "%d.%d", &major, &minor) == 2) {
- _this->egl_data->egl_version_major = major;
- _this->egl_data->egl_version_minor = minor;
- }
- }
- }
+ /* Get the EGL version with a valid egl_display, for EGL <= 1.4 */
+ SDL_EGL_GetVersion(_this);
_this->egl_data->is_offscreen = 0;
@@ -602,17 +600,8 @@ SDL_EGL_InitializeOffscreen(_THIS, int device)
}
}
- /* Get the EGL version */
- if (_this->egl_data->eglQueryString && _this->egl_data->egl_version_major == 0 && _this->egl_data->egl_version_major == 0) {
- const char *egl_version = _this->egl_data->eglQueryString(_this->egl_data->egl_display, EGL_VERSION);
- int major = 0, minor = 0;
- if (egl_version != NULL) {
- if (SDL_sscanf(egl_version, "%d.%d", &major, &minor) == 2) {
- _this->egl_data->egl_version_major = major;
- _this->egl_data->egl_version_minor = minor;
- }
- }
- }
+ /* Get the EGL version with a valid egl_display, for EGL <= 1.4 */
+ SDL_EGL_GetVersion(_this);
_this->egl_data->is_offscreen = 1;