def check_support(min_texture_size=0, force_enable=False, check_colormap=False): #platform checks: from xpra.platform.gui import gl_check warning = gl_check() if warning: gl_check_error(warning) props = {} import gtk.gdk import gtk.gdkgl, gtk.gtkgl assert gtk.gdkgl is not None and gtk.gtkgl is not None log("pygdkglext version=%s", gtk.gdkgl.pygdkglext_version) props["pygdkglext_version"] = gtk.gdkgl.pygdkglext_version log("gtkglext_version=%s", gtk.gdkgl.gdkglext_version) props["gdkglext_version"] = gtk.gdkgl.gdkglext_version log("pygdkglext OpenGL version=%s", gtk.gdkgl.query_version()) props["gdkgl_version"] = gtk.gdkgl.query_version() display_mode = get_DISPLAY_MODE() try: glconfig = gtk.gdkgl.Config(mode=display_mode) except gtk.gdkgl.NoMatches, e: log("no match: %s, toggling double-buffering", e) display_mode &= ~gtk.gdkgl.MODE_DOUBLE glconfig = gtk.gdkgl.Config(mode=display_mode)
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_base.gtk_compat import get_info, gdkgl, Config_new_by_mode, GLDrawingArea assert GLDrawingArea except RuntimeError as e: gl_check_error(str(e)) return {} props.update(get_info()) for want_alpha in (GL_ALPHA_SUPPORTED, not GL_ALPHA_SUPPORTED): for double_buffered in (CAN_DOUBLE_BUFFER, not CAN_DOUBLE_BUFFER): display_mode = get_DISPLAY_MODE(want_alpha, double_buffered) log("get_DISPLAY_MODE(%s, %s)=%s", want_alpha, double_buffered, display_mode) glconfig = Config_new_by_mode(display_mode) log("Config_new_by_mode(%s)=%s", display_mode, glconfig) if glconfig: break 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) if TEST_GTKGL_RENDERING: gl_props = test_gtkgl_rendering(glconfig, force_enable, check_colormap) if not gl_props: #if we fail the test rendering, don't return anything #so the client will know this backend should not be used return {} props.update(gl_props) else: log("gtkgl rendering test skipped") 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, 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") 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