Matteo Bruni : opengl32: Don' t use deprecated functions for extension checking purposes on core profile contexts.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Feb 2 08:32:23 CST 2015
Module: wine
Branch: master
Commit: 1e48bbb7acf3bfc43c5d041a2680d73aed9e40c4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1e48bbb7acf3bfc43c5d041a2680d73aed9e40c4
Author: Matteo Bruni <mbruni at codeweavers.com>
Date: Thu Jan 29 18:45:00 2015 +0100
opengl32: Don't use deprecated functions for extension checking purposes on core profile contexts.
---
dlls/opengl32/wgl.c | 44 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 32d241c..cb91699 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -162,6 +162,12 @@ static void free_handle_ptr( struct wgl_handle *ptr )
LeaveCriticalSection( &wgl_section );
}
+static inline enum wgl_handle_type get_current_context_type(void)
+{
+ if (!NtCurrentTeb()->glCurrentRC) return HANDLE_CONTEXT;
+ return (LOWORD(NtCurrentTeb()->glCurrentRC) & HANDLE_TYPE_MASK) >> 12;
+}
+
/***********************************************************************
* wglCopyContext (OPENGL32.@)
*/
@@ -684,6 +690,30 @@ int WINAPI wglGetLayerPaletteEntries(HDC hdc,
/* check if the extension is present in the list */
static BOOL has_extension( const char *list, const char *ext, size_t len )
{
+ if (!list)
+ {
+ const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
+ const char *gl_ext;
+ unsigned int i;
+ GLint extensions_count;
+
+ if (!funcs->ext.p_glGetStringi)
+ {
+ void **func_ptr = (void **)&funcs->ext.p_glGetStringi;
+
+ *func_ptr = funcs->wgl.p_wglGetProcAddress("glGetStringi");
+ }
+
+ glGetIntegerv(GL_NUM_EXTENSIONS, &extensions_count);
+ for (i = 0; i < extensions_count; ++i)
+ {
+ gl_ext = (const char *)funcs->ext.p_glGetStringi(GL_EXTENSIONS, i);
+ if (!strncmp(gl_ext, ext, len) && !gl_ext[len])
+ return TRUE;
+ }
+ return FALSE;
+ }
+
while (list)
{
while (*list == ' ') list++;
@@ -701,15 +731,21 @@ static int compar(const void *elt_a, const void *elt_b) {
/* Check if a GL extension is supported */
static BOOL is_extension_supported(const char* extension)
{
+ enum wgl_handle_type type = get_current_context_type();
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- const char *gl_ext_string = (const char*)glGetString(GL_EXTENSIONS);
+ const char *gl_ext_string = NULL;
size_t len;
TRACE("Checking for extension '%s'\n", extension);
- if(!gl_ext_string) {
- ERR("No OpenGL extensions found, check if your OpenGL setup is correct!\n");
- return FALSE;
+ if (type == HANDLE_CONTEXT)
+ {
+ gl_ext_string = (const char*)glGetString(GL_EXTENSIONS);
+ if (!gl_ext_string)
+ {
+ ERR("No OpenGL extensions found, check if your OpenGL setup is correct!\n");
+ return FALSE;
+ }
}
/* We use the GetProcAddress function from the display driver to retrieve function pointers
More information about the wine-cvs
mailing list