Browse Source

more WxPandaWindow fixes

David Rose 14 years ago
parent
commit
e08f1d204f

+ 20 - 10
direct/src/wxwidgets/WxPandaWindow.py

@@ -33,7 +33,12 @@ class EmbeddedPandaWindow(wx.Window):
 
         wp = WindowProperties.getDefault()
         if platform.system() != 'Darwin':
-            wp.setParentWindow(self.GetHandle())
+            try:
+                wp.setParentWindow(self.GetHandle())
+            except OverflowError:
+                # Sheesh, a negative value from GetHandle().  This can
+                # only happen on 32-bit Windows.
+                wp.setParentWindow(self.GetHandle() & 0xffffffff)
 
         self.win = base.openWindow(props = wp, gsg = gsg, type = 'onscreen')
         self.Bind(wx.EVT_SIZE, self.onSize)
@@ -130,7 +135,12 @@ else:
                     attribList.append(True)
                 if fbprops.getDepthBits() > 0:
                     attribList.append(wxgl.WX_GL_DEPTH_SIZE)
-                    attribList.append(fbprops.getDepthBits())
+                    if fbprops.getDepthBits() <= 16:
+                        attribList.append(16)
+                    elif fbprops.getDepthBits() <= 24:
+                        attribList.append(24)
+                    else:
+                        attribList.append(32)
 
                 kw['attribList'] = attribList
                 
@@ -160,13 +170,8 @@ else:
             if pipe.getInterfaceName() != 'OpenGL':
                 raise StandardError, "Couldn't get an OpenGL pipe."
 
-            self.SetCurrent()
-            if base.win:
-                self.win = base.openWindow(callbackWindowDict = callbackWindowDict, pipe = pipe, gsg = gsg, type = 'onscreen')
-            else:
-                base.openDefaultWindow(callbackWindowDict = callbackWindowDict, pipe = pipe, gsg = gsg, type = 'onscreen')
-                self.win = base.win
 
+            self.win = base.openWindow(callbackWindowDict = callbackWindowDict, pipe = pipe, gsg = gsg, type = 'onscreen')
             self.inputDevice = self.win.getInputDevice(0)
 
             self.Bind(wx.EVT_SIZE, self.onSize)
@@ -258,9 +263,14 @@ else:
         def __renderCallback(self, data):
             cbType = data.getCallbackType()
             if cbType == CallbackGraphicsWindow.RCTBeginFrame:
-                self.SetCurrent()
                 if not self.IsShownOnScreen():
-                    return False
+                    data.setRenderFlag(False)
+                    return
+                self.SetCurrent()
+
+                # Don't upcall() in this case.
+                return
+            
             elif cbType == CallbackGraphicsWindow.RCTEndFlip:
                 self.SwapBuffers()
 

+ 4 - 1
panda/src/display/callbackGraphicsWindow.cxx

@@ -286,7 +286,10 @@ void CallbackGraphicsWindow::RenderCallbackData::
 upcall() {
   switch (_callback_type) {
   case RCT_begin_frame:
-    _window->GraphicsWindow::begin_frame(_frame_mode, Thread::get_current_thread());
+    {
+      bool render_flag = _window->GraphicsWindow::begin_frame(_frame_mode, Thread::get_current_thread());
+      set_render_flag(render_flag);
+    }
     break;
 
   case RCT_end_frame:

+ 1 - 1
panda/src/display/graphicsEngine.cxx

@@ -1503,7 +1503,7 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
   size_t wlist_size = wlist.size();
   for (size_t wi = 0; wi < wlist_size; ++wi) {
     GraphicsOutput *win = wlist[wi];
-    if (win->is_active() && win->get_gsg()->is_active()) {
+    if (win->is_active()) {
       if (win->flip_ready()) {
         {
           PStatTimer timer(GraphicsEngine::_flip_begin_pcollector, current_thread);