Skip to content

Commit

Permalink
Expose OpenGL extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
einarf committed Sep 29, 2024
1 parent fb28eea commit 7861155
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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

0 comments on commit 7861155

Please sign in to comment.