solve WxPandaWindow issues on Linux

This commit is contained in:
David Rose 2012-01-11 01:58:25 +00:00
parent ce8af6bc29
commit 7fd4c1cc18
3 changed files with 37 additions and 6 deletions

View File

@ -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:

View File

@ -1452,7 +1452,7 @@ begin_frame(Thread *current_thread) {
_state_rs = RenderState::make_empty();
_state_mask.clear();
return true;
return !_needs_reset;
}
////////////////////////////////////////////////////////////////////

View File

@ -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()) {