gdk/win32: Fix Win32 GL Context switching
authorChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 30 Oct 2017 07:00:28 +0000 (15:00 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Sat, 4 Nov 2017 02:39:03 +0000 (10:39 +0800)
commit322814989280441c25fc654dba4b7ac427fdfb57
treec45169cccc6f4b7d9054e61ff8eeeaec4149bfd2
parent6a12a3cd10c9985d2dbbf176e6899b54880e14dd
gdk/win32: Fix Win32 GL Context switching

Since on Windows we need to use a good amount of temporary GL contexts,
we need to switch back to the original GL contexts we were using when
we are done with the temporary GL contexts, otherwise multi-GL windows
will cause confusions causing display artifacts and crashes.

Also, use the GdkWin32GLContext::gl_hdc consistently throughout
the code and remove the GdkWin32Display::gl_hdc as Lukas K pointed out
that GdkWin32Display::gl_hdc becomes out-of-date and so the HDC that the
GL context is bound to becomes incorrect in sceanarios using multiple
windows with GtkGLArea/GdkGLArea items (which would cause the artifacts in
programs that use multiple windows with GtkGLArea/GdkGLArea items, and it
turns out that GdkWin32Display::gl_hdc is actually not necessary to help
keep track of the HDCs we use for our GL contexts.

This will also fix on Windows with GDK_GL=always, or when GSK's gl
renderer is used.

Partly based on patch from Lukas K <lu@0x83.eu>

https://bugzilla.gnome.org/show_bug.cgi?id=789213
gdk/win32/gdkdisplay-win32.h
gdk/win32/gdkglcontext-win32.c