Skip to content

Commit

Permalink
#2467 always make the gl context current before use
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Oct 26, 2023
1 parent 27b9263 commit 6e2276e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions xpra/client/gl/gtk3/glarea_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from collections.abc import Callable
from gi.repository import Gtk, Gdk, GObject

from xpra.common import noop
from xpra.util.str_fn import ellipsizer
from xpra.client.gl.gtk3.client_window import GLClientWindowBase
from xpra.client.gl.backing import GLWindowBackingBase
Expand All @@ -32,6 +33,7 @@ def is_double_buffered(self) -> bool:

def init_backing(self) -> None:
da = Gtk.GLArea()
da.set_use_es(True)
da.set_auto_render(True)
da.set_has_alpha(self._alpha_enabled)
da.set_has_depth_buffer(False)
Expand All @@ -45,16 +47,17 @@ def init_backing(self) -> None:
self._backing = da

def on_realize(self, *args) -> None:
onrcb = self.on_realize_cb
log("GLAreaBacking.on_realize%s callbacks=%s", args, tuple(ellipsizer(x) for x in onrcb))
self.on_realize_cb = []
gl_context = self.gl_context()
log("gl context version %s", gl_context.get_version())
gl_context.make_current()
self.gl_init(gl_context)
# fire the delayed realized callbacks:
onrcb = self.on_realize_cb
log("GLAreaBacking.fire_realize_cb callbacks=%s", tuple(ellipsizer(x) for x in onrcb))
gl_context.update_geometry = noop
self.on_realize_cb = []
for x, args in onrcb:
with log.trap_error("Error calling realize callback %s", ellipsizer(x)):
x(gl_context, *args)
self.gl_init(gl_context)

def with_gl_context(self, cb:Callable, *args):
da = self._backing
Expand Down Expand Up @@ -92,8 +95,8 @@ def draw_fbo(self, context) -> bool:
def on_render(self, glarea, glcontext):
log(f"render({glarea}, {glcontext}) {self.textures=}, {self.offscreen_fbo=}")
if self.textures is None or self.offscreen_fbo is None:
self.gl_init(glcontext)
return False
return True
glcontext.make_current()
w, h = self.render_size
from xpra.client.gl.backing import TEX_FBO
if False:
Expand Down

0 comments on commit 6e2276e

Please sign in to comment.