File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -193,12 +193,32 @@ export class SwipeController {
193
193
ctx . clip ( ) ;
194
194
} else {
195
195
// ctx instanceof WebGLRenderingContext
196
- ctx . clear ( ctx . COLOR_BUFFER_BIT ) ;
196
+ this . fixWebGLContextScissorClear ( ctx ) ;
197
197
ctx . enable ( ctx . SCISSOR_TEST ) ;
198
198
ctx . scissor ( 0 , 0 , width , height ) ;
199
199
}
200
200
}
201
201
202
+ /**
203
+ * Will monkey-patch the context to make sure that clear() calls will not
204
+ * take into account any scissor test previously set.
205
+ * @param {WebGLRenderingContext } gl WebGL Context
206
+ * @private
207
+ */
208
+ fixWebGLContextScissorClear ( gl ) {
209
+ if ( gl . _scissorClearFixed ) {
210
+ return ;
211
+ }
212
+ const clearFn = gl . clear ;
213
+ gl . clear = function ( ...args ) {
214
+ const scissorEnabled = gl . getParameter ( gl . SCISSOR_TEST ) ;
215
+ scissorEnabled && gl . disable ( gl . SCISSOR_TEST ) ;
216
+ clearFn . apply ( gl , args ) ;
217
+ scissorEnabled && gl . enable ( gl . SCISSOR_TEST ) ;
218
+ } ;
219
+ gl . _scissorClearFixed = true ;
220
+ }
221
+
202
222
/**
203
223
* @param {?Event|import('ol/events/Event').default } evt OpenLayers object event.
204
224
* @private
You can’t perform that action at this time.
0 commit comments