Skip to content

Commit

Permalink
out of the box web support
Browse files Browse the repository at this point in the history
  • Loading branch information
szabolcsdombi committed Oct 8, 2023
1 parent 83accb7 commit 390cbe1
Show file tree
Hide file tree
Showing 4 changed files with 3,711 additions and 4 deletions.
4 changes: 1 addition & 3 deletions _zengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ def loader(name):
return ctypes.cast(lib[name], ctypes.c_void_p).value

elif sys.platform.startswith('emscripten'):
import webgl2

loader = webgl2.load_opengl_function
loader = None

self.load_opengl_function = loader

Expand Down
17 changes: 16 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

extra_compile_args = []
extra_link_args = []
define_macros = []
sources = ['zengl.c']

stubs = {
'packages': ['zengl-stubs'],
Expand All @@ -18,6 +20,18 @@
if sys.platform.startswith('darwin'):
extra_compile_args = ['-Wno-writable-strings']

if os.getenv('PYODIDE'):
import re

with open('zengl_web.js') as f:
setup_gl = re.sub(r'\s+', ' ', f.read(), flags=re.M)

define_macros = [
('setup_gl', f'"{setup_gl}"'),
]
sources = ['zengl_web.c']
stubs = {}

if os.getenv('ZENGL_COVERAGE'):
extra_compile_args += ['-O0', '--coverage']
extra_link_args += ['-O0', '--coverage']
Expand All @@ -34,9 +48,10 @@

ext = Extension(
name='zengl',
sources=['zengl.c'],
sources=sources,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
define_macros=define_macros,
)

with open('README.md') as readme:
Expand Down
Loading

0 comments on commit 390cbe1

Please sign in to comment.