Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose OpenGL extensions #2379

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions arcade/gl/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@ def info(self) -> GLInfo:
"""
return self._info

@property
def extensions(self) -> set[str]:
"""
Get a set of supported OpenGL extensions strings for this context.

This can be used to check if a specific extension is supported::

# Check if bindless textures are supported
"GL_ARB_bindless_texture" in ctx.extensions
# Check for multiple extensions
expected_extensions = {"GL_ARB_bindless_texture", "GL_ARB_get_program_binary"}
ctx.extensions & expected_extensions == expected_extensions
"""
return gl.gl_info.get_extensions()

@property
def stats(self) -> ContextStats:
"""
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/gl/test_opengl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def test_ctx(ctx):
assert ctx.blend_func == ctx.BLEND_PREMULTIPLIED_ALPHA


def test_extensions(ctx):
assert isinstance(ctx.extensions, set)
assert len(ctx.extensions) > 0


def test_viewport(ctx):
vp = 0, 0, 100, 100
ctx.viewport = vp
Expand Down
Loading