Skip to content

Commit

Permalink
Add internal function SDL_EGL_GetVersion()
Browse files Browse the repository at this point in the history
  • Loading branch information
1bsyl committed Oct 18, 2019
1 parent b060b2e commit 24bee6e
Showing 1 changed file with 25 additions and 36 deletions.
61 changes: 25 additions & 36 deletions src/video/SDL_egl.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 24bee6e

Please sign in to comment.