# OpenGL¶

pycuda.gl.make_context(dev, flags=0)

Create and return a pycuda.driver.Context that has GL interoperability enabled.

Warning

This will fail with a rather unhelpful error message if you don’t already have a GL context created and active.

class pycuda.gl.graphics_map_flags

Usage of OpenGL object from CUDA.

NONE

READ_ONLY

WRITE_DISCARD

class pycuda.gl.RegisteredBuffer(bufobj, flags = CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)

Object managing mapping of OpenGL buffers to CUDA. Cannot be used to map images.

gl_handle()
unregister()
map(stream=None)

Return a RegisteredMapping.

class pycuda.gl.RegisteredImage(bufobj, target, flags = CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)

Object managing mapping of OpenGL textures and render buffers to CUDA.

target must be be one of:

• GL_TEXTURE_2D

• GL_TEXTURE_RECTANGLE

• GL_TEXTURE_CUBE_MAP

• GL_TEXTURE_3D

• GL_TEXTURE_2D_ARRAY

• GL_RENDERBUFFER

(see PyOpenGL docs)

gl_handle()
unregister()
map(stream=None)

Return a RegisteredMapping.

class pycuda.gl.RegisteredMapping
unmap(stream=None)

If no stream is specified, the unmap will use the same stream as the original mapping.

device_ptr_and_size()

Return a tuple (dev_pointer, size).

array(index, level)

Return an array for mapped image object for given array index and MIP level.

## Automatic Initialization¶

Warning

Importing pycuda.gl.autoinit will fail with a rather unhelpful error message if you don’t already have a GL context created and active.

pycuda.gl.autoinit.device
pycuda.gl.autoinit.context

## Old-style (pre-CUDA 3.0) API¶

pycuda.gl.autoinit.init()

Enable GL interoperability for the already-created (so far non-GL) and currently active pycuda.driver.Context.

According to the forum post referenced in the note below, this will succeed on Windows XP and Linux, but it will not work on Windows Vista. There you have to create the GL-enabled context using make_context().

Warning

This function is deprecated since CUDA 3.0 and PyCUDA 2011.1.

Warning

This will fail with a rather unhelpful error message if you don’t already have a GL context created and active.

Note

See this post on the Nvidia forums for a discussion of problems and solutions with the GL interop interface.

class pycuda.gl.autoinit.BufferObject(bufobj)

Warning

This class is deprecated since CUDA 3.0 and PyCUDA 2011.1.

unregister()
handle
map()
class pycuda.gl.autoinit.BufferObjectMapping

Warning

This class is deprecated since CUDA 3.0 and PyCUDA 2011.1. It will be removed in PyCUDA 0.96.

unmap()
device_ptr()
size()