diff --git a/examples/gl_interop_demo.py b/examples/gl_interop_demo.py
index dd4bf3e3abe962d37947a6ebfd88e1d40a6aefeb..468564cd0efb578ad450e587642d14f7fa3f6d23 100644
--- a/examples/gl_interop_demo.py
+++ b/examples/gl_interop_demo.py
@@ -1,75 +1,80 @@
-from OpenGL.GL import *
-from OpenGL.GLUT import *
-from OpenGL.raw.GL.VERSION.GL_1_5 import glBufferData as rawGlBufferData
-try:
-    from OpenGL.WGL import wglGetCurrentDisplay as GetCurrentDisplay, wglGetCurrentContext as GetCurrentContext
-except:
-    pass
-try:
-    from OpenGL.GLX import glXGetCurrentDisplay as GetCurrentDisplay, glXGetCurrentContext as GetCurrentContext
-except:
-    pass
-import pyopencl as cl
-
-
-n_vertices = 10000
-
-src = """
-
-__kernel void generate_sin(__global float2* a)
-{
-    int id = get_global_id(0);
-    int n = get_global_size(0);
-    float r = (float)id / (float)n;
-    float x = r * 16.0f * 3.1415f;
-    a[id].x = r * 2.0f - 1.0f;
-    a[id].y = native_sin(x);
-}
-
-"""
-
-def initialize():
-    plats = cl.get_platforms()
-    ctx_props = cl.context_properties
-    props = [(ctx_props.PLATFORM, plats[0]), (ctx_props.GL_CONTEXT_KHR,
-        GetCurrentContext()), (ctx_props.GLX_DISPLAY_KHR, GetCurrentDisplay())]
-    ctx = cl.Context(properties=props)
-    glClearColor(1, 1, 1, 1)
-    glColor(0, 0, 1)
-    vbo = glGenBuffers(1)
-    glBindBuffer(GL_ARRAY_BUFFER, vbo)
-    rawGlBufferData(GL_ARRAY_BUFFER, n_vertices * 2 * 4, None, GL_STATIC_DRAW)
-    glEnableClientState(GL_VERTEX_ARRAY)
-    glVertexPointer(2, GL_FLOAT, 0, None)
-    coords_dev = cl.GLBuffer(ctx, cl.mem_flags.READ_WRITE, int(vbo))
-    prog = cl.Program(ctx, src).build()
-    queue = cl.CommandQueue(ctx)
-    cl.enqueue_acquire_gl_objects(queue, [coords_dev])
-    prog.generate_sin(queue, (n_vertices,), None, coords_dev)
-    cl.enqueue_release_gl_objects(queue, [coords_dev])
-    queue.finish()
-    glFlush()
-
-def display():
-    glClear(GL_COLOR_BUFFER_BIT)
-    glDrawArrays(GL_LINE_STRIP, 0, n_vertices)
-    glFlush()
-
-def reshape(w, h):
-    glViewport(0, 0, w, h)
-    glMatrixMode(GL_PROJECTION)
-    glLoadIdentity()
-    glMatrixMode(GL_MODELVIEW)
-
-if __name__ == '__main__':
-    import sys
-    glutInit(sys.argv)
-    if len(sys.argv) > 1:
-        n_vertices = int(sys.argv[1])
-    glutInitWindowSize(800, 160)
-    glutInitWindowPosition(0, 0)
-    glutCreateWindow('OpenCL/OpenGL Interop Tutorial: Sin Generator')
-    glutDisplayFunc(display)
-    glutReshapeFunc(reshape)
-    initialize()
-    glutMainLoop()
+from OpenGL.GL import *
+from OpenGL.GLUT import *
+from OpenGL.raw.GL.VERSION.GL_1_5 import glBufferData as rawGlBufferData
+from OpenGL import platform, GLX, WGL
+import pyopencl as cl
+
+
+n_vertices = 10000
+
+src = """
+
+__kernel void generate_sin(__global float2* a)
+{
+    int id = get_global_id(0);
+    int n = get_global_size(0);
+    float r = (float)id / (float)n;
+    float x = r * 16.0f * 3.1415f;
+    a[id].x = r * 2.0f - 1.0f;
+    a[id].y = native_sin(x);
+}
+
+"""
+
+def initialize():
+    plats = cl.get_platforms()
+    ctx_props = cl.context_properties
+
+    props = [(ctx_props.PLATFORM, plats[0]), 
+            (ctx_props.GL_CONTEXT_KHR, platform.GetCurrentContext())]
+
+    import sys
+    if sys.platform == "linux2":
+        props.append(
+                (ctx_props.GLX_DISPLAY_KHR, 
+                    GLX.glXGetCurrentDisplay()))
+    elif sys.platform == "nt":
+        props.append(
+                (ctx_props.WGL_HDC_KHR, 
+                    WGL.wglGetCurrentDC()))
+    ctx = cl.Context(properties=props)
+
+    glClearColor(1, 1, 1, 1)
+    glColor(0, 0, 1)
+    vbo = glGenBuffers(1)
+    glBindBuffer(GL_ARRAY_BUFFER, vbo)
+    rawGlBufferData(GL_ARRAY_BUFFER, n_vertices * 2 * 4, None, GL_STATIC_DRAW)
+    glEnableClientState(GL_VERTEX_ARRAY)
+    glVertexPointer(2, GL_FLOAT, 0, None)
+    coords_dev = cl.GLBuffer(ctx, cl.mem_flags.READ_WRITE, int(vbo))
+    prog = cl.Program(ctx, src).build()
+    queue = cl.CommandQueue(ctx)
+    cl.enqueue_acquire_gl_objects(queue, [coords_dev])
+    prog.generate_sin(queue, (n_vertices,), None, coords_dev)
+    cl.enqueue_release_gl_objects(queue, [coords_dev])
+    queue.finish()
+    glFlush()
+
+def display():
+    glClear(GL_COLOR_BUFFER_BIT)
+    glDrawArrays(GL_LINE_STRIP, 0, n_vertices)
+    glFlush()
+
+def reshape(w, h):
+    glViewport(0, 0, w, h)
+    glMatrixMode(GL_PROJECTION)
+    glLoadIdentity()
+    glMatrixMode(GL_MODELVIEW)
+
+if __name__ == '__main__':
+    import sys
+    glutInit(sys.argv)
+    if len(sys.argv) > 1:
+        n_vertices = int(sys.argv[1])
+    glutInitWindowSize(800, 160)
+    glutInitWindowPosition(0, 0)
+    glutCreateWindow('OpenCL/OpenGL Interop Tutorial: Sin Generator')
+    glutDisplayFunc(display)
+    glutReshapeFunc(reshape)
+    initialize()
+    glutMainLoop()
diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp
index e001d907f11eb8e731c8de057446ac57c0ec6ba2..2975c14d7023f31a00f64277c629e2bb79877094 100644
--- a/src/wrapper/wrap_cl.hpp
+++ b/src/wrapper/wrap_cl.hpp
@@ -20,6 +20,12 @@
 #include <CL/cl.h>
 // FIXME: Nvidia doesn't install cl_ext.h by default. Grr.
 // #include <CL/cl_ext.h>
+
+#ifdef _WIN32
+#define NOMINMAX
+#include <windows.h>
+#endif
+
 #ifdef HAVE_GL
 #include <GL/gl.h>
 #include <CL/cl_gl.h>
@@ -2875,8 +2881,8 @@ namespace pyopencl
     std::vector<cl_context_properties> props
       = parse_context_properties(py_properties);
 
-    typedef CL_API_ENTRY cl_int CL_API_CALL
-      (*func_ptr_type)(const cl_context_properties * /* properties */,
+    typedef CL_API_ENTRY cl_int (CL_API_CALL
+      *func_ptr_type)(const cl_context_properties * /* properties */,
           cl_gl_context_info            /* param_name */,
           size_t                        /* param_value_size */,
           void *                        /* param_value */,
diff --git a/test/test_math.py b/test/test_math.py
index c7aabf4687d6d3997d5a37a3c5d4a249143fed1d..58b6a09bb958f9823a7e75b45198490e1ea7bcaf 100644
--- a/test/test_math.py
+++ b/test/test_math.py
@@ -78,8 +78,8 @@ if have_cl():
     test_floor = make_unary_function_test("ceil", (-10, 10))
     test_fabs = make_unary_function_test("fabs", (-10, 10))
     test_exp = make_unary_function_test("exp", (-3, 3), 1e-5)
-    test_log = make_unary_function_test("log", (1e-5, 1), 5e-7)
-    test_log10 = make_unary_function_test("log10", (1e-5, 1), 3e-7)
+    test_log = make_unary_function_test("log", (1e-5, 1), 1e-6)
+    test_log10 = make_unary_function_test("log10", (1e-5, 1), 5e-7)
     test_sqrt = make_unary_function_test("sqrt", (1e-5, 1), 2e-7)
 
     test_sin = make_unary_function_test("sin", (-10, 10), 1e-7)