Skip to content

Commit

Permalink
Release 0.1.1
Browse files Browse the repository at this point in the history
- Fix the OpenGL driver being broken if window support isn't included
  • Loading branch information
JesseTG committed May 31, 2024
1 parent dd8c819 commit e7625ca
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ 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.1] - 2024-05-31

### Changed

- Added `moderngl`'s `headless` extra when installing this package's `opengl` extra.

### Fixed

- Fixed a bug where `ModernGlVideoDriver` couldn't be used
without the `moderngl_window` package installed.

## [0.1.0] - 2024-05-31

### Added
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ add one or more of the following extras to the `install` command:
Required if contributing to libretro.py.
- **`opengl`:** Support for the built-in OpenGL video driver.
Required if testing a core's OpenGL support.
- **`opengl-window`:** Same as the `opengl` extra,
but with support for opening an actual window.
Can help simplify some debugging tasks,
e.g. RenderDoc usage.

For example, if you want to submit an improvement to the OpenGL video driver,
you would install libretro.py like so:
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ docs = [
]
doc = ["libretro.py[docs]"] # Alias for the docs extra
opengl = [
'moderngl == 5.10.*',
'moderngl[headless] == 5.10.*',
'PyOpenGL == 3.1.*',
]
all = ["libretro.py[build,dev,docs,opengl]"]
opengl-window = [
'moderngl-window == 2.4.*',
"libretro.py[opengl]"
]
all = ["libretro.py[build,dev,docs,opengl,opengl-window]"]

[project.urls]
Homepage = "https://github.com/JesseTG/libretro.py"
Expand Down
16 changes: 11 additions & 5 deletions src/libretro/drivers/video/opengl/moderngl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
from typing import final, override

import moderngl
import moderngl_window

try:
import moderngl_window
from moderngl_window.context.base import BaseWindow
except ImportError:
moderngl_window = None
BaseWindow = None

from moderngl import (
Buffer,
Context,
Expand All @@ -18,7 +25,6 @@
VertexArray,
create_context,
)
from moderngl_window.context.base import BaseWindow
from OpenGL import GL

from libretro.api.av import retro_game_geometry, retro_system_av_info
Expand Down Expand Up @@ -194,7 +200,7 @@ def __init__(
self._window_class: type[BaseWindow] | None = None

# TODO: Honor os.environ.get("MODERNGL_WINDOW")
if window is not None:
if window is not None and moderngl_window is not None:
window_mode = _DEFAULT_WINDOW_IMPL if window == "default" else window
if not isinstance(window, str):
raise TypeError(f"Expected a str or None, got {type(window).__name__}")
Expand Down Expand Up @@ -363,7 +369,7 @@ def reinit(self) -> None:
geometry = self._system_av_info.geometry

match context_type:
case HardwareContext.NONE | HardwareContext.OPENGL if self._window_class:
case HardwareContext.NONE | HardwareContext.OPENGL if self._window_class is not None:
self._window = self._window_class(
title="libretro.py",
size=(geometry.base_width, geometry.base_height),
Expand All @@ -373,7 +379,7 @@ def reinit(self) -> None:
)
moderngl_window.activate_context(self._window)
self._context = self._window.ctx
case HardwareContext.OPENGL_CORE if self._window_class:
case HardwareContext.OPENGL_CORE if self._window_class is not None:
self._window = self._window_class(
title="libretro.py",
gl_version=(self._callback.version_major, self._callback.version_minor),
Expand Down

0 comments on commit e7625ca

Please sign in to comment.