예제 #1
0
    def __init__(self, config, share):
        super(BaseXlibContext, self).__init__(config, share)

        self.x_display = config.canvas.display._display

        self.glx_context = self._create_glx_context(share)
        glx_context_id = self.glx_context
        if glx_context_id == glx.GLX_BAD_CONTEXT:
            raise gl.ContextException('Invalid context share')
        elif glx_context_id == glx.GLXBadFBConfig:
            raise gl.ContextException('Invalid GL configuration')
        elif glx_context_id < 0:
            raise gl.ContextException('Could not create GL context')

        self._have_SGI_video_sync = \
            config.glx_info.have_extension('GLX_SGI_video_sync')
        self._have_SGI_swap_control = \
            config.glx_info.have_extension('GLX_SGI_swap_control')
        self._have_MESA_swap_control = \
            config.glx_info.have_extension('GLX_MESA_swap_control')

        # In order of preference:
        # 1. GLX_MESA_swap_control (more likely to work where video_sync will
        #    not)
        # 2. GLX_SGI_video_sync (does not work on Intel 945GM, but that has
        #    MESA)
        # 3. GLX_SGI_swap_control (cannot be disabled once enabled).
        self._use_video_sync = (self._have_SGI_video_sync
                                and not self._have_MESA_swap_control)

        # XXX mandate that vsync defaults on across all platforms.
        self._vsync = True
예제 #2
0
    def create_context(self, share):
        context = self._create_glx_context(share)

        if context == glx.GLX_BAD_CONTEXT:
            raise gl.ContextException('Invalid context share')
        elif context == glx.GLXBadFBConfig:
            raise gl.ContextException('Invalid GL configuration')
        elif context < 0:
            raise gl.ContextException('Could not create GL context')

        return XlibGLContext(self, context, share)
예제 #3
0
    def __init__(self, config, share):
        super(BaseXlibContext, self).__init__(config, share)

        self.x_display = config.canvas.display._display

        self.glx_context = self._create_glx_context(share)
        if not self.glx_context:
            # TODO: Check Xlib error generated
            raise gl.ContextException('Could not create GL context')

        self._have_SGI_video_sync = config.glx_info.have_extension(
            'GLX_SGI_video_sync')
        self._have_SGI_swap_control = config.glx_info.have_extension(
            'GLX_SGI_swap_control')
        self._have_EXT_swap_control = config.glx_info.have_extension(
            'GLX_EXT_swap_control')
        self._have_MESA_swap_control = config.glx_info.have_extension(
            'GLX_MESA_swap_control')

        # In order of preference:
        # 1. GLX_EXT_swap_control (more likely to work where video_sync will not)
        # 2. GLX_MESA_swap_control (same as above, but supported by MESA drivers)
        # 3. GLX_SGI_video_sync (does not work on Intel 945GM, but that has EXT)
        # 4. GLX_SGI_swap_control (cannot be disabled once enabled)
        self._use_video_sync = (self._have_SGI_video_sync
                                and not (self._have_EXT_swap_control
                                         or self._have_MESA_swap_control))

        # XXX mandate that vsync defaults on across all platforms.
        self._vsync = True
예제 #4
0
 def _set_window(self, window):
     assert self._context is None
     _gdi32.SetPixelFormat(window._dc, self.config._pf, None)
     self._context = wgl.wglCreateContext(window._dc)
     if self._share:
         assert self._share._context is not None
         if not wgl.wglShareLists(self._share._context, self._context):
             raise gl.ContextException('Unable to share contexts')
예제 #5
0
파일: headless.py 프로젝트: thabotr/pyglet
    def __init__(self, config, share):
        super(HeadlessContext, self).__init__(config, share)

        self.display_connection = config.canvas.display._display_connection

        self.egl_context = self._create_egl_context(share)
        if not self.egl_context:
            raise gl.ContextException('Could not create GL context')
예제 #6
0
    def attach(self, canvas):
        if self.config._requires_gl_3():
            raise gl.ContextException(
                'Require WGL_ARB_create_context extension to create ' +
                'OpenGL 3 contexts.')

        super(Win32Context, self).attach(canvas)

        self.config._set_pixel_format(canvas)
        self._context = wgl.wglCreateContext(canvas.hdc)

        share = self.context_share
        if share:
            if not share.canvas:
                raise RuntimeError('Share context has no canvas.')
            if not wgl.wglShareLists(share._context, self._context):
                raise gl.ContextException('Unable to share contexts')
예제 #7
0
파일: xlib.py 프로젝트: thabotr/pyglet
    def _create_glx_context(self, share):
        if self.config.requires_gl_3():
            raise gl.ContextException(
                'Require GLX_ARB_create_context extension to create OpenGL 3 contexts.')

        if share:
            share_context = share.glx_context
        else:
            share_context = None

        return glx.glXCreateContext(self.config.canvas.display._display,
                                    self.config._visual_info, share_context, True)
예제 #8
0
    def attach(self, canvas):
        super(Win32Context, self).attach(canvas)

        if not self._context:
            self.config._set_pixel_format(canvas)
            self._context = wgl.wglCreateContext(canvas.hdc)

        share = self.context_share
        if share:
            if not share.canvas:
                raise RuntimeError('Share context has no canvas.')
            if not wgl.wglShareLists(share._context, self._context):
                raise gl.ContextException('Unable to share contexts.')
예제 #9
0
    def _create_glx_context(self, share):
        if self.config._requires_gl_3():
            raise gl.ContextException(
                'Require GLX_ARB_create_context extension to create ' +
                'OpenGL 3 contexts.')

        if share:
            share_context = share.glx_context
        else:
            share_context = None

        return glx.glXCreateNewContext(self.config.canvas.display._display, 
            self.config._fbconfig, glx.GLX_RGBA_TYPE, share_context, True)
예제 #10
0
    def __init__(self, screen, attrib_list):
        self.screen = screen
        self._display = screen.display._display
        self._visual_info = glx.glXChooseVisual(self._display,
                                                screen._x_screen_id,
                                                attrib_list)
        if not self._visual_info:
            raise gl.ContextException('No conforming visual exists')

        for name, attr in self.attribute_ids.items():
            value = c_int()
            result = glx.glXGetConfig(self._display, self._visual_info, attr,
                                      byref(value))
            if result >= 0:
                setattr(self, name, value.value)
        self.sample_buffers = 0
        self.samples = 0
예제 #11
0
    def __init__(self, canvas, glx_info, attrib_list, config):
        super(XlibCanvasConfig10, self).__init__(canvas, glx_info, config)
        x_display = canvas.display._display
        x_screen = canvas.display.x_screen

        self._visual_info = glx.glXChooseVisual(x_display, x_screen,
                                                attrib_list)
        if not self._visual_info:
            raise gl.ContextException('No conforming visual exists')

        for name, attr in self.attribute_ids.items():
            value = c_int()
            result = glx.glXGetConfig(x_display, self._visual_info, attr,
                                      byref(value))
            if result >= 0:
                setattr(self, name, value.value)
        self.sample_buffers = 0
        self.samples = 0