def check_support(self, force_enable=False): i = self.props tmp = make_temp_window("tmp-opengl-check") log("check_support(%s) using temporary window=%s", force_enable, tmp) with self.get_paint_context(tmp): i.update(check_PyOpenGL_support(force_enable)) tmp.destroy() return i
def check_support(self, force_enable=False): #create a temporary window to query opengl attributes: hInst = GetModuleHandleA(0) log("check_support() GetModuleHandleW()=%#x", hInst or 0) classname = "Xpra Temporary Window for OpenGL" wndc = WNDCLASSEX() wndc.cbSize = sizeof(WNDCLASSEX) wndc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW wndc.hInstance = hInst wndc.hBrush = COLOR_WINDOW wndc.lpszClassName = classname wndc.lpfnWndProc = WNDPROC(DefWndProc) reg_atom = RegisterClassExA(byref(wndc)) log("check_support() RegisterClassExW()=%#x", reg_atom or 0) if not reg_atom: return { "info": "disabled: failed to register window class, %s" % FormatError() } style = WS_OVERLAPPED | WS_SYSMENU window_name = "Xpra OpenGL Test" self.hwnd = CreateWindowExA(0, reg_atom, window_name, style, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, hInst, None) log("check_support() CreateWindowExW()=%#x", self.hwnd or 0) if not self.hwnd: return { "info": "disabled: failed to create temporary window, %s" % FormatError() } try: self.context = self.create_wgl_context(self.hwnd) with WGLWindowContext(self.hwnd, self.hdc, self.context): props = check_PyOpenGL_support(force_enable) props["display_mode"] = [ ["SINGLE", "DOUBLE"][int(DOUBLE_BUFFERED)], ] #, "ALPHA"] return props finally: hwnd = self.hwnd self.destroy() if hwnd and not DestroyWindow(hwnd): log.warn( "Warning: failed to destroy temporary OpenGL test window") latom = c_void_p(reg_atom) if not UnregisterClassW(cast(latom, LPCWSTR), hInst): log.warn( "Warning: failed to unregister class for OpenGL test window" ) log.warn(" for class %r and module handle %#x:", classname, hInst or 0) log.warn(" '%s'", FormatError())
def check_support(self, force_enable=False): i = self.props gtk = import_gtk() tmp = gtk.Window(WINDOW_TOPLEVEL) tmp.resize(1, 1) tmp.set_decorated(False) tmp.realize() enable_alpha(tmp) win = tmp.get_window() log("check_support(%s) using temporary window=%s", force_enable, tmp) with self.get_paint_context(win): i.update(check_PyOpenGL_support(force_enable)) tmp.destroy() return i
def check_support(self, force_enable=False): #map our names (based on GTK's) to apple's constants: attr_name = { "rgba": (bool, NSOpenGLPFAAlphaSize), "depth": (int, NSOpenGLPFAColorSize), #"red-size" : ? #"green-size" : ? #"blue-size" : ? #"red-shift" : ? #"green-shift" : ? #"blue-shift" : ? #"alpha-shift" : ? #"accum-red-size" : ? #"accum-green-size" : ? #"accum-blue-size" : ? "alpha-size": (int, NSOpenGLPFAAlphaSize), "accum-size": (int, NSOpenGLPFAAccumSize), "depth-size": (int, NSOpenGLPFADepthSize), "stencil-size": (int, NSOpenGLPFAStencilSize), "aux-buffers": (int, NSOpenGLPFAAuxBuffers), #"visible-mask" : ? "double-buffered": (int, NSOpenGLPFADoubleBuffer) } nscreens = self.pixel_format.numberOfVirtualScreens() i = { #"pixel-format" : self.pixel_format, "virtual-screens": nscreens, } for name, vdef in attr_name.items(): conv, const_val = vdef #ie (bool, NSOpenGLPFAAlphaSize) v = self._get_apfa(const_val) #ie: NSOpenGLPFAAlphaSize=8 i[name] = conv(v) #ie: bool(8) #do it again but for each screen: if nscreens > 1: for screen in range(nscreens): si = i.setdefault("screen-%i" % screen, {}) for name, vdef in attr_name.items(): conv, const_val = vdef #ie (bool, NSOpenGLPFAAlphaSize) v = self._get_pfa(const_val, screen) #ie: NSOpenGLPFAAlphaSize=8 si[name] = conv(v) #ie: bool(8) from gi.repository import Gdk tmp = GDKWindow(window_type=Gdk.WindowType.TEMP, title="tmp-opengl-check") with self.get_paint_context(tmp): i.update(check_PyOpenGL_support(force_enable)) tmp.destroy() return i
def check_support(self, force_enable=False): i = self.props if not self.xdisplay: return { "success": False, "safe": False, "message": "cannot access X11 display", } gtk = import_gtk() tmp = gtk.Window(WINDOW_TOPLEVEL) tmp.resize(1, 1) tmp.set_decorated(False) tmp.realize() enable_alpha(tmp) win = tmp.get_window() log("check_support(%s) using temporary window=%s", force_enable, tmp) with self.get_paint_context(win): i.update(check_PyOpenGL_support(force_enable)) tmp.destroy() return i
def check_support(self, force_enable=False): i = self.props gdk = import_gdk() title = "tmp-opengl-check" if is_gtk3(): attributes = gdk.WindowAttr() attributes.width = 1 attributes.height = 1 attributes.title = title attributes.window_type = gdk.WindowType.TOPLEVEL attributes.wclass = gdk.WindowWindowClass.INPUT_OUTPUT attributes.event_mask = 0 attributes_mask = gdk.WindowAttributesType.TITLE | gdk.WindowAttributesType.WMCLASS tmp = gdk.Window(None, attributes, attributes_mask) else: tmp = gdk.Window(None, 1, 1, gdk.WINDOW_TOPLEVEL, 0, gdk.INPUT_OUTPUT, title) log("check_support(%s) using temporary window=%s", force_enable, tmp) with self.get_paint_context(tmp): i.update(check_PyOpenGL_support(force_enable)) tmp.destroy() return i
def check_support(self, force_enable=False): i = self.props if not self.xdisplay: return { "success": False, "safe": False, "enabled": False, "message": "cannot access X11 display", } from gi.repository import Gtk tmp = Gtk.Window(Gtk.WindowType.TOPLEVEL) tmp.resize(1, 1) tmp.set_decorated(False) tmp.realize() da = Gtk.DrawingArea() tmp.add(da) set_visual(da, True) win = tmp.get_window() log("check_support(%s) using temporary window=%s", force_enable, tmp) with self.get_paint_context(win): i.update(check_PyOpenGL_support(force_enable)) tmp.destroy() return i
def check_GL_support(widget, force_enable=False): from xpra.client.gl.gtk_base.gtk_compat import GtkGLExtContext with GtkGLExtContext(widget): return check_PyOpenGL_support(force_enable)