def check_support(force_enable=False, check_colormap=False): #platform checks: from xpra.platform.gui import gl_check warning = gl_check() if warning: if force_enable: log.warn("Warning: trying to continue despite '%s'" % warning) else: gl_check_error(warning) props = {} #this will import gtk.gtkgl / gdkgl or gi.repository.GtkGLExt / GdkGLExt: try: from xpra.client.gl.gtk_compat import get_info, gdkgl, Config_new_by_mode, GLDrawingArea except RuntimeError as e: gl_check_error(str(e)) return {} props.update(get_info()) display_mode = get_DISPLAY_MODE() glconfig = Config_new_by_mode(display_mode) if glconfig is None and CAN_DOUBLE_BUFFER: log("trying to toggle double-buffering") display_mode &= ~MODE_DOUBLE glconfig = Config_new_by_mode(display_mode) if not glconfig: gl_check_error("cannot setup an OpenGL context") return {} props["display_mode"] = get_MODE_names(display_mode) #on OSX, we had to patch out get_depth... #so take extra precautions when querying properties: for x, fn_name in { "has_alpha": "has_alpha", "rgba": "is_rgba", "stereo": "is_stereo", "double-buffered": "is_double_buffered", "depth": "get_depth", "has-depth-buffer": "has_depth_buffer", "has-stencil-buffer": "has_stencil_buffer", }.items(): fn = getattr(glconfig, fn_name, None) if fn: props[x] = fn() else: log("%s does not support %s()", glconfig, fn_name) for x in ("RED_SIZE", "GREEN_SIZE", "BLUE_SIZE", "ALPHA_SIZE", "AUX_BUFFERS", "DEPTH_SIZE", "STENCIL_SIZE", "ACCUM_RED_SIZE", "ACCUM_GREEN_SIZE", "ACCUM_BLUE_SIZE", "SAMPLE_BUFFERS", "SAMPLES"): prop = getattr(gdkgl, x) if not prop: continue try: v = glconfig.get_attrib(prop)[0] props[x.lower().replace("_", "-")] = v except: pass log("GL props=%s", props) from xpra.gtk_common.gtk_util import import_gtk, gdk_window_process_all_updates gtk = import_gtk() assert gdkgl.query_extension() glext, w = None, None try: #ugly code for win32 and others (virtualbox broken GL drivers) #for getting a GL drawable and context: we must use a window... #(which we do not even show on screen) # #here is the old simpler alternative which does not work on some platforms: # glext = gtk.gdkgl.ext(gdk.Pixmap(gdk.get_default_root_window(), 1, 1)) # gldrawable = glext.set_gl_capability(glconfig) # glcontext = gtk.gdkgl.Context(gldrawable, direct=True) w = gtk.Window() w.set_decorated(False) vbox = gtk.VBox() glarea = GLDrawingArea(glconfig) glarea.set_size_request(32, 32) vbox.add(glarea) vbox.show_all() w.add(vbox) #we don't need to actually show the window! #w.show_all() glarea.realize() gdk_window_process_all_updates() gl_props = check_GL_support(glarea, force_enable) if check_colormap: s = w.get_screen() for x in ("rgb_visual", "rgba_visual", "system_visual"): try: visual = getattr(s, "get_%s" % x)() gl_props[x] = visual_to_str(visual) except: pass #i = 0 #for v in s.list_visuals(): # gl_props["visual[%s]" % i] = visual_to_str(v) # i += 1 finally: if w: w.destroy() del glext, glconfig props.update(gl_props) return props
def check_support(force_enable=False, check_colormap=False): #platform checks: from xpra.platform.gui import gl_check warning = gl_check() if warning: if force_enable: log.warn("Warning: trying to continue despite '%s'" % warning) else: gl_check_error(warning) props = {} #this will import gtk.gtkgl / gdkgl or gi.repository.GtkGLExt / GdkGLExt: try: from xpra.client.gl.gtk_compat import get_info, gdkgl, Config_new_by_mode, MODE_DOUBLE, GLDrawingArea except RuntimeError as e: gl_check_error(str(e)) return {} props.update(get_info()) display_mode = get_DISPLAY_MODE() glconfig = Config_new_by_mode(display_mode) if glconfig is None and CAN_DOUBLE_BUFFER: log("trying to toggle double-buffering") display_mode &= ~MODE_DOUBLE glconfig = Config_new_by_mode(display_mode) if not glconfig: gl_check_error("cannot setup an OpenGL context") props["display_mode"] = get_MODE_names(display_mode) props["glconfig"] = glconfig props["has_alpha"] = glconfig.has_alpha() props["rgba"] = glconfig.is_rgba() log("GL props=%s", props) from xpra.gtk_common.gtk_util import import_gtk, gdk_window_process_all_updates gtk = import_gtk() assert gdkgl.query_extension() glext, w = None, None try: #ugly code for win32 and others (virtualbox broken GL drivers) #for getting a GL drawable and context: we must use a window... #(which we do not even show on screen) # #here is the old simpler alternative which does not work on some platforms: # glext = gtk.gdkgl.ext(gdk.Pixmap(gdk.get_default_root_window(), 1, 1)) # gldrawable = glext.set_gl_capability(glconfig) # glcontext = gtk.gdkgl.Context(gldrawable, direct=True) w = gtk.Window() w.set_decorated(False) vbox = gtk.VBox() glarea = GLDrawingArea(glconfig) glarea.set_size_request(32, 32) vbox.add(glarea) vbox.show_all() w.add(vbox) #we don't need to actually show the window! #w.show_all() glarea.realize() gdk_window_process_all_updates() gl_props = check_GL_support(glarea, force_enable) if check_colormap: s = w.get_screen() for x in ("rgb_visual", "rgba_visual", "system_visual"): try: visual = getattr(s, "get_%s" % x)() gl_props[x] = visual_to_str(visual) except: pass #i = 0 #for v in s.list_visuals(): # gl_props["visual[%s]" % i] = visual_to_str(v) # i += 1 finally: if w: w.destroy() del glext, glconfig props.update(gl_props) return props
def check_support(force_enable=False, check_colormap=False): #platform checks: from xpra.platform.gui import gl_check warning = gl_check() if warning: if force_enable: log.warn("Warning: trying to continue despite '%s'" % warning) else: gl_check_error(warning) props = {} #this will import gtk.gtkgl / gdkgl or gi.repository.GtkGLExt / GdkGLExt: try: from xpra.client.gl.gtk_compat import get_info, gdkgl, Config_new_by_mode, MODE_DOUBLE, GLDrawingArea except RuntimeError as e: gl_check_error(str(e)) return {} props.update(get_info()) display_mode = get_DISPLAY_MODE() glconfig = Config_new_by_mode(display_mode) if glconfig is None and CAN_DOUBLE_BUFFER: log("trying to toggle double-buffering") display_mode &= ~MODE_DOUBLE glconfig = Config_new_by_mode(display_mode) if not glconfig: gl_check_error("cannot setup an OpenGL context") return {} props["display_mode"] = get_MODE_names(display_mode) props["glconfig"] = glconfig props["has_alpha"] = glconfig.has_alpha() props["rgba"] = glconfig.is_rgba() log("GL props=%s", props) from xpra.gtk_common.gtk_util import import_gtk, gdk_window_process_all_updates gtk = import_gtk() assert gdkgl.query_extension() glext, w = None, None try: #ugly code for win32 and others (virtualbox broken GL drivers) #for getting a GL drawable and context: we must use a window... #(which we do not even show on screen) # #here is the old simpler alternative which does not work on some platforms: # glext = gtk.gdkgl.ext(gdk.Pixmap(gdk.get_default_root_window(), 1, 1)) # gldrawable = glext.set_gl_capability(glconfig) # glcontext = gtk.gdkgl.Context(gldrawable, direct=True) w = gtk.Window() w.set_decorated(False) vbox = gtk.VBox() glarea = GLDrawingArea(glconfig) glarea.set_size_request(32, 32) vbox.add(glarea) vbox.show_all() w.add(vbox) #we don't need to actually show the window! #w.show_all() glarea.realize() gdk_window_process_all_updates() gl_props = check_GL_support(glarea, force_enable) if check_colormap: s = w.get_screen() for x in ("rgb_visual", "rgba_visual", "system_visual"): try: visual = getattr(s, "get_%s" % x)() gl_props[x] = visual_to_str(visual) except: pass #i = 0 #for v in s.list_visuals(): # gl_props["visual[%s]" % i] = visual_to_str(v) # i += 1 finally: if w: w.destroy() del glext, glconfig props.update(gl_props) return props