From 853c879f0a6de1a77d614ea2ef1839d9356dccf9 Mon Sep 17 00:00:00 2001 From: Jesse Talavera Date: Mon, 3 Jun 2024 18:49:56 -0400 Subject: [PATCH] Release 0.1.4 --- CHANGELOG.md | 7 ++++++ src/libretro/drivers/video/opengl/moderngl.py | 25 +++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a7ff6..ec82ea0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 > breaking changes may be introduced > at any time without warning. +## [0.1.4] - 2024-06-03 + +### Fixed + +- Prevent a failure to import PyOpenGL from stopping `ModernGlVideoDriver` + from being imported. + ## [0.1.3] - 2024-06-02 ### Fixed diff --git a/src/libretro/drivers/video/opengl/moderngl.py b/src/libretro/drivers/video/opengl/moderngl.py index e20fb0d..8706b6b 100644 --- a/src/libretro/drivers/video/opengl/moderngl.py +++ b/src/libretro/drivers/video/opengl/moderngl.py @@ -12,6 +12,9 @@ try: import moderngl_window from moderngl_window.context.base import BaseWindow + + # These features require moderngl_window, + # but I don't want to require that it be installed except ImportError: moderngl_window = None BaseWindow = None @@ -25,7 +28,11 @@ VertexArray, create_context, ) -from OpenGL import GL + +try: + from OpenGL import GL +except ImportError: + GL = None from libretro.api.av import retro_game_geometry, retro_system_av_info from libretro.api.video import ( @@ -401,8 +408,12 @@ def reinit(self) -> None: self._context = create_context(require=ver, standalone=True, share=self._shared) self._has_debug = ( - "GL_KHR_debug" in self._context.extensions - or "GL_ARB_debug_output" in self._context.extensions + GL + and GL.glObjectLabel + and ( + "GL_KHR_debug" in self._context.extensions + or "GL_ARB_debug_output" in self._context.extensions + ) ) self._context.gc_mode = "auto" self.__init_fbo() @@ -426,7 +437,7 @@ def reinit(self) -> None: ) # TODO: Make the particular names configurable - if self._has_debug and GL.glObjectLabel: + if self._has_debug: GL.glObjectLabel( GL.GL_PROGRAM, self._shader_program.glo, -1, b"libretro.py Shader Program" ) @@ -624,7 +635,7 @@ def __init_fbo(self): # Similar to glGenFramebuffers, glBindFramebuffer, and glFramebufferTexture2D self._fbo = self._context.framebuffer(self._color, self._depth) - if self._has_debug and GL.glObjectLabel: + if self._has_debug: GL.glObjectLabel( GL.GL_TEXTURE, self._color.glo, -1, b"libretro.py Main FBO Color Attachment" ) @@ -667,7 +678,7 @@ def __init_hw_render(self): ) self._hw_render_fbo.clear() - if self._has_debug and GL.glObjectLabel: + if self._has_debug: GL.glObjectLabel( GL.GL_FRAMEBUFFER, self._hw_render_fbo.glo, @@ -713,7 +724,7 @@ def __update_cpu_texture(self, data: memoryview, width: int, height: int, pitch: ) # moderngl can't natively express GL_RGB5 - if self._has_debug and GL.glObjectLabel: + if self._has_debug: GL.glObjectLabel( GL.GL_TEXTURE, self._cpu_color.glo, -1, b"libretro.py CPU-Rendered Frame" )