1 /* Support for window-specific OpenGL extensions.
3 * Copyright (c) 2004 Lionel Ulmer
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/port.h"
34 #include "opengl_ext.h"
35 #include "wine/library.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
40 /* Some WGL extensions... */
41 static const char *WGL_extensions_base = "WGL_ARB_extensions_string WGL_EXT_extensions_string";
42 static char *WGL_extensions = NULL;
44 /* Extensions-query functions */
45 BOOL query_function_pbuffers(const char *gl_version, const char *gl_extensions, const char *glx_extensions,
46 const char *server_glx_extensions, const char *client_glx_extensions)
51 /***********************************************************************
52 * wglGetExtensionsStringEXT(OPENGL32.@)
54 const char * WINAPI wglGetExtensionsStringEXT(void) {
55 TRACE("() returning \"%s\"\n", WGL_extensions);
57 return WGL_extensions;
60 /***********************************************************************
61 * wglGetExtensionsStringARB(OPENGL32.@)
63 const char * WINAPI wglGetExtensionsStringARB(HDC hdc) {
64 TRACE("() returning \"%s\"\n", WGL_extensions);
66 return WGL_extensions;
71 BOOL (*query_function)(const char *gl_version, const char *gl_extensions, const char *glx_extensions,
72 const char *server_glx_extensions, const char *client_glx_extensions);
73 } extension_list[] = {
74 { "WGL_ARB_pbuffer", query_function_pbuffers }
77 /* Used to initialize the WGL extension string at DLL loading */
78 void wgl_ext_initialize_extensions(Display *display, int screen)
80 int size = strlen(WGL_extensions_base);
81 const char *glx_extensions = glXQueryExtensionsString(display, screen);
82 const char *server_glx_extensions = glXQueryServerString(display, screen, GLX_EXTENSIONS);
83 const char *client_glx_extensions = glXGetClientString(display, GLX_EXTENSIONS);
84 const char *gl_extensions = (const char *) glGetString(GL_EXTENSIONS);
85 const char *gl_version = (const char *) glGetString(GL_VERSION);
88 TRACE("GL version : %s.\n", debugstr_a(gl_version));
89 TRACE("GL exts : %s.\n", debugstr_a(gl_extensions));
90 TRACE("GLX exts : %s.\n", debugstr_a(glx_extensions));
91 TRACE("Server GLX exts : %s.\n", debugstr_a(server_glx_extensions));
92 TRACE("Client GLX exts : %s.\n", debugstr_a(client_glx_extensions));
94 for (i = 0; i < (sizeof(extension_list) / sizeof(extension_list[0])); i++) {
95 if (extension_list[i].query_function(gl_version, gl_extensions, glx_extensions,
96 server_glx_extensions, client_glx_extensions)) {
97 size += strlen(extension_list[i].name) + 1;
101 /* For the moment, only 'base' extensions are supported. */
102 WGL_extensions = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + 1);
103 if (WGL_extensions == NULL) {
104 WGL_extensions = (char *) WGL_extensions_base;
106 strcpy(WGL_extensions, WGL_extensions_base);
107 for (i = 0; i < (sizeof(extension_list) / sizeof(extension_list[0])); i++) {
108 if (extension_list[i].query_function(gl_version, gl_extensions, glx_extensions,
109 server_glx_extensions, client_glx_extensions)) {
110 strcat(WGL_extensions, " ");
111 strcat(WGL_extensions, extension_list[i].name);
116 TRACE("Supporting following WGL extensions : %s.\n", debugstr_a(WGL_extensions));
119 void wgl_ext_finalize_extensions(void)
121 if (WGL_extensions != WGL_extensions_base) {
122 HeapFree(GetProcessHeap(), 0, WGL_extensions);
126 /* Putting this at the end to prevent having to write the prototypes :-) */
127 WGL_extension wgl_extension_registry[] = {
128 { "wglGetExtensionsStringARB", (void *) wglGetExtensionsStringARB, NULL, NULL},
129 { "wglGetExtensionsStringEXT", (void *) wglGetExtensionsStringEXT, NULL, NULL}
131 int wgl_extension_registry_size = sizeof(wgl_extension_registry) / sizeof(wgl_extension_registry[0]);