[PATCH 3/5] opengl32: Fix extension checks on OpenGL core profile contexts.
Matteo Bruni
mbruni at codeweavers.com
Mon Jan 5 10:17:53 CST 2015
---
dlls/opengl32/wgl.c | 42 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 3a5e148..54f2aea 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "wine/port.h"
+#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -667,6 +668,23 @@ 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;
+
+ 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++;
@@ -685,14 +703,30 @@ static int compar(const void *elt_a, const void *elt_b) {
static BOOL is_extension_supported(const char* extension)
{
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
- const char *gl_ext_string = (const char*)glGetString(GL_EXTENSIONS);
+ const char *gl_ext_string = NULL, *gl_version;
size_t len;
+ unsigned int major;
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;
+ gl_version = (const char *)glGetString(GL_VERSION);
+ sscanf(gl_version, "%u", &major);
+ if (major >= 3)
+ {
+ if (!funcs->ext.p_glGetStringi)
+ {
+ void **func_ptr = (void **)&funcs->ext.p_glGetStringi;
+ *func_ptr = funcs->wgl.p_wglGetProcAddress("glGetStringi");
+ }
+ }
+ else
+ {
+ 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
--
2.0.5
More information about the wine-patches
mailing list