@@ -439,6 +439,7 @@ impl Context {
439
439
version,
440
440
pf_reqs,
441
441
surface_type,
442
+ opengl,
442
443
config_selector,
443
444
) ?
444
445
} ;
@@ -1008,6 +1009,7 @@ unsafe fn choose_fbconfig<F>(
1008
1009
version : Option < ( u8 , u8 ) > ,
1009
1010
pf_reqs : & PixelFormatRequirements ,
1010
1011
surface_type : SurfaceType ,
1012
+ opengl : & GlAttributes < & Context > ,
1011
1013
mut config_selector : F ,
1012
1014
) -> Result < ( ffi:: egl:: types:: EGLConfig , PixelFormat ) , CreationError >
1013
1015
where
@@ -1177,7 +1179,42 @@ where
1177
1179
) ) ;
1178
1180
}
1179
1181
1180
- if num_configs == 0 {
1182
+ // We're interested in those configs which allow our desired VSync.
1183
+ let desired_swap_interval = if opengl. vsync {
1184
+ 1
1185
+ } else {
1186
+ 0
1187
+ } ;
1188
+
1189
+ let config_ids = config_ids. into_iter ( ) . filter ( |& config| {
1190
+ let mut min_swap_interval = 0 ;
1191
+ let res = egl. GetConfigAttrib (
1192
+ display,
1193
+ config,
1194
+ ffi:: egl:: MIN_SWAP_INTERVAL as ffi:: egl:: types:: EGLint ,
1195
+ & mut min_swap_interval,
1196
+ ) ;
1197
+
1198
+ if desired_swap_interval < min_swap_interval {
1199
+ return false ;
1200
+ }
1201
+
1202
+ let mut max_swap_interval = 0 ;
1203
+ let res = egl. GetConfigAttrib (
1204
+ display,
1205
+ config,
1206
+ ffi:: egl:: MAX_SWAP_INTERVAL as ffi:: egl:: types:: EGLint ,
1207
+ & mut max_swap_interval,
1208
+ ) ;
1209
+
1210
+ if desired_swap_interval > max_swap_interval {
1211
+ return false ;
1212
+ }
1213
+
1214
+ true
1215
+ } ) . collect :: < Vec < _ > > ( ) ;
1216
+
1217
+ if config_ids. is_empty ( ) {
1181
1218
return Err ( CreationError :: NoAvailablePixelFormat ) ;
1182
1219
}
1183
1220
0 commit comments