@@ -115,9 +115,9 @@ required).
115
115
| :sl:`Initialize a window or screen for display`
116
116
| :sg:`set_mode(size=(0, 0), flags=0, depth=0, display=0, vsync=0) -> Surface`
117
117
118
- This function will create a display Surface. The arguments passed in are
119
- requests for a display type. The actual created display will be the best
120
- possible match supported by the system.
118
+ This will create a window or display output and return a display Surface.
119
+ The arguments passed in are requests for a display type. The actual created
120
+ display will be the best possible match supported by the system.
121
121
122
122
Note that calling this function implicitly initializes ``pygame.display ``, if
123
123
it was not initialized before.
@@ -173,21 +173,42 @@ required).
173
173
.. versionadded :: 2.0.0 ``SCALED``, ``SHOWN`` and ``HIDDEN``
174
174
175
175
By setting the ``vsync `` parameter to ``1 ``, it is possible to get a display
176
- with vertical sync, but you are not guaranteed to get one. The request only
177
- works at all for calls to ``set_mode() `` with the ``pygame.OPENGL `` or
178
- ``pygame.SCALED `` flags set, and is still not guaranteed even with one of
179
- those set. What you get depends on the hardware and driver configuration
180
- of the system pygame is running on. Here is an example usage of a call
176
+ with vertical sync at a constant frame rate. Subsequent calls to
177
+ :func: `pygame.display.flip() ` will block (i.e. *wait *) until the screen has
178
+ refreshed.
179
+ Be careful when using this feature together with ``pygame.time.Clock `` or
180
+ :func: `pygame.time.delay() `, as multiple forms of waiting and frame rate
181
+ limiting may interact to cause skipped frames.
182
+
183
+ The request only works when graphics acceleration is available on the
184
+ system. The exact behaviour depends on the hardware and driver
185
+ configuration. When ``vsync `` is requested, but unavailable,
186
+ ``set_mode() `` may raise an exception.
187
+
188
+ Setting the ``vsync `` parameter to ``-1 `` in conjunction with ``OPENGL ``
189
+ will request the OpenGL-specific feature "adaptive vsync".
190
+
191
+ Here is an example usage of a call
181
192
to ``set_mode() `` that may give you a display with vsync:
182
193
183
194
::
184
195
185
196
flags = pygame.OPENGL | pygame.FULLSCREEN
186
- window_surface = pygame.display.set_mode((1920, 1080), flags, vsync=1)
197
+ try:
198
+ window_surface = pygame.display.set_mode((1920, 1080), flags, vsync=1)
199
+ vsync_success=True
200
+ except pygame.error:
201
+ window_surface = pygame.display.set_mode((1920, 1080), flags)
202
+ vsync_success=False
187
203
188
- Vsync behaviour is considered experimental, and may change in future releases.
204
+ .. versionadded :: 2.0.0 ``vsync`` parameter
205
+
206
+ .. versionchanged :: 2.2.0 passing ``vsync`` can raise an exception
207
+
208
+ .. versionchanged :: 2.2.0 explicit request for "adaptive vsync"
209
+
210
+ .. versionchanged :: 2.2.0 ``vsync=1`` does not require ``SCALED`` or ``OPENGL``
189
211
190
- .. versionadded :: 2.0.0 ``vsync``
191
212
192
213
Basic example:
193
214
@@ -723,7 +744,43 @@ required).
723
744
724
745
.. versionadded :: 2.0.0
725
746
747
+ .. function :: is_vsync
748
+
749
+ | :sl:`Returns True if vertical synchronisation for pygame.display.flip() is enabled`
750
+ | :sg:`is_vsync() -> bool`
751
+
752
+ .. versionadded :: 2.2.0
753
+
754
+ .. function :: get_current_refresh_rate() -> int
755
+
756
+ | :sl:`Returns the screen refresh rate or 0 if unknown`
757
+ | :sg:`get_current_refresh_rate() -> int`
758
+
759
+ The screen refresh rate for the current window. In windowed mode, this
760
+ should be equal to the refresh rate of the desktop the window is on.
761
+
762
+ If no window is open, an exception is raised.
763
+
764
+ When a constant refresh rate cannot be determined, 0 is returned.
765
+
766
+ .. versionadded :: 2.2.0
767
+
768
+ .. function :: get_desktop_refresh_rates() -> list
769
+
770
+ | :sl:`Returns the screen refresh rates for all displays (in windowed mode).`
771
+ | :sg:`get_desktop_refresh_rates() -> list`
772
+
773
+ If the current window is in full-screen mode, the actual refresh rate for
774
+ that window can differ.
775
+
776
+ This is safe to call when no window is open (i.e. before any calls to
777
+ :func: `pygame.display.set_mode() `
778
+
779
+ When a constant refresh rate cannot be determined, 0 is returned for that
780
+ desktop.
781
+
726
782
783
+ .. versionadded :: 2.2.0
727
784
.. ## pygame.display.set_allow_screensaver ##
728
785
729
786
.. ## pygame.display ##
0 commit comments