implement GLX_SGI_swap_control

This commit is contained in:
David Rose 2005-04-14 17:33:39 +00:00
parent 00485bf6c8
commit 17c9ee24ab
6 changed files with 45 additions and 8 deletions

View File

@ -231,6 +231,15 @@ ConfigVariableDouble background_color
PRC_DESC("Specifies the rgb(a) value of the default background color for a " PRC_DESC("Specifies the rgb(a) value of the default background color for a "
"new window or offscreen buffer.")); "new window or offscreen buffer."));
ConfigVariableBool sync_video
("sync-video", true,
PRC_DESC("Configure this true to request the rendering to sync to the video "
"refresh, or false to let your frame rate go as high as it can, "
"irrespective of the video refresh. Usually you want this true, "
"but it may be useful to set it false during development for a "
"cheesy estimate of scene complexity. Some drivers may ignore "
"this request."));
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: init_libdisplay // Function: init_libdisplay

View File

@ -80,6 +80,7 @@ extern EXPCL_PANDA ConfigVariableInt stencil_bits;
extern EXPCL_PANDA ConfigVariableInt multisamples; extern EXPCL_PANDA ConfigVariableInt multisamples;
extern EXPCL_PANDA ConfigVariableDouble background_color; extern EXPCL_PANDA ConfigVariableDouble background_color;
extern EXPCL_PANDA ConfigVariableBool sync_video;
extern EXPCL_PANDA void init_libdisplay(); extern EXPCL_PANDA void init_libdisplay();

View File

@ -75,6 +75,35 @@ glxGraphicsStateGuardian::
} }
} }
////////////////////////////////////////////////////////////////////
// Function: glxGraphicsStateGuardian::reset
// Access: Public, Virtual
// Description: Resets all internal state as if the gsg were newly
// created.
////////////////////////////////////////////////////////////////////
void glxGraphicsStateGuardian::
reset() {
GLGraphicsStateGuardian::reset();
_supports_swap_control = has_extension("GLX_SGI_swap_control");
if (_supports_swap_control) {
_glXSwapIntervalSGI =
(PFNGLXSWAPINTERVALSGIPROC)get_extension_func("glX", "SwapIntervalSGI");
if (_glXSwapIntervalSGI == NULL) {
glxdisplay_cat.error()
<< "Driver claims to support GLX_SGI_swap_control extension, but does not define all functions.\n";
_supports_swap_control = false;
}
}
if (_supports_swap_control) {
// Set the video-sync setting up front, if we have the extension
// that supports it.
_glXSwapIntervalSGI(sync_video ? 1 : 0);
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: glxGraphicsStateGuardian::glx_is_at_least_version // Function: glxGraphicsStateGuardian::glx_is_at_least_version
// Access: Public // Access: Public

View File

@ -70,6 +70,8 @@ public:
virtual ~glxGraphicsStateGuardian(); virtual ~glxGraphicsStateGuardian();
virtual void reset();
bool glx_is_at_least_version(int major_version, int minor_version) const; bool glx_is_at_least_version(int major_version, int minor_version) const;
GLXContext _context; GLXContext _context;
@ -81,6 +83,10 @@ public:
GLXFBConfig _fbconfig; GLXFBConfig _fbconfig;
#endif // HAVE_GLXFBCONFIG #endif // HAVE_GLXFBCONFIG
public:
bool _supports_swap_control;
PFNGLXSWAPINTERVALSGIPROC _glXSwapIntervalSGI;
protected: protected:
virtual void get_gl_version(); virtual void get_gl_version();
virtual void get_extra_extensions(); virtual void get_extra_extensions();

View File

@ -61,13 +61,6 @@ ConfigVariableBool ime_hide
("ime-hide", false, ("ime-hide", false,
PRC_DESC("Set this true to hide ime windows.")); PRC_DESC("Set this true to hide ime windows."));
ConfigVariableBool sync_video
("sync-video", true,
PRC_DESC("Configure this true to force the rendering to sync to the video "
"refresh, or false to let your frame rate go as high as it can, "
"irrespective of the video refresh (if this capability is "
"available in the ICD)."));
ConfigVariableBool swapbuffer_framelock ConfigVariableBool swapbuffer_framelock
("swapbuffer-framelock", false, ("swapbuffer-framelock", false,
PRC_DESC("Set this true to enable HW swapbuffer frame-lock on 3dlabs cards")); PRC_DESC("Set this true to enable HW swapbuffer frame-lock on 3dlabs cards"));

View File

@ -33,7 +33,6 @@ extern ConfigVariableBool ime_composition_w;
extern ConfigVariableBool ime_aware; extern ConfigVariableBool ime_aware;
extern ConfigVariableBool ime_hide; extern ConfigVariableBool ime_hide;
extern EXPCL_PANDAWIN ConfigVariableBool sync_video;
extern EXPCL_PANDAWIN ConfigVariableBool swapbuffer_framelock; extern EXPCL_PANDAWIN ConfigVariableBool swapbuffer_framelock;
extern EXPCL_PANDAWIN void init_libwindisplay(); extern EXPCL_PANDAWIN void init_libwindisplay();