示例#1
0
    def video_quit(self):
        """This function closes any open rendering window and shuts down the
        video system. The default SDL implementation of this function calls
        SDL_QuitSubSystem(SDL_INIT_VIDEO). This function should be called from
        within the RomClosed() video plugin function.
        PROTOTYPE:
         m64p_error VidExt_Quit(void)"""
        log.debug("Vidext: video_quit()")

        # Nullify those EGL variables
        if self.egl_context != egl.EGL_NO_CONTEXT:
            egl.eglDestroyContext(self.egl_display, self.egl_context)
            self.egl_context = egl.EGL_NO_CONTEXT

        egl.eglMakeCurrent(self.egl_display, egl.EGL_NO_SURFACE,
                           egl.EGL_NO_SURFACE, egl.EGL_NO_CONTEXT)
        if self.egl_surface != egl.EGL_NO_SURFACE:
            egl.eglDestroySurface(self.egl_display, self.egl_surface)
            self.egl_surface = egl.EGL_NO_SURFACE

        if self.egl_display != egl.EGL_NO_DISPLAY:
            egl.eglTerminate(self.egl_display)
            self.egl_display = egl.EGL_NO_DISPLAY

        self.new_surface = True

        ## GTK
        # Restore the good old name of the frontend
        if self.title != None:
            self.window.set_title(self.title)
        self.window.set_resizable(True)

        # First we must lift the restriction on the minimum size of the widget
        self.window.canvas.set_size_request(1, 1)

        #XXX: Workaround because GTK is too slow
        time.sleep(0.1)

        self.window.resize(self.former_size[0], self.former_size[1])
        return wrp_dt.m64p_error.M64ERR_SUCCESS.value
示例#2
0
 def initialize_on_device(self, device, width, height):
     print("selected: " + device.name)
     # step 1
     if device.initialize():
         self.add_rollback_cb(lambda: device.release())
     else:
         self.rollback()
         return False
     # step 2
     egl_dpy = device.get_egl_display()
     if egl_dpy != egl.EGL_NO_DISPLAY:
         self.add_rollback_cb(lambda: egl.eglTerminate(egl_dpy))
     else:
         self.rollback()
         return False
     # step 3
     major, minor = egl.EGLint(), egl.EGLint()
     if not egl.eglInitialize(egl_dpy, pointer(major), pointer(minor)):
         self.rollback()
         return False
     print("EGL version %d.%d" % (major.value, minor.value))
     # step 4
     egl_config = self.get_config(egl_dpy, device.compatible_surface_type())
     if egl_config is None:
         self.rollback()
         return False
     # step 5
     egl_surface = device.create_surface(egl_dpy, egl_config)
     if egl_surface.initialize(width, height):
         self.add_rollback_cb(lambda: egl_surface.release())
     else:
         self.rollback()
         return False
     # step 6
     egl_context = self.get_context(egl_dpy, egl_config)
     if egl_context is not None:
         self.add_rollback_cb(
             lambda: egl.eglDestroyContext(egl_dpy, egl_context))
     else:
         self.rollback()
         return False
     # step 7
     if not egl_surface.make_current(egl_context):
         self.rollback()
         return False
     # device seems to be working
     return True
示例#3
0
文件: context.py 项目: eduble/panteda
 def initialize_on_device(self, device, width, height):
     print("selected: " + device.name)
     # step 1
     if device.initialize():
         self.add_rollback_cb(lambda: device.release())
     else:
         self.rollback(); return False
     # step 2
     egl_dpy = device.get_egl_display()
     if egl_dpy != egl.EGL_NO_DISPLAY:
         self.add_rollback_cb(lambda: egl.eglTerminate(egl_dpy))
         self.egl_dpy = egl_dpy
     else:
         self.rollback(); return False
     # step 3
     major, minor = egl.EGLint(), egl.EGLint()
     if not egl.eglInitialize(egl_dpy, pointer(major), pointer(minor)):
         self.rollback(); return False
     print("EGL version %d.%d" % (major.value, minor.value))
     # step 4
     egl_config = self.get_config(egl_dpy, device.compatible_surface_type())
     if egl_config is None:
         self.rollback(); return False
     # step 5
     egl_surface = device.create_surface(egl_dpy, egl_config)
     if egl_surface.initialize(width, height):
         self.add_rollback_cb(lambda: egl_surface.release())
         self.egl_surface = egl_surface
     else:
         self.rollback(); return False
     # step 6
     egl_context = self.get_context(egl_dpy, egl_config)
     if egl_context is not None:
         self.add_rollback_cb(lambda: egl.eglDestroyContext(egl_dpy, egl_context))
         self.egl_context = egl_context
     else:
         self.rollback(); return False
     # device seems to be working
     return True