mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
wgl: Improve error messages when GL init fails
In particular, we want to get the GL version, when the Windows box/VM has an unsuitable GL implementation. This is somewhat helpful in analyzing failures to bring up GL on machines where users claim GL does work.
This commit is contained in:
parent
d6afcee1e4
commit
9254ab8503
@ -331,7 +331,8 @@ static gboolean
|
|||||||
ensure_legacy_wgl_context (HDC hdc,
|
ensure_legacy_wgl_context (HDC hdc,
|
||||||
HGLRC hglrc_legacy,
|
HGLRC hglrc_legacy,
|
||||||
GdkGLContext *share,
|
GdkGLContext *share,
|
||||||
GdkGLVersion *version)
|
GdkGLVersion *version,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GdkWin32GLContextWGL *context_wgl;
|
GdkWin32GLContextWGL *context_wgl;
|
||||||
GdkGLVersion legacy_version;
|
GdkGLVersion legacy_version;
|
||||||
@ -342,11 +343,25 @@ ensure_legacy_wgl_context (HDC hdc,
|
|||||||
gdk_gl_version_get_minor (version)));
|
gdk_gl_version_get_minor (version)));
|
||||||
|
|
||||||
if (!wglMakeCurrent (hdc, hglrc_legacy))
|
if (!wglMakeCurrent (hdc, hglrc_legacy))
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
|
_("Unable to create a GL context"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gdk_gl_version_init_epoxy (&legacy_version);
|
gdk_gl_version_init_epoxy (&legacy_version);
|
||||||
if (!gdk_gl_version_greater_equal (&legacy_version, version))
|
if (!gdk_gl_version_greater_equal (&legacy_version, version))
|
||||||
|
{
|
||||||
|
g_set_error (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
|
_("WGL version %d.%d is too low, need at least %d.%d"),
|
||||||
|
gdk_gl_version_get_major (&legacy_version),
|
||||||
|
gdk_gl_version_get_minor (&legacy_version),
|
||||||
|
gdk_gl_version_get_major (version),
|
||||||
|
gdk_gl_version_get_minor (version));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
*version = legacy_version;
|
*version = legacy_version;
|
||||||
|
|
||||||
@ -354,7 +369,13 @@ ensure_legacy_wgl_context (HDC hdc,
|
|||||||
{
|
{
|
||||||
context_wgl = GDK_WIN32_GL_CONTEXT_WGL (share);
|
context_wgl = GDK_WIN32_GL_CONTEXT_WGL (share);
|
||||||
|
|
||||||
return wglShareLists (hglrc_legacy, context_wgl->wgl_context);
|
if (!wglShareLists (hglrc_legacy, context_wgl->wgl_context))
|
||||||
|
{
|
||||||
|
g_set_error (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||||
|
_("GL implementation cannot share GL contexts"));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -421,7 +442,8 @@ create_wgl_context (GdkGLContext *context,
|
|||||||
gboolean hasWglARBCreateContext,
|
gboolean hasWglARBCreateContext,
|
||||||
GdkGLContext *share,
|
GdkGLContext *share,
|
||||||
int flags,
|
int flags,
|
||||||
gboolean legacy)
|
gboolean legacy,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
/* We need a legacy context for *all* cases */
|
/* We need a legacy context for *all* cases */
|
||||||
HGLRC hglrc_base, hglrc;
|
HGLRC hglrc_base, hglrc;
|
||||||
@ -431,7 +453,15 @@ create_wgl_context (GdkGLContext *context,
|
|||||||
HGLRC hglrc_current = wglGetCurrentContext ();
|
HGLRC hglrc_current = wglGetCurrentContext ();
|
||||||
|
|
||||||
hglrc_base = wglCreateContext (hdc);
|
hglrc_base = wglCreateContext (hdc);
|
||||||
wglMakeCurrent (hdc, hglrc_base);
|
if (hglrc_base == NULL ||
|
||||||
|
!wglMakeCurrent (hdc, hglrc_base))
|
||||||
|
{
|
||||||
|
g_clear_pointer (&hglrc_base, wglDeleteContext);
|
||||||
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
|
_("Unable to create a GL context"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
hglrc = NULL;
|
hglrc = NULL;
|
||||||
|
|
||||||
@ -473,7 +503,7 @@ create_wgl_context (GdkGLContext *context,
|
|||||||
GDK_GL_API_GL,
|
GDK_GL_API_GL,
|
||||||
TRUE,
|
TRUE,
|
||||||
&version);
|
&version);
|
||||||
if (ensure_legacy_wgl_context (hdc, hglrc_base, share, &version))
|
if (ensure_legacy_wgl_context (hdc, hglrc_base, share, &version, error))
|
||||||
hglrc = g_steal_pointer (&hglrc_base);
|
hglrc = g_steal_pointer (&hglrc_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,15 +615,10 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
|||||||
display_win32->hasWglARBCreateContext,
|
display_win32->hasWglARBCreateContext,
|
||||||
share,
|
share,
|
||||||
flags,
|
flags,
|
||||||
legacy_bit);
|
legacy_bit,
|
||||||
|
error);
|
||||||
if (hglrc == NULL)
|
if (hglrc == NULL)
|
||||||
{
|
|
||||||
g_set_error_literal (error, GDK_GL_ERROR,
|
|
||||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
|
||||||
_("Unable to create a GL context"));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
GDK_NOTE (OPENGL,
|
GDK_NOTE (OPENGL,
|
||||||
g_print ("Created WGL context[%p], pixel_format=%d\n",
|
g_print ("Created WGL context[%p], pixel_format=%d\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user