From 7fd4c1cc18f85b8ae4468f6466f350784759277a Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 11 Jan 2012 01:58:25 +0000 Subject: [PATCH] solve WxPandaWindow issues on Linux --- direct/src/wxwidgets/WxPandaWindow.py | 29 +++++++++++++++++-- panda/src/display/graphicsStateGuardian.cxx | 2 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 12 ++++++-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/direct/src/wxwidgets/WxPandaWindow.py b/direct/src/wxwidgets/WxPandaWindow.py index a756ffa2c3..99d32f7ea0 100644 --- a/direct/src/wxwidgets/WxPandaWindow.py +++ b/direct/src/wxwidgets/WxPandaWindow.py @@ -64,7 +64,7 @@ class EmbeddedPandaWindow(wx.Window): def onSize(self, event): wp = WindowProperties() wp.setOrigin(0, 0) - wp.setSize(*self.GetClientSizeTuple()) + wp.setSize(*self.GetClientSize()) self.win.requestProperties(wp) event.Skip() @@ -165,6 +165,7 @@ else: self.inputDevice = self.win.getInputDevice(0) self.Bind(wx.EVT_SIZE, self.onSize) + self.Bind(wx.EVT_IDLE, self.onIdle) self.Bind(wx.EVT_LEFT_DOWN, lambda event: self.__buttonDown(MouseButton.one())) self.Bind(wx.EVT_LEFT_UP, lambda event: self.__buttonUp(MouseButton.one())) self.Bind(wx.EVT_MIDDLE_DOWN, lambda event: self.__buttonDown(MouseButton.two())) @@ -262,13 +263,35 @@ else: def onSize(self, event): wp = WindowProperties() - wp.setSize(*self.GetClientSizeTuple()) + wp.setSize(*self.GetClientSize()) self.win.requestProperties(wp) + + # Apparently, sometimes on Linux we get the onSize event + # before the size has actually changed, and the size we + # report in GetClientSize() is the *previous* size. To + # work around this unfortunate circumstance, we'll also + # ensure an idle event comes in later, and check the size + # again then. + wx.WakeUpIdle() + event.Skip() + def onIdle(self, event): + size = None + properties = self.win.getProperties() + if properties.hasSize(): + size = (properties.getXSize(), properties.getYSize()) + + if tuple(self.GetClientSize()) != size: + # The window has changed size during the idle call. + # This seems to be possible in Linux. + wp = WindowProperties() + wp.setSize(*self.GetClientSize()) + self.win.requestProperties(wp) + # Choose the best implementation of WxPandaWindow for the platform. WxPandaWindow = None -if platform.system() == 'Darwin': # or platform.system() == 'Linux': +if platform.system() == 'Darwin' or platform.system() == 'Linux': WxPandaWindow = OpenGLPandaWindow if not WxPandaWindow: diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 8cb6135649..28b7216bc7 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -1452,7 +1452,7 @@ begin_frame(Thread *current_thread) { _state_rs = RenderState::make_empty(); _state_mask.clear(); - return true; + return !_needs_reset; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index bf1837fe44..377ec0f148 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -380,6 +380,12 @@ reset() { // Output the vendor and version strings. query_gl_version(); + if (_gl_version_major == 0) { + // Couldn't get GL. Fail. + mark_new(); + return; + } + // Save the extensions tokens. save_extensions((const char *)GLP(GetString)(GL_EXTENSIONS)); get_extra_extensions(); @@ -5338,8 +5344,10 @@ show_gl_string(const string &name, GLenum id) { const GLubyte *text = GLP(GetString)(id); if (text == (const GLubyte *)NULL) { - GLCAT.warning() - << "Unable to query " << name << "\n"; + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Unable to query " << name << "\n"; + } } else { result = (const char *)text; if (GLCAT.is_debug()) {