Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created March 24, 2011 15:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save enjalot/885214 to your computer and use it in GitHub Desktop.
Save enjalot/885214 to your computer and use it in GitHub Desktop.
PyOpenCL .92 GL Interop
from OpenGL import GLX
def clinit(self):
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 == "win32":
props.append((ctx_props.WGL_HDC_KHR,
WGL.wglGetCurrentDC()))
self.ctx = cl.Context(properties=props)
self.queue = cl.CommandQueue(self.ctx)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment