[BUG][4.1.0.24] SDL2 cant create EGLSurface, cant return SDL_GetDeviceDPI

REPRODUCIBILITY: 100%
BUILD ID = OS VERSION any, till with 4.1.0.24
HARDWARE (XA2, Xperia 10…): Any device
UI LANGUAGE: Any Language
REGRESSION: No

DESCRIPTION:

In my applications ( like some games ports Quake 2, Love2D Engine )

PRECONDITIONS:

For creating SDL applications, need some missing functions for Wayland backend.

STEPS TO REPRODUCE:

Just try create SDL2 application with EGL initialization, or try use SDL_GetDeviceDPI function, which return just SDL_Unsuported() error.
This code should work (use here) Bug Report on SDL

struct SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
if (!SDL_GetWindowWMInfo(sdlwContext->window, &wmInfo)) {
    printf("Cannot get the window handle.\n");
    return (EGLNativeWindowType)NULL;
}
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
        nativeWindow=wmInfo.info.wl.egl_window;
#endif

and this code should work to

float ddpi = -1;
if( SDL_GetDeviceDPI( 0, &ddpi, NULL, NULL ) != 0 ) {
	std::cerr << "SDL_Error: " << SDL_GetError(); // Here on SailfishOS it return SDL_Unsuported()
	return 1.0;
}
return ddpi;

EXPECTED RESULT:

SDL_SysWMinfo should contains in wmInfo.info.wl.egl_window pointer to wayland_egl
SDL_GetDeviceDPI should return device DPI

ACTUAL RESULT:

First code sample cant even compile,
Second code sample show SDL_Error (Unsuported) and return 1.0

ADDITIONAL INFORMATION:

Wayland EGL pointer bug report
SDL_GetDisplayDPI commit

Both features are implemented and used in Quake2 port with statically built in SDL2 =)

Is it possible, while SDL2 not released this features, make patch current SDL2 in SaiflishOS git repository? if need, i can make patch for this features realeted to SailfishOS version of SDL2…

Given that there indeed isn’t SDL2 release with that yet, I believe the fastest way to get it in would be patching our version. And if you could make a PR for that, it would definitely speed things up.

i dont have account on git.sailfishos.org ) but can make patch file, if somebody with account make PR .

I can make the MR if you need it. Please create the patch with git format-patch so it will keep your commit message and authorship.

Thanks, today, later, i’ll do it !
Edit: Ok, now i has account! Soon i’ll create MR.

1 Like

done, when it is merged ( if it is merged :smile_cat: ), i’ll resolve this bug report as fixed )