[waffle] [PATCH 08/53] wgl: wire-up waffle_get_proc_address()

Emil Velikov emil.l.velikov at gmail.com
Sun Nov 9 14:58:49 PST 2014


For WGL we need a current context otherwise wglGetProcAddress will
return NULL pointer. Notice this in the documentation and leave it
up-to the user to design/use waffle in such a way this will work.

Remove the mesa workaround from gl_basic_test. Suggested by Chad.

Cc: Chad Versace <chad.versace at linux.intel.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 man/waffle_get_proc_address.3.xml | 15 ++++++++++++++-
 src/waffle/wgl/wgl_platform.c     |  3 ++-
 tests/functional/gl_basic_test.c  |  9 ---------
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/man/waffle_get_proc_address.3.xml b/man/waffle_get_proc_address.3.xml
index 36b9ea2..fea2dff 100644
--- a/man/waffle_get_proc_address.3.xml
+++ b/man/waffle_get_proc_address.3.xml
@@ -66,6 +66,9 @@
             On CGL, this function returns <constant>NULL</constant>
 
             because there exists no <function>CGLGetProcAdress()</function>.
+
+            On WGL, this redirects to
+            <citerefentry><refentrytitle><function>wglGetProcAddress</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>.
           </para>
 
           <para>
@@ -89,6 +92,14 @@
                   then <function>waffle_get_proc_address()</function> may return a <constant>NULL</constant>.
                 </para>
               </listitem>
+
+              <listitem>
+                <para>
+                  Under Windows (WGL) a current context must be available before executing the function.
+
+                  Otherwise <function>waffle_get_proc_address()</function> may return a <constant>NULL</constant>.
+                </para>
+              </listitem>
             </itemizedlist>
           </para>
 
@@ -99,7 +110,9 @@
 
             the <ulink url="http://www.opengl.org/registry/doc/glx1.4.pdf">GLX 1.4 Specification</ulink>
 
-            or the <ulink url="http://www.khronos.org/registry/egl/specs/eglspec.1.4.20110406.pdf">EGL 1.4 Specification</ulink>.
+            the <ulink url="http://www.khronos.org/registry/egl/specs/eglspec.1.4.20110406.pdf">EGL 1.4 Specification</ulink>
+
+            or the <ulink url="http://msdn.microsoft.com/en-gb/library/windows/desktop/dd374386(v=vs.85).aspx">MSDN article</ulink>.
           </para>
         </listitem>
       </varlistentry>
diff --git a/src/waffle/wgl/wgl_platform.c b/src/waffle/wgl/wgl_platform.c
index 2f88aff..573d5e6 100644
--- a/src/waffle/wgl/wgl_platform.c
+++ b/src/waffle/wgl/wgl_platform.c
@@ -24,6 +24,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <stdlib.h>
+#include <windows.h>
 
 #include "wcore_error.h"
 
@@ -128,7 +129,7 @@ wgl_make_current(struct wcore_platform *wc_self,
 static void*
 wgl_get_proc_address(struct wcore_platform *wc_self, const char *name)
 {
-    return NULL;
+    return wglGetProcAddress(name);
 }
 
 static const struct wcore_platform_vtbl wgl_platform_vtbl = {
diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 035b221..c73e1f9 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -235,15 +235,6 @@ gl_basic_draw__(struct gl_basic_draw_args__ args)
     config_attrib_list[i++] = alpha;
     config_attrib_list[i++] = 0;
 
-    // Check that we've set the EGL_PLATFORM environment variable for Mesa.
-    //
-    // If Mesa's libEGL is built with support for multiple platforms, then the
-    // environment variable EGL_PLATFORM must be set before the first EGL
-    // call. Otherwise, libEGL may initialize itself with the incorrect
-    // platform. In my experiments, first calling eglGetProcAddress will
-    // produce a segfault in eglInitialize.
-    waffle_get_proc_address("glClear");
-
     // Create objects.
     ASSERT_TRUE(dpy = waffle_display_connect(NULL));
 
-- 
2.1.3



More information about the waffle mailing list