diff --git a/doc/source/misc.rst b/doc/source/misc.rst index f94b716252cb0acb5af923806b690547e634b8a8..c96af3d1c1edde33aac64cc308ef3ae73ae14bd9 100644 --- a/doc/source/misc.rst +++ b/doc/source/misc.rst @@ -15,8 +15,8 @@ Acknowledgments * Achim Gottinger submitted a fix for an example. * Andrew Karpushin provided a fix for a whole class of crash bugs in PyOpenCL. -* Paolo Simone Gasparello provided much help in getting OpenCL-OpenGL - interoperability to work. +* Paolo Simone Gasparello, Keith Brafford, and Ian Johnson provided much help + in getting OpenCL-OpenGL interoperability to work. Guidelines ========== diff --git a/examples/gl_interop_demo.py b/examples/gl_interop_demo.py index 964682bb9422554d4a768877ef80ccc015219bb2..99524cb30b3662b09aa4599d14d6df259ff6f340 100644 --- a/examples/gl_interop_demo.py +++ b/examples/gl_interop_demo.py @@ -21,17 +21,25 @@ __kernel void generate_sin(__global float2* a) """ def initialize(): - plats = cl.get_platforms() + platform = cl.get_platforms()[0] from pyopencl.tools import get_gl_sharing_context_properties import sys if sys.platform == "darwin": ctx = cl.Context(properties=get_gl_sharing_context_properties(), - devices=[]) + devices=[]) else: - ctx = cl.Context(properties=[ - (cl.context_properties.PLATFORM, plats[0])] - + get_gl_sharing_context_properties()) + # Some OSs prefer clCreateContextFromType, some prefer + # clCreateContext. Try both. + try: + ctx = cl.Context(properties=[ + (cl.context_properties.PLATFORM, platform)] + + get_gl_sharing_context_properties()) + except: + ctx = cl.Context(properties=[ + (cl.context_properties.PLATFORM, platform)] + + get_gl_sharing_context_properties(), + devices = [platform.get_devices()[0]]) glClearColor(1, 1, 1, 1) glColor(0, 0, 1)