예제 #1
0
 def __init__(self, wid, w, h, has_alpha):
     GTK2WindowBacking.__init__(self, wid, w, h, has_alpha)
     display_mode = get_DISPLAY_MODE()
     try:
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     except gtk.gdkgl.NoMatches:
         display_mode &= ~gtk.gdkgl.MODE_DOUBLE
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     self._backing = gtk.gtkgl.DrawingArea(self.glconfig)
     #restoring missed masks:
     self._backing.set_events(self._backing.get_events()
                              | gdk.POINTER_MOTION_MASK
                              | gdk.POINTER_MOTION_HINT_MASK)
     self._backing.show()
     self._backing.connect("expose_event", self.gl_expose_event)
     self.textures = None  # OpenGL texture IDs
     self.shaders = None
     self.pixel_format = None
     self.size = 0, 0
     self.texture_size = 0, 0
     self.gl_setup = False
     self.paint_screen = False
     self._video_use_swscale = False
     self.draw_needs_refresh = False
     self.offscreen_fbo = None
예제 #2
0
 def __init__(self, wid, w, h, has_alpha):
     GTK2WindowBacking.__init__(self, wid, w, h, has_alpha)
     display_mode = get_DISPLAY_MODE()
     try:
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     except gtk.gdkgl.NoMatches:
         display_mode &= ~gtk.gdkgl.MODE_DOUBLE
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     self._backing = gtk.gtkgl.DrawingArea(self.glconfig)
     # restoring missed masks:
     self._backing.set_events(self._backing.get_events() | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK)
     if self._has_alpha:
         screen = self._backing.get_screen()
         rgba = screen.get_rgba_colormap()
         if rgba:
             self._backing.set_colormap(rgba)
         else:
             log.warn("failed to enable transparency on screen %s", screen)
             self._has_alpha = False
     self._backing.show()
     self._backing.connect("expose_event", self.gl_expose_event)
     self.textures = None  # OpenGL texture IDs
     self.shaders = None
     self.pixel_format = None
     self.size = 0, 0
     self.texture_size = 0, 0
     self.gl_setup = False
     self.debug_setup = False
     self.paint_screen = False
     self._video_use_swscale = False
     self.draw_needs_refresh = False
     self.offscreen_fbo = None
예제 #3
0
 def init_gl_config(self, window_alpha):
     #setup gl config:
     alpha = GL_ALPHA_SUPPORTED and window_alpha
     display_mode = get_DISPLAY_MODE(want_alpha=alpha)
     self.glconfig = Config_new_by_mode(display_mode)
     if self.glconfig is None and CAN_DOUBLE_BUFFER:
         log("trying to toggle double-buffering")
         display_mode &= ~MODE_DOUBLE
         self.glconfig = Config_new_by_mode(display_mode)
     if not self.glconfig:
         raise Exception("cannot setup an OpenGL context")
예제 #4
0
 def init_gl_config(self, window_alpha):
     #setup gl config:
     alpha = GL_ALPHA_SUPPORTED and window_alpha
     display_mode = get_DISPLAY_MODE(want_alpha=alpha)
     self.glconfig = Config_new_by_mode(display_mode)
     if self.glconfig is None and CAN_DOUBLE_BUFFER:
         log("trying to toggle double-buffering")
         display_mode &= ~MODE_DOUBLE
         self.glconfig = Config_new_by_mode(display_mode)
     if not self.glconfig:
         raise Exception("cannot setup an OpenGL context")
예제 #5
0
 def __init__(self, wid, w, h, window_alpha):
     alpha = GL_ALPHA_SUPPORTED and window_alpha
     display_mode = get_DISPLAY_MODE(want_alpha=alpha)
     try:
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     except gtk.gdkgl.NoMatches:
         #toggle double buffering and try again:
         display_mode &= ~gtk.gdkgl.MODE_DOUBLE
         log.warn(
             "failed to initialize gl context: trying again %s double buffering",
             (bool(display_mode & gtk.gdkgl.MODE_DOUBLE) and "with")
             or "without")
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     GTK2WindowBacking.__init__(self, wid, alpha
                                and self.glconfig.has_alpha())
     self._backing = gtk.gtkgl.DrawingArea(self.glconfig)
     #restoring missed masks:
     self._backing.set_events(self._backing.get_events()
                              | gdk.POINTER_MOTION_MASK
                              | gdk.POINTER_MOTION_HINT_MASK)
     if self._alpha_enabled:
         assert GL_ALPHA_SUPPORTED, "BUG: cannot enable alpha if GL backing does not support it!"
         screen = self._backing.get_screen()
         rgba = screen.get_rgba_colormap()
         if rgba:
             log("%s.__init__() using rgba colormap %s", rgba)
             self._backing.set_colormap(rgba)
         else:
             log.warn("failed to enable transparency on screen %s", screen)
             self._alpha_enabled = False
     #this is how many bpp we keep in the texture
     #(pixels are always stored in 32bpp - but this makes it clearer when we do/don't support alpha)
     if self._alpha_enabled:
         self.texture_pixel_format = GL_RGBA
     else:
         self.texture_pixel_format = GL_RGB
     #this is the pixel format we are currently updating the fbo with
     #can be: "YUV420P", "YUV422P", "YUV444P", "GBRP" or None when not initialized yet.
     self.pixel_format = None
     self._backing.show()
     self._backing.connect("expose_event", self.gl_expose_event)
     self.textures = None  # OpenGL texture IDs
     self.shaders = None
     self.size = 0, 0
     self.texture_size = 0, 0
     self.gl_setup = False
     self.debug_setup = False
     self.border = None
     self.paint_screen = False
     self._video_use_swscale = False
     self.draw_needs_refresh = False
     self.offscreen_fbo = None
예제 #6
0
 def __init__(self, wid, w, h, window_alpha):
     alpha = GL_ALPHA_SUPPORTED and window_alpha
     display_mode = get_DISPLAY_MODE(want_alpha=alpha)
     try:
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     except gtk.gdkgl.NoMatches:
         #toggle double buffering and try again:
         display_mode &= ~gtk.gdkgl.MODE_DOUBLE
         log.warn("failed to initialize gl context: trying again %s double buffering", (bool(display_mode & gtk.gdkgl.MODE_DOUBLE) and "with") or "without")
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     GTK2WindowBacking.__init__(self, wid, alpha and self.glconfig.has_alpha())
     self._backing = gtk.gtkgl.DrawingArea(self.glconfig)
     #restoring missed masks:
     self._backing.set_events(self._backing.get_events() | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK)
     if self._alpha_enabled:
         assert GL_ALPHA_SUPPORTED, "BUG: cannot enable alpha if GL backing does not support it!"
         screen = self._backing.get_screen()
         rgba = screen.get_rgba_colormap()
         if rgba:
             log("%s.__init__() using rgba colormap %s", rgba)
             self._backing.set_colormap(rgba)
         else:
             log.warn("failed to enable transparency on screen %s", screen)
             self._alpha_enabled = False
     #this is how many bpp we keep in the texture
     #(pixels are always stored in 32bpp - but this makes it clearer when we do/don't support alpha)
     if self._alpha_enabled:
         self.texture_pixel_format = GL_RGBA
     else:
         self.texture_pixel_format = GL_RGB
     #this is the pixel format we are currently updating the fbo with
     #can be: "YUV420P", "YUV422P", "YUV444P", "GBRP" or None when not initialized yet.
     self.pixel_format = None
     self._backing.show()
     self._backing.connect("expose_event", self.gl_expose_event)
     self.textures = None # OpenGL texture IDs
     self.shaders = None
     self.size = 0, 0
     self.texture_size = 0, 0
     self.gl_setup = False
     self.debug_setup = False
     self.border = None
     self.paint_screen = False
     self._video_use_swscale = False
     self.draw_needs_refresh = False
     self.offscreen_fbo = None
예제 #7
0
 def __init__(self, wid, w, h, has_alpha):
     display_mode = get_DISPLAY_MODE()
     try:
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     except gtk.gdkgl.NoMatches:
         display_mode &= ~gtk.gdkgl.MODE_DOUBLE
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     if not HAS_ALPHA or not self.glconfig.has_alpha():
         has_alpha = False
     GTK2WindowBacking.__init__(self, wid, w, h, has_alpha)
     self._backing = gtk.gtkgl.DrawingArea(self.glconfig)
     #restoring missed masks:
     self._backing.set_events(self._backing.get_events()
                              | gdk.POINTER_MOTION_MASK
                              | gdk.POINTER_MOTION_HINT_MASK)
     if self._has_alpha:
         screen = self._backing.get_screen()
         rgba = screen.get_rgba_colormap()
         if rgba:
             self._backing.set_colormap(rgba)
         else:
             log.warn("failed to enable transparency on screen %s", screen)
             self._has_alpha = False
     #this is how many bpp we keep in the texture
     #(pixels are always stored in 32bpp - but this makes it clearer when we do/don't support alpha)
     if self._has_alpha:
         self.texture_pixel_format = GL_RGBA
     else:
         self.texture_pixel_format = GL_RGB
     #this is the pixel format we are currently updating the fbo with
     #can be: "YUV420P", "YUV422P", "YUV444P", "GBRP" or None when not initialized yet.
     self.pixel_format = None
     self._backing.show()
     self._backing.connect("expose_event", self.gl_expose_event)
     self.textures = None  # OpenGL texture IDs
     self.shaders = None
     self.size = 0, 0
     self.texture_size = 0, 0
     self.gl_setup = False
     self.debug_setup = False
     self.border = None
     self.paint_screen = False
     self._video_use_swscale = False
     self.draw_needs_refresh = False
     self.offscreen_fbo = None
예제 #8
0
 def __init__(self, wid, w, h, has_alpha):
     display_mode = get_DISPLAY_MODE()
     try:
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     except gtk.gdkgl.NoMatches:
         display_mode &= ~gtk.gdkgl.MODE_DOUBLE
         self.glconfig = gtk.gdkgl.Config(mode=display_mode)
     if not HAS_ALPHA or not self.glconfig.has_alpha():
         has_alpha = False
     GTK2WindowBacking.__init__(self, wid, w, h, has_alpha)
     self._backing = gtk.gtkgl.DrawingArea(self.glconfig)
     #restoring missed masks:
     self._backing.set_events(self._backing.get_events() | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK)
     if self._has_alpha:
         screen = self._backing.get_screen()
         rgba = screen.get_rgba_colormap()
         if rgba:
             self._backing.set_colormap(rgba)
         else:
             log.warn("failed to enable transparency on screen %s", screen)
             self._has_alpha = False
     #this is how many bpp we keep in the texture
     #(pixels are always stored in 32bpp - but this makes it clearer when we do/don't support alpha)
     if self._has_alpha:
         self.texture_pixel_format = GL_RGBA
     else:
         self.texture_pixel_format = GL_RGB
     #this is the pixel format we are currently updating the fbo with
     #can be: "YUV420P", "YUV422P", "YUV444P", "GBRP" or None when not initialized yet.
     self.pixel_format = None
     self._backing.show()
     self._backing.connect("expose_event", self.gl_expose_event)
     self.textures = None # OpenGL texture IDs
     self.shaders = None
     self.size = 0, 0
     self.texture_size = 0, 0
     self.gl_setup = False
     self.debug_setup = False
     self.border = None
     self.paint_screen = False
     self._video_use_swscale = False
     self.draw_needs_refresh = False
     self.offscreen_fbo = None