12
12
try :
13
13
import moderngl_window
14
14
from moderngl_window .context .base import BaseWindow
15
+
16
+ # These features require moderngl_window,
17
+ # but I don't want to require that it be installed
15
18
except ImportError :
16
19
moderngl_window = None
17
20
BaseWindow = None
25
28
VertexArray ,
26
29
create_context ,
27
30
)
28
- from OpenGL import GL
31
+
32
+ try :
33
+ from OpenGL import GL
34
+ except ImportError :
35
+ GL = None
29
36
30
37
from libretro .api .av import retro_game_geometry , retro_system_av_info
31
38
from libretro .api .video import (
@@ -401,8 +408,12 @@ def reinit(self) -> None:
401
408
self ._context = create_context (require = ver , standalone = True , share = self ._shared )
402
409
403
410
self ._has_debug = (
404
- "GL_KHR_debug" in self ._context .extensions
405
- or "GL_ARB_debug_output" in self ._context .extensions
411
+ GL
412
+ and GL .glObjectLabel
413
+ and (
414
+ "GL_KHR_debug" in self ._context .extensions
415
+ or "GL_ARB_debug_output" in self ._context .extensions
416
+ )
406
417
)
407
418
self ._context .gc_mode = "auto"
408
419
self .__init_fbo ()
@@ -426,7 +437,7 @@ def reinit(self) -> None:
426
437
)
427
438
# TODO: Make the particular names configurable
428
439
429
- if self ._has_debug and GL . glObjectLabel :
440
+ if self ._has_debug :
430
441
GL .glObjectLabel (
431
442
GL .GL_PROGRAM , self ._shader_program .glo , - 1 , b"libretro.py Shader Program"
432
443
)
@@ -624,7 +635,7 @@ def __init_fbo(self):
624
635
# Similar to glGenFramebuffers, glBindFramebuffer, and glFramebufferTexture2D
625
636
self ._fbo = self ._context .framebuffer (self ._color , self ._depth )
626
637
627
- if self ._has_debug and GL . glObjectLabel :
638
+ if self ._has_debug :
628
639
GL .glObjectLabel (
629
640
GL .GL_TEXTURE , self ._color .glo , - 1 , b"libretro.py Main FBO Color Attachment"
630
641
)
@@ -667,7 +678,7 @@ def __init_hw_render(self):
667
678
)
668
679
self ._hw_render_fbo .clear ()
669
680
670
- if self ._has_debug and GL . glObjectLabel :
681
+ if self ._has_debug :
671
682
GL .glObjectLabel (
672
683
GL .GL_FRAMEBUFFER ,
673
684
self ._hw_render_fbo .glo ,
@@ -713,7 +724,7 @@ def __update_cpu_texture(self, data: memoryview, width: int, height: int, pitch:
713
724
)
714
725
# moderngl can't natively express GL_RGB5
715
726
716
- if self ._has_debug and GL . glObjectLabel :
727
+ if self ._has_debug :
717
728
GL .glObjectLabel (
718
729
GL .GL_TEXTURE , self ._cpu_color .glo , - 1 , b"libretro.py CPU-Rendered Frame"
719
730
)
0 commit comments