Use explicit display type in egl if possible.
This commit is contained in:
parent
201f8eca59
commit
f6111d04fd
@ -150,12 +150,56 @@ bool ContextManagerEGL::initDisplay()
|
|||||||
display = EGL_DEFAULT_DISPLAY;
|
display = EGL_DEFAULT_DISPLAY;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (display != EGL_DEFAULT_DISPLAY)
|
bool use_default_platform = false;
|
||||||
|
EGLenum platform = 0;
|
||||||
|
|
||||||
|
switch (m_creation_params.platform)
|
||||||
|
{
|
||||||
|
case CEGL_PLATFORM_ANDROID:
|
||||||
|
platform = EGL_PLATFORM_ANDROID;
|
||||||
|
break;
|
||||||
|
case CEGL_PLATFORM_GBM:
|
||||||
|
platform = EGL_PLATFORM_GBM;
|
||||||
|
break;
|
||||||
|
case CEGL_PLATFORM_WAYLAND:
|
||||||
|
platform = EGL_PLATFORM_WAYLAND;
|
||||||
|
break;
|
||||||
|
case CEGL_PLATFORM_X11:
|
||||||
|
platform = EGL_PLATFORM_X11;
|
||||||
|
break;
|
||||||
|
case CEGL_PLATFORM_DEFAULT:
|
||||||
|
use_default_platform = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (use_default_platform == false)
|
||||||
|
{
|
||||||
|
typedef EGLDisplay (*getPlatformDisp_t) (EGLenum, void*, const EGLint*);
|
||||||
|
getPlatformDisp_t getPlatformDisplay = NULL;
|
||||||
|
|
||||||
|
if (hasEGLExtension("EGL_KHR_platform_base"))
|
||||||
|
{
|
||||||
|
getPlatformDisplay =
|
||||||
|
(getPlatformDisp_t)eglGetProcAddress("eglGetPlatformDisplay");
|
||||||
|
}
|
||||||
|
else if (hasEGLExtension("EGL_EXT_platform_base"))
|
||||||
|
{
|
||||||
|
getPlatformDisplay =
|
||||||
|
(getPlatformDisp_t)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getPlatformDisplay != NULL)
|
||||||
|
{
|
||||||
|
m_egl_display = getPlatformDisplay(platform, display, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_egl_display == EGL_NO_DISPLAY)
|
||||||
{
|
{
|
||||||
m_egl_display = eglGetDisplay(display);
|
m_egl_display = eglGetDisplay(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_egl_display == EGL_NO_DISPLAY)
|
if (m_egl_display == EGL_NO_DISPLAY && display != EGL_DEFAULT_DISPLAY)
|
||||||
{
|
{
|
||||||
m_egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
m_egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,18 @@
|
|||||||
#ifndef EGL_GL_COLORSPACE_LINEAR
|
#ifndef EGL_GL_COLORSPACE_LINEAR
|
||||||
#define EGL_GL_COLORSPACE_LINEAR 0x308A
|
#define EGL_GL_COLORSPACE_LINEAR 0x308A
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef EGL_PLATFORM_ANDROID
|
||||||
|
#define EGL_PLATFORM_ANDROID 0x3141
|
||||||
|
#endif
|
||||||
|
#ifndef EGL_PLATFORM_GBM
|
||||||
|
#define EGL_PLATFORM_GBM 0x31D7
|
||||||
|
#endif
|
||||||
|
#ifndef EGL_PLATFORM_WAYLAND
|
||||||
|
#define EGL_PLATFORM_WAYLAND 0x31D8
|
||||||
|
#endif
|
||||||
|
#ifndef EGL_PLATFORM_X11
|
||||||
|
#define EGL_PLATFORM_X11 0x31D5
|
||||||
|
#endif
|
||||||
|
|
||||||
enum ContextEGLOpenGLAPI
|
enum ContextEGLOpenGLAPI
|
||||||
{
|
{
|
||||||
@ -52,10 +64,20 @@ enum ContextEGLSurfaceType
|
|||||||
CEGL_SURFACE_PBUFFER
|
CEGL_SURFACE_PBUFFER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ContextEGLPlatform
|
||||||
|
{
|
||||||
|
CEGL_PLATFORM_ANDROID,
|
||||||
|
CEGL_PLATFORM_GBM,
|
||||||
|
CEGL_PLATFORM_WAYLAND,
|
||||||
|
CEGL_PLATFORM_X11,
|
||||||
|
CEGL_PLATFORM_DEFAULT
|
||||||
|
};
|
||||||
|
|
||||||
struct ContextEGLParams
|
struct ContextEGLParams
|
||||||
{
|
{
|
||||||
ContextEGLOpenGLAPI opengl_api;
|
ContextEGLOpenGLAPI opengl_api;
|
||||||
ContextEGLSurfaceType surface_type;
|
ContextEGLSurfaceType surface_type;
|
||||||
|
ContextEGLPlatform platform;
|
||||||
EGLNativeWindowType window;
|
EGLNativeWindowType window;
|
||||||
EGLNativeDisplayType display;
|
EGLNativeDisplayType display;
|
||||||
bool force_legacy_device;
|
bool force_legacy_device;
|
||||||
|
@ -797,6 +797,7 @@ bool CIrrDeviceWayland::initEGL()
|
|||||||
egl_params.handle_srgb = CreationParams.HandleSRGB;
|
egl_params.handle_srgb = CreationParams.HandleSRGB;
|
||||||
egl_params.with_alpha_channel = CreationParams.WithAlphaChannel;
|
egl_params.with_alpha_channel = CreationParams.WithAlphaChannel;
|
||||||
egl_params.vsync_enabled = CreationParams.Vsync;
|
egl_params.vsync_enabled = CreationParams.Vsync;
|
||||||
|
egl_params.platform = CEGL_PLATFORM_WAYLAND;
|
||||||
egl_params.window = m_egl_window;
|
egl_params.window = m_egl_window;
|
||||||
egl_params.display = m_display;
|
egl_params.display = m_display;
|
||||||
|
|
||||||
|
@ -79,10 +79,12 @@ namespace video
|
|||||||
HDc = GetDC(data.OpenGLWin32.HWnd);
|
HDc = GetDC(data.OpenGLWin32.HWnd);
|
||||||
egl_params.display = (NativeDisplayType)(HDc);
|
egl_params.display = (NativeDisplayType)(HDc);
|
||||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||||
|
egl_params.platform = CEGL_PLATFORM_X11;
|
||||||
egl_params.window = (EGLNativeWindowType)(data.OpenGLLinux.X11Window);
|
egl_params.window = (EGLNativeWindowType)(data.OpenGLLinux.X11Window);
|
||||||
egl_params.display = (EGLNativeDisplayType)(data.OpenGLLinux.X11Display);
|
egl_params.display = (EGLNativeDisplayType)(data.OpenGLLinux.X11Display);
|
||||||
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||||
egl_params.window = ((struct android_app *)(params.PrivateData))->window;
|
egl_params.platform = CEGL_PLATFORM_DEFAULT;
|
||||||
|
egl_params.window = ((struct android_app *)(params.PrivateData))->window;
|
||||||
egl_params.display = NULL;
|
egl_params.display = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user