From 17c9ee24ab95a181263660801a0efbbda5168ec9 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 14 Apr 2005 17:33:39 +0000 Subject: [PATCH] implement GLX_SGI_swap_control --- panda/src/display/config_display.cxx | 9 ++++++ panda/src/display/config_display.h | 1 + .../glxdisplay/glxGraphicsStateGuardian.cxx | 29 +++++++++++++++++++ .../src/glxdisplay/glxGraphicsStateGuardian.h | 6 ++++ panda/src/windisplay/config_windisplay.cxx | 7 ----- panda/src/windisplay/config_windisplay.h | 1 - 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index b66ac2154e..208be6ccc9 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -231,6 +231,15 @@ ConfigVariableDouble background_color PRC_DESC("Specifies the rgb(a) value of the default background color for a " "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 diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index abb87ec6eb..d365b62f83 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -80,6 +80,7 @@ extern EXPCL_PANDA ConfigVariableInt stencil_bits; extern EXPCL_PANDA ConfigVariableInt multisamples; extern EXPCL_PANDA ConfigVariableDouble background_color; +extern EXPCL_PANDA ConfigVariableBool sync_video; extern EXPCL_PANDA void init_libdisplay(); diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 30e7f56541..e5d459454d 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -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 // Access: Public diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.h b/panda/src/glxdisplay/glxGraphicsStateGuardian.h index 4fc3b550e5..db7e6ea3bf 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.h +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.h @@ -70,6 +70,8 @@ public: virtual ~glxGraphicsStateGuardian(); + virtual void reset(); + bool glx_is_at_least_version(int major_version, int minor_version) const; GLXContext _context; @@ -81,6 +83,10 @@ public: GLXFBConfig _fbconfig; #endif // HAVE_GLXFBCONFIG +public: + bool _supports_swap_control; + PFNGLXSWAPINTERVALSGIPROC _glXSwapIntervalSGI; + protected: virtual void get_gl_version(); virtual void get_extra_extensions(); diff --git a/panda/src/windisplay/config_windisplay.cxx b/panda/src/windisplay/config_windisplay.cxx index 325b272dcb..a073e51dc2 100644 --- a/panda/src/windisplay/config_windisplay.cxx +++ b/panda/src/windisplay/config_windisplay.cxx @@ -61,13 +61,6 @@ ConfigVariableBool ime_hide ("ime-hide", false, 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 ("swapbuffer-framelock", false, PRC_DESC("Set this true to enable HW swapbuffer frame-lock on 3dlabs cards")); diff --git a/panda/src/windisplay/config_windisplay.h b/panda/src/windisplay/config_windisplay.h index eb90e997ba..b317a5d53a 100644 --- a/panda/src/windisplay/config_windisplay.h +++ b/panda/src/windisplay/config_windisplay.h @@ -33,7 +33,6 @@ extern ConfigVariableBool ime_composition_w; extern ConfigVariableBool ime_aware; extern ConfigVariableBool ime_hide; -extern EXPCL_PANDAWIN ConfigVariableBool sync_video; extern EXPCL_PANDAWIN ConfigVariableBool swapbuffer_framelock; extern EXPCL_PANDAWIN void init_libwindisplay();