mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 03:15:07 -04:00
If the sync flag is set in GraphicsWindow, end_frame flushes the pipe,
but doesn't swap buffers. To swap buffers, call GraphicsWindow.swap()
This commit is contained in:
parent
65d37b8c1a
commit
307b0afd05
@ -288,3 +288,26 @@ get_button_event(int device) {
|
|||||||
return _input_devices[device].get_button_event();
|
return _input_devices[device].get_button_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsWindow::set_sync
|
||||||
|
// Access: Public
|
||||||
|
// Description: Sets flag for whether the buffer swap is done
|
||||||
|
// implicitely at the end of each frame, or done
|
||||||
|
// explicitely for the purpose of synchronization.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void GraphicsWindow::
|
||||||
|
set_sync(const bool b) {
|
||||||
|
_is_synced = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsWindow::get_sync
|
||||||
|
// Access: Public
|
||||||
|
// Description: Returns whether buffer swap is done explicitely by
|
||||||
|
// call to swap() method.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool GraphicsWindow::
|
||||||
|
get_sync() const {
|
||||||
|
return _is_synced;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,7 @@ GraphicsWindow(GraphicsPipe *pipe) : Configurable() {
|
|||||||
_idle_callback = NULL;
|
_idle_callback = NULL;
|
||||||
_resize_callback = NULL;
|
_resize_callback = NULL;
|
||||||
_frame_number = 0;
|
_frame_number = 0;
|
||||||
|
_is_synced = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -157,6 +158,7 @@ GraphicsWindow(GraphicsPipe *pipe,
|
|||||||
_draw_callback = NULL;
|
_draw_callback = NULL;
|
||||||
_idle_callback = NULL;
|
_idle_callback = NULL;
|
||||||
_resize_callback = NULL;
|
_resize_callback = NULL;
|
||||||
|
_is_synced = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -601,6 +603,16 @@ void GraphicsWindow::read_priorities(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsWindow::swap
|
||||||
|
// Access: Public
|
||||||
|
// Description: Swaps buffers explicitely as synchronization
|
||||||
|
// mechanism.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void GraphicsWindow::
|
||||||
|
swap() {
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicsWindow::deactivate_window(void) { return; }
|
void GraphicsWindow::deactivate_window(void) { return; }
|
||||||
void GraphicsWindow::reactivate_window(void) { return; }
|
void GraphicsWindow::reactivate_window(void) { return; }
|
||||||
|
|
||||||
|
@ -121,6 +121,11 @@ PUBLISHED:
|
|||||||
INLINE void set_frame_number(const int);
|
INLINE void set_frame_number(const int);
|
||||||
INLINE int get_frame_number() const;
|
INLINE int get_frame_number() const;
|
||||||
|
|
||||||
|
INLINE void set_sync(const bool);
|
||||||
|
INLINE bool get_sync() const;
|
||||||
|
|
||||||
|
virtual void swap();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void resized(const int, const int);
|
virtual void resized(const int, const int);
|
||||||
|
|
||||||
@ -196,6 +201,8 @@ protected:
|
|||||||
vfnii _resize_function;
|
vfnii _resize_function;
|
||||||
int _frame_number;
|
int _frame_number;
|
||||||
|
|
||||||
|
bool _is_synced;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Callback *_draw_callback;
|
Callback *_draw_callback;
|
||||||
|
@ -673,12 +673,18 @@ void glxGraphicsWindow::end_frame( void )
|
|||||||
|
|
||||||
{
|
{
|
||||||
PStatTimer timer(_swap_pcollector);
|
PStatTimer timer(_swap_pcollector);
|
||||||
glXSwapBuffers(_display, _xwindow);
|
if(_is_synced)glFinish();
|
||||||
|
else glXSwapBuffers(_display, _xwindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsWindow::end_frame();
|
GraphicsWindow::end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void glxGraphicsWindow::swap()
|
||||||
|
{
|
||||||
|
if(_is_synced) glXSwapBuffers(_display, _xwindow);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: handle_reshape
|
// Function: handle_reshape
|
||||||
// Access:
|
// Access:
|
||||||
|
@ -55,6 +55,8 @@ public:
|
|||||||
virtual void update(void);
|
virtual void update(void);
|
||||||
virtual void end_frame( void );
|
virtual void end_frame( void );
|
||||||
|
|
||||||
|
virtual void swap(void);
|
||||||
|
|
||||||
INLINE Window get_xwindow(void) { return _xwindow; }
|
INLINE Window get_xwindow(void) { return _xwindow; }
|
||||||
|
|
||||||
virtual TypeHandle get_gsg_type() const;
|
virtual TypeHandle get_gsg_type() const;
|
||||||
|
@ -1022,11 +1022,21 @@ void wglGraphicsWindow::end_frame(void) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
PStatTimer timer(_swap_pcollector);
|
PStatTimer timer(_swap_pcollector);
|
||||||
SwapBuffers(_hdc);
|
if(_is_synced) glFinish();
|
||||||
|
else SwapBuffers(_hdc);
|
||||||
}
|
}
|
||||||
GraphicsWindow::end_frame();
|
GraphicsWindow::end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: swap
|
||||||
|
// Access:
|
||||||
|
// Description: Swaps the front and back buffers explicitly.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void wglGraphicsWindow::swap(void) {
|
||||||
|
if(_is_synced)SwapBuffers(_hdc);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: handle_reshape
|
// Function: handle_reshape
|
||||||
// Access:
|
// Access:
|
||||||
|
@ -66,6 +66,7 @@ public:
|
|||||||
virtual bool supports_update() const;
|
virtual bool supports_update() const;
|
||||||
virtual void update(void);
|
virtual void update(void);
|
||||||
virtual void end_frame( void );
|
virtual void end_frame( void );
|
||||||
|
virtual void swap( void );
|
||||||
|
|
||||||
virtual TypeHandle get_gsg_type() const;
|
virtual TypeHandle get_gsg_type() const;
|
||||||
static GraphicsWindow* make_wglGraphicsWindow(const FactoryParams ¶ms);
|
static GraphicsWindow* make_wglGraphicsWindow(const FactoryParams ¶ms);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user