2222from arcade .clock import GLOBAL_CLOCK , GLOBAL_FIXED_CLOCK , _setup_clock , _setup_fixed_clock
2323from arcade .color import BLACK
2424from arcade .context import ArcadeContext
25+ from arcade .gl .provider import get_arcade_context , set_provider
2526from arcade .types import LBWH , Color , Rect , RGBANormalized , RGBOrA255
26- from arcade .utils import is_raspberry_pi
27+ from arcade .utils import is_pyodide , is_raspberry_pi
2728from arcade .window_commands import get_display_size , set_window
2829
2930if TYPE_CHECKING :
@@ -157,7 +158,7 @@ def __init__(
157158 center_window : bool = False ,
158159 samples : int = 4 ,
159160 enable_polling : bool = True ,
160- gl_api : str = "gl " ,
161+ gl_api : str = "opengl " ,
161162 draw_rate : float = 1 / 60 ,
162163 fixed_rate : float = 1.0 / 60.0 ,
163164 fixed_frame_cap : int | None = None ,
@@ -167,10 +168,17 @@ def __init__(
167168 if os .environ .get ("REPL_ID" ):
168169 antialiasing = False
169170
171+ desired_gl_provider = "opengl"
172+ if is_pyodide ():
173+ gl_api = "webgl"
174+
175+ if gl_api == "webgl" :
176+ desired_gl_provider = "webgl"
177+
170178 # Detect Raspberry Pi and switch to OpenGL ES 3.1
171179 if is_raspberry_pi ():
172180 gl_version = 3 , 1
173- gl_api = "gles "
181+ gl_api = "opengles "
174182
175183 self .closed = False
176184 """Indicates if the window was closed"""
@@ -184,7 +192,7 @@ def __init__(
184192 config = gl .Config (
185193 major_version = gl_version [0 ],
186194 minor_version = gl_version [1 ],
187- opengl_api = gl_api , # type: ignore # pending: upstream fix
195+ opengl_api = gl_api . replace ( "open" , "" ) , # type: ignore # pending: upstream fix
188196 double_buffer = True ,
189197 sample_buffers = 1 ,
190198 samples = samples ,
@@ -208,7 +216,7 @@ def __init__(
208216 config = gl .Config (
209217 major_version = gl_version [0 ],
210218 minor_version = gl_version [1 ],
211- opengl_api = gl_api , # type: ignore # pending: upstream fix
219+ opengl_api = gl_api . replace ( "open" , "" ) , # type: ignore # pending: upstream fix
212220 double_buffer = True ,
213221 depth_size = 24 ,
214222 stencil_size = 8 ,
@@ -277,7 +285,9 @@ def __init__(
277285
278286 self .push_handlers (on_resize = self ._on_resize )
279287
280- self ._ctx : ArcadeContext = ArcadeContext (self , gc_mode = gc_mode , gl_api = gl_api )
288+ set_provider (desired_gl_provider )
289+ self ._ctx : ArcadeContext = get_arcade_context (self , gc_mode = gc_mode , gl_api = gl_api )
290+ # self._ctx: ArcadeContext = ArcadeContext(self, gc_mode=gc_mode, gl_api=gl_api)
281291 self ._background_color : Color = BLACK
282292
283293 self ._current_view : View | None = None
0 commit comments