Пример #1
0
    def _recreate(self, changes):
        # If flipping to/from fullscreen and using override_redirect (we
        # always are, _NET_WM_FULLSCREEN doesn't work), need to recreate the
        # window.
        #
        # A possible improvement could be to just hide the top window,
        # destroy the GLX window, and reshow it again when leaving fullscreen.
        # This would prevent the floating window from being moved by the
        # WM.
        if 'fullscreen' in changes or 'resizable' in changes:
            # clear out the GLX context
            self.switch_to()
            gl.glFlush()
            glx.glXMakeCurrent(self._x_display, 0, None)
            if self._glx_window:
                glx.glXDestroyWindow(self._x_display, self._glx_window)
            xlib.XDestroyWindow(self._x_display, self._window)
            self._glx_window = None
            self._window = None 
            self._mapped = False

        # TODO: detect state loss only by examining context share.
        if 'context' in changes:
            self._lost_context = True
            self._lost_context_state = True

        self._create()
Пример #2
0
    def _recreate(self, changes):
        # If flipping to/from fullscreen and using override_redirect (we
        # always are, _NET_WM_FULLSCREEN doesn't work), need to recreate the
        # window.
        #
        # A possible improvement could be to just hide the top window,
        # destroy the GLX window, and reshow it again when leaving fullscreen.
        # This would prevent the floating window from being moved by the
        # WM.
        if 'fullscreen' in changes or 'resizable' in changes:
            # clear out the GLX context
            self.switch_to()
            gl.glFlush()
            glx.glXMakeCurrent(self._x_display, 0, None)
            if self._glx_window:
                glx.glXDestroyWindow(self._x_display, self._glx_window)
            xlib.XDestroyWindow(self._x_display, self._window)
            self._glx_window = None
            self._window = None
            self._mapped = False

        # TODO: detect state loss only by examining context share.
        if 'context' in changes:
            self._lost_context = True
            self._lost_context_state = True

        self._create()
Пример #3
0
    def detach(self):
        if not self.canvas:
            return

        self.set_current()
        gl.glFlush()
        glx.glXMakeCurrent(self.x_display, 0, None)
        super(XlibContext10, self).detach()
Пример #4
0
    def detach(self):
        if not self.canvas:
            return

        self.set_current()
        gl.glFlush()
        glx.glXMakeCurrent(self.x_display, 0, None)
        super(XlibContext10, self).detach()
Пример #5
0
    def _switch_to_impl(self):
        if not self._window:
            return

        if self._glx_1_3:
            glx.glXMakeContextCurrent(self._x_display, self._glx_window, self._glx_window, self._glx_context)
        else:
            glx.glXMakeCurrent(self._x_display, self._window, self._glx_context)
Пример #6
0
    def _switch_to_impl(self):
        if not self._window:
            return

        if self._glx_1_3:
            glx.glXMakeContextCurrent(self._x_display, self._glx_window,
                                      self._glx_window, self._glx_context)
        else:
            glx.glXMakeCurrent(self._x_display, self._window,
                               self._glx_context)
Пример #7
0
 def switch_to(self):
     if sys.platform == 'darwin':
         agl.aglSetCurrentContext(self._agl_context)
         _aglcheck()
     elif sys.platform in ('win32', 'cygwin'):
         self._dc = _user32.GetDC(self.window.handle)
         self.context._set_window(self)
         wgl.wglMakeCurrent(self._dc, self.context.glx_context)
     else:
         glx.glXMakeCurrent(self.context.x_display, self.get_property('window').get_xid(),self.context.glx_context)
     self.context.set_current()
     gl_info.set_active_context()
     glu_info.set_active_context()
Пример #8
0
    def switch_to(self):
        if self._glx_1_3:
            if not self._glx_window:
                self._glx_window = glx.glXCreateWindow(self._x_display,
                    self._config._fbconfig, self._window, None)
            glx.glXMakeContextCurrent(self._x_display,
                self._glx_window, self._glx_window, self._glx_context)
        else:
            glx.glXMakeCurrent(self._x_display, self._window, self._glx_context)

        self.set_vsync(self._vsync)

        self._context.set_current()
        gl_info.set_active_context()
        glu_info.set_active_context()
Пример #9
0
    def close(self):
        # clear out the GLX context.  Can fail if current context already
        # destroyed (on exit, say).
        try:
            gl.glFlush()
        except gl.GLException:
            pass
        glx.glXMakeCurrent(self._x_display, 0, None)

        self._unmap()
        if self._glx_window:
            glx.glXDestroyWindow(self._x_display, self._glx_window)
        if self._window:
            xlib.XDestroyWindow(self._x_display, self._window)

        self._window = None
        self._glx_window = None
Пример #10
0
    def switch_to(self):
        if self._glx_1_3:
            if not self._glx_window:
                self._glx_window = glx.glXCreateWindow(self._x_display,
                                                       self._config._fbconfig,
                                                       self._window, None)
            glx.glXMakeContextCurrent(self._x_display, self._glx_window,
                                      self._glx_window, self._glx_context)
        else:
            glx.glXMakeCurrent(self._x_display, self._window,
                               self._glx_context)

        self.set_vsync(self._vsync)

        self._context.set_current()
        gl_info.set_active_context()
        glu_info.set_active_context()
Пример #11
0
    def close(self):
        # clear out the GLX context.  Can fail if current context already
        # destroyed (on exit, say).
        try:
            gl.glFlush()
        except gl.GLException:
            pass
        glx.glXMakeCurrent(self._x_display, 0, None)

        self._unmap()
        if self._glx_window:
            glx.glXDestroyWindow(self._x_display, self._glx_window)
        if self._window:
            xlib.XDestroyWindow(self._x_display, self._window)

        self._window = None
        self._glx_window = None

        if _have_utf8:
            xlib.XDestroyIC(self._x_ic)
            xlib.XCloseIM(self._x_im)
Пример #12
0
 def set_current(self):
     glx.glXMakeCurrent(self.x_display, self.canvas.x_window,
                        self.glx_context)
     super(XlibContext10, self).set_current()
Пример #13
0
 def set_current(self):
     glx.glXMakeCurrent(self.x_display, self.canvas.x_window, 
                        self.glx_context)
     super(XlibContext10, self).set_current()