diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 51503cb930..0fbe462398 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -775,15 +775,13 @@ flip_windows(const GraphicsEngine::Windows &wlist) { Windows::const_iterator wi; for (wi = wlist.begin(); wi != wlist.end(); ++wi) { GraphicsOutput *win = (*wi); - if (win->is_active() && win->get_gsg()->is_active() && - !win->get_gsg()->get_properties().is_single_buffered()) { + if (win->flip_ready()) { win->begin_flip(); } } for (wi = wlist.begin(); wi != wlist.end(); ++wi) { GraphicsOutput *win = (*wi); - if (win->is_active() && win->get_gsg()->is_active() && - !win->get_gsg()->get_properties().is_single_buffered()) { + if (win->flip_ready()) { win->end_flip(); } } diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index d755db1223..32577be690 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -160,6 +160,17 @@ is_valid() const { return _is_valid; } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::flip_ready +// Access: Published +// Description: Returns true if a frame has been rendered and needs +// to be flipped, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool GraphicsOutput:: +flip_ready() const { + return _flip_ready; +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_sort // Access: Published diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 8ebe365598..23030070b0 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -51,6 +51,7 @@ GraphicsOutput(GraphicsPipe *pipe, GraphicsStateGuardian *gsg, _has_size = false; _is_valid = false; _copy_texture = false; + _flip_ready = false; _sort = 0; int mode = gsg->get_properties().get_frame_buffer_mode(); @@ -542,6 +543,11 @@ end_frame() { TextureContext *tc = get_texture()->prepare_now(_gsg->get_prepared_objects(), _gsg); _gsg->copy_texture(tc, &dr, buffer); } + + // If we're not single-buffered, we're now ready to flip. + if (!_gsg->get_properties().is_single_buffered()) { + _flip_ready = true; + } } //////////////////////////////////////////////////////////////////// @@ -599,6 +605,7 @@ begin_flip() { //////////////////////////////////////////////////////////////////// void GraphicsOutput:: end_flip() { + _flip_ready = false; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index 9788f11f6a..f96945881b 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -80,6 +80,7 @@ PUBLISHED: INLINE int get_y_size() const; INLINE bool has_size() const; INLINE bool is_valid() const; + INLINE bool flip_ready() const; virtual bool is_active() const; @@ -149,6 +150,7 @@ protected: string _name; PT(Texture) _texture; bool _copy_texture; + bool _flip_ready; private: INLINE void determine_display_regions() const; diff --git a/panda/src/dxgsg7/wdxGraphicsWindow7.cxx b/panda/src/dxgsg7/wdxGraphicsWindow7.cxx index 783582badd..2b9f2c0fa7 100644 --- a/panda/src/dxgsg7/wdxGraphicsWindow7.cxx +++ b/panda/src/dxgsg7/wdxGraphicsWindow7.cxx @@ -219,6 +219,7 @@ end_flip() { if (_dxgsg != (DXGraphicsStateGuardian7 *)NULL && is_active()) { _dxgsg->show_frame(); } + GraphicsWindow::end_flip(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/dxgsg8/wdxGraphicsWindow8.cxx b/panda/src/dxgsg8/wdxGraphicsWindow8.cxx index 3a603acb3d..6759523651 100644 --- a/panda/src/dxgsg8/wdxGraphicsWindow8.cxx +++ b/panda/src/dxgsg8/wdxGraphicsWindow8.cxx @@ -258,6 +258,7 @@ end_flip() { // wdxdisplay8_cat.debug() << "current swapchain from end_flip is " << _wcontext.pSwapChain << "\n"; _dxgsg->show_frame(); } + GraphicsWindow::end_flip(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index 2d84e3073c..b6802a7306 100755 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -259,6 +259,7 @@ end_flip() { //wdxdisplay9_cat.debug() << "current swapchain from end_flip is " << _wcontext.pSwapChain << "\n"; _dxgsg->show_frame(); } + GraphicsWindow::end_flip(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 245cdfedd3..1f63ae9190 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -147,7 +147,7 @@ begin_flip() { // context is current before flipping the windows, and insisting // on doing so can be a significant performance hit. - // make_current(); + //make_current(); glXSwapBuffers(_display, _xwindow); }