Example #1
0
    def __init__(self, sound, medium):
        self._medium = medium
        self._movie = medium.movie
        self.sound = sound

        # Get CGL context and pixel format (10.4 only)
        agl_context = gl.get_current_context()._context
        agl_pixelformat = gl.get_current_context()._pixelformat
        cgl_context = ctypes.c_void_p()
        agl.aglGetCGLContext(agl_context, ctypes.byref(cgl_context))
        cgl_pixelformat = ctypes.c_void_p()
        agl.aglGetCGLPixelFormat(
            agl_pixelformat, ctypes.byref(cgl_pixelformat))


        # No attributes on texture contexts, only pixel buffer, according to
        # apple docs ref'd in class docstring.
        textureContextAttributes = None

        self.context = ctypes.c_void_p()
        r = quicktime.QTOpenGLTextureContextCreate(
            None,
            cgl_context,
            cgl_pixelformat, 
            textureContextAttributes,
            ctypes.byref(self.context))
        _oscheck(r)

        if textureContextAttributes:
            quicktime.CFRelease(textureContextAttributes)

        # Get dimensions of video
        rect = Rect()
        quicktime.GetMovieBox(self._movie, ctypes.byref(rect))
        self.width = rect.right - rect.left
        self.height = rect.bottom - rect.top

        # Set to null before setting real context to disassocate from
        # automatically created gworld.
        quicktime.SetMovieVisualContext(self._movie, None)
        quicktime.SetMovieVisualContext(self._movie, self.context)

        # Dummy texture object to hold id and target of textures returned by
        # corevideo.  XXX need to cleanup texture data after first frame
        # retrieved.
        self._texture = image.Texture.create_for_size(GL_TEXTURE_2D,
            self.width, self.height)

        self._last_cv_image = None
Example #2
0
def errcheck_glbegin(result, func, arguments):
    from pyglet.gl import get_current_context
    context = get_current_context()
    if not context:
        raise GLException('No GL context; create a Window first')
    context._gl_begin = True
    return result
Example #3
0
def errcheck_glend(result, func, arguments):
    from pyglet.gl import get_current_context
    context = get_current_context()
    if not context:
        raise GLException('No GL context; create a Window first')
    context._gl_begin = False
    return errcheck(result, func, arguments)
Example #4
0
def errcheck(result, func, arguments):
    from pyglet.gl import get_current_context
    context = get_current_context()
    if not context:
        raise GLException('No GL context; create a Window first')
    if not context._gl_begin:
        from pyglet.gl import glGetError, gluErrorString
        error = glGetError()
        if error:
            message = ctypes.cast(gluErrorString(error), ctypes.c_char_p).value
            raise GLException(message)
        return result
Example #5
0
def errcheck(result, func, arguments):
    from pyglet.gl import get_current_context
    context = get_current_context()
    if not context:
        raise GLException('No GL context; create a Window first')
    if not context._gl_begin:
        from pyglet.gl import glGetError, gluErrorString
        error = glGetError()
        if error:
            message = ctypes.cast(gluErrorString(error), ctypes.c_char_p).value
            raise GLException(message)
        return result