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:
khillesl 2001-08-02 18:29:14 +00:00
parent 65d37b8c1a
commit 307b0afd05
7 changed files with 63 additions and 2 deletions

View File

@ -288,3 +288,26 @@ get_button_event(int device) {
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;
}

View File

@ -140,6 +140,7 @@ GraphicsWindow(GraphicsPipe *pipe) : Configurable() {
_idle_callback = NULL;
_resize_callback = NULL;
_frame_number = 0;
_is_synced = false;
}
////////////////////////////////////////////////////////////////////
@ -157,6 +158,7 @@ GraphicsWindow(GraphicsPipe *pipe,
_draw_callback = NULL;
_idle_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::reactivate_window(void) { return; }

View File

@ -121,6 +121,11 @@ PUBLISHED:
INLINE void set_frame_number(const int);
INLINE int get_frame_number() const;
INLINE void set_sync(const bool);
INLINE bool get_sync() const;
virtual void swap();
public:
virtual void resized(const int, const int);
@ -196,6 +201,8 @@ protected:
vfnii _resize_function;
int _frame_number;
bool _is_synced;
protected:
Callback *_draw_callback;

View File

@ -673,12 +673,18 @@ void glxGraphicsWindow::end_frame( void )
{
PStatTimer timer(_swap_pcollector);
glXSwapBuffers(_display, _xwindow);
if(_is_synced)glFinish();
else glXSwapBuffers(_display, _xwindow);
}
GraphicsWindow::end_frame();
}
void glxGraphicsWindow::swap()
{
if(_is_synced) glXSwapBuffers(_display, _xwindow);
}
////////////////////////////////////////////////////////////////////
// Function: handle_reshape
// Access:

View File

@ -55,6 +55,8 @@ public:
virtual void update(void);
virtual void end_frame( void );
virtual void swap(void);
INLINE Window get_xwindow(void) { return _xwindow; }
virtual TypeHandle get_gsg_type() const;

View File

@ -1022,11 +1022,21 @@ void wglGraphicsWindow::end_frame(void) {
{
PStatTimer timer(_swap_pcollector);
SwapBuffers(_hdc);
if(_is_synced) glFinish();
else SwapBuffers(_hdc);
}
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
// Access:

View File

@ -66,6 +66,7 @@ public:
virtual bool supports_update() const;
virtual void update(void);
virtual void end_frame( void );
virtual void swap( void );
virtual TypeHandle get_gsg_type() const;
static GraphicsWindow* make_wglGraphicsWindow(const FactoryParams &params);