mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
GDK/Win32: Try to fix initializing GLES contexts
We are now able to create EGL contexts properly on Windows, but not GLES. This tries to fix things by doing the following: * Record the GL context type in a more proper fashion, using an Enum. This makes things a bit cleaner. * Force GLES-3.0+ contexts, since libANGLE requires this to properly work with the shaders-its 2.0 contexts don't work well with our shaders.
This commit is contained in:
parent
3e9d858af1
commit
598c7d9cf4
@ -1181,6 +1181,7 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display,
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
GdkWin32GLType gl_type = GDK_WIN32_GL_TYPE_NONE;
|
||||
|
||||
if (display_win32->dummy_context_wgl.hdc == NULL)
|
||||
display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd);
|
||||
@ -1196,20 +1197,29 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display,
|
||||
* usage against libANGLE EGL. EGL is used more as a compatibility layer
|
||||
* on Windows rather than being a native citizen on Windows
|
||||
*/
|
||||
if (_gdk_debug_flags & GDK_DEBUG_GL_EGL)
|
||||
result = gdk_display_init_egl (display,
|
||||
EGL_PLATFORM_ANGLE_ANGLE,
|
||||
display_win32->dummy_context_wgl.hdc,
|
||||
FALSE,
|
||||
error);
|
||||
if (GDK_DEBUG_CHECK (GL_EGL) || GDK_DEBUG_CHECK (GL_GLES))
|
||||
{
|
||||
result = gdk_display_init_egl (display,
|
||||
EGL_PLATFORM_ANGLE_ANGLE,
|
||||
display_win32->dummy_context_wgl.hdc,
|
||||
FALSE,
|
||||
error);
|
||||
|
||||
if (result)
|
||||
gl_type = GDK_WIN32_GL_TYPE_EGL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!result)
|
||||
{
|
||||
g_clear_error (error);
|
||||
result = gdk_win32_display_init_wgl (display, error);
|
||||
|
||||
if (result)
|
||||
gl_type = GDK_WIN32_GL_TYPE_WGL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
if (!result)
|
||||
{
|
||||
@ -1219,9 +1229,13 @@ gdk_win32_display_init_gl_backend (GdkDisplay *display,
|
||||
display_win32->dummy_context_wgl.hdc,
|
||||
TRUE,
|
||||
error);
|
||||
|
||||
if (result)
|
||||
gl_type = GDK_WIN32_GL_TYPE_EGL;
|
||||
}
|
||||
#endif
|
||||
|
||||
display_win32->gl_type = gl_type;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1235,11 +1249,17 @@ gdk_win32_display_init_gl (GdkDisplay *display,
|
||||
if (!gdk_win32_display_init_gl_backend (display, error))
|
||||
return NULL;
|
||||
|
||||
if (display_win32->wgl_pixel_format != 0)
|
||||
if (display_win32->gl_type == GDK_WIN32_GL_TYPE_WGL)
|
||||
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL, "display", display, NULL);
|
||||
#ifdef HAVE_EGL
|
||||
else if (gdk_display_get_egl_display (display))
|
||||
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL);
|
||||
else if (display_win32->gl_type == GDK_WIN32_GL_TYPE_EGL)
|
||||
{
|
||||
gl_context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_EGL, "display", display, NULL);
|
||||
|
||||
/* We want to use a GLES 3.0+ context */
|
||||
gdk_gl_context_set_allowed_apis (gl_context, GDK_GL_API_GLES);
|
||||
gdk_gl_context_set_required_version (gl_context, 3, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (gl_context != NULL, NULL);
|
||||
|
@ -105,6 +105,13 @@ typedef enum {
|
||||
GDK_WIN32_TABLET_INPUT_API_WINPOINTER
|
||||
} GdkWin32TabletInputAPI;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GDK_WIN32_GL_TYPE_NONE,
|
||||
GDK_WIN32_GL_TYPE_WGL,
|
||||
GDK_WIN32_GL_TYPE_EGL,
|
||||
} GdkWin32GLType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HDC hdc;
|
||||
@ -125,7 +132,7 @@ struct _GdkWin32Display
|
||||
|
||||
/* WGL/OpenGL Items */
|
||||
GdkWin32GLDummyContextWGL dummy_context_wgl;
|
||||
int wgl_pixel_format;
|
||||
GdkWin32GLType gl_type;
|
||||
guint gl_version;
|
||||
|
||||
GListModel *monitors;
|
||||
|
@ -258,7 +258,7 @@ gdk_win32_display_init_wgl (GdkDisplay *display,
|
||||
if (!gdk_gl_backend_can_be_used (GDK_GL_WGL, error))
|
||||
return FALSE;
|
||||
|
||||
if (display_win32->wgl_pixel_format != 0)
|
||||
if (display_win32->gl_type == GDK_WIN32_GL_TYPE_WGL)
|
||||
return TRUE;
|
||||
|
||||
/* acquire and cache dummy Window (HWND & HDC) and
|
||||
@ -299,8 +299,6 @@ gdk_win32_display_init_wgl (GdkDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
display_win32->wgl_pixel_format = best_idx;
|
||||
|
||||
display_win32->hasWglARBCreateContext =
|
||||
epoxy_has_wgl_extension (hdc, "WGL_ARB_create_context");
|
||||
display_win32->hasWglEXTSwapControl =
|
||||
@ -728,10 +726,11 @@ gdk_win32_display_get_wgl_version (GdkDisplay *display,
|
||||
if (!GDK_IS_WIN32_DISPLAY (display))
|
||||
return FALSE;
|
||||
|
||||
display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
if (display_win32->wgl_pixel_format == 0)
|
||||
if (!gdk_win32_display_init_wgl (display, NULL))
|
||||
return FALSE;
|
||||
|
||||
display_win32 = GDK_WIN32_DISPLAY (display);
|
||||
|
||||
if (major != NULL)
|
||||
*major = display_win32->gl_version / 10;
|
||||
if (minor != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user