예제 #1
0
 def clinit(self):
     plats = cl.get_platforms()
     from pyopencl.tools import get_gl_sharing_context_properties
     if sys.platform == "darwin":
         self.ctx= cl.create_some_context()
         #print cl.context_properties.
         #print get_gl_sharing_context_properties()
         #print "ctx_props.CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE", cl.get_apple_cgl_share_group()
         print cl.get_apple_cgl_share_group()
         #self.ctx = cl.Context(properties=get_gl_sharing_context_properties(), devices=[])
     else:
         self.ctx = cl.Context(properties=[(cl.context_properties.PLATFORM, plats[0])]
             + get_gl_sharing_context_properties(), devices=None)
             
     self.queue = cl.CommandQueue(self.ctx)
예제 #2
0
def get_gl_sharing_context_properties():
    ctx_props = cl.context_properties

    from OpenGL import platform as gl_platform

    props = []

    import sys
    if sys.platform in ["linux", "linux2"]:
        from OpenGL import GLX
        props.append(
            (ctx_props.GL_CONTEXT_KHR, gl_platform.GetCurrentContext()))
        props.append((ctx_props.GLX_DISPLAY_KHR, GLX.glXGetCurrentDisplay()))
    elif sys.platform == "win32":
        from OpenGL import WGL
        props.append(
            (ctx_props.GL_CONTEXT_KHR, gl_platform.GetCurrentContext()))
        props.append((ctx_props.WGL_HDC_KHR, WGL.wglGetCurrentDC()))
    elif sys.platform == "darwin":
        props.append((ctx_props.CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
                      cl.get_apple_cgl_share_group()))
    else:
        raise NotImplementedError("platform '%s' not yet supported" %
                                  sys.platform)

    return props
예제 #3
0
def get_gl_sharing_context_properties():
    ctx_props = cl.context_properties

    from OpenGL import platform as gl_platform, GLX, WGL

    props = []

    import sys
    if sys.platform in ["linux", "linux2"]:
        props.append(
            (ctx_props.GL_CONTEXT_KHR, gl_platform.GetCurrentContext()))
        props.append(
                (ctx_props.GLX_DISPLAY_KHR,
                    GLX.glXGetCurrentDisplay()))
    elif sys.platform == "win32":
        props.append(
            (ctx_props.GL_CONTEXT_KHR, gl_platform.GetCurrentContext()))
        props.append(
                (ctx_props.WGL_HDC_KHR,
                    WGL.wglGetCurrentDC()))
    elif sys.platform == "darwin":
        props.append(
            (ctx_props.CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
                cl.get_apple_cgl_share_group()))
    else:
        raise NotImplementedError("platform '%s' not yet supported"
                % sys.platform)

    return props